Syndicate content
By Linux Geeks, For Linux Geeks.
Updated: 3 hours 38 min ago

Dropbox available

Mon, 2014-12-01 04:55

Many users uses dropbox in their smartphones and want to be able to sync from the computer too. Been added in FLR repo. Read more about dropbox in our wiki site here.

Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. Never email yourself a file again!

Categories: FLOSS Project Planets

Linux: Install Samsung SCX-4650 Printer / Scanner | Ubuntu 14.04 LTS

Sun, 2014-11-30 22:30
Hello, Today I am sharing steps to Install and Configure Samsung SCX-4650 Printer / Scanner on Linux (Ubuntu 14.04 LTS), This method is very simple and easy to Install on Ubuntu Linux, You just need to download drivers and Install using scripts. Perform following steps to Install Samsung SCX-4650 on Ubuntu 14.04 LTS 1. You need […]
Categories: FLOSS Project Planets

New packages available

Fri, 2014-11-28 07:19

We have added few packages that might come in handy. They are added in the wiki.

Virtualbox – Always fun to play around with different things in a virtual system.

Android-tools – Needed to get fastboot and adb into your system.

Deja-dup – Probably want to make some backups.

Chromium – Open Source web browser.



Categories: FLOSS Project Planets

Enable Contrib and Epel7 repository in your system

Thu, 2014-11-27 15:01

If you have already installed or planning to install in the near future, you need to enable atleast 2 repository to get hold of more packages. Contrib and Epel repository.

It will give you more packages to be able to install from conary.

Read more at: Repository

Those will be enabled as default later, when installation notes and installation guides gets updated. So if you already installed conary with centos, then make sure to enable them.


Categories: FLOSS Project Planets

Encrypt Everything: Encrypt data using GPG and save passwords

Thu, 2014-11-27 10:00
Data security is an important concern these days and encryption is a very powerful tool to secure the data. In my previous post I talked about how to encrypt a disk. Now we are going to talk about how to encrypt files using GNU Privacy Guard (GPG).

GPG uses public key cryptography. This means that instead of having one key to encrypt and decrypt, there are two keys. One of these keys can be publicly shared and hence is known as public key. The other key is to be kept secret and is known as private key. Anything encrypted with public key can only be decrypted with private key.
How to encrypt files?Assuming a scenario that user "test" wants to send an encrypted file to me, the user just has to find my public key, encrypt the data and send it to me where I will be able to decrypt the file using my private key and obtain the data. Note that user "test" doesn't need to have GPG keys generated in order to encrypt and send data to me.
Step1: Let us create a text file which we'll encypt:test$ echo "This is a secret message." > secret.txt
Step2: User "test" needs to find my keys. There are many public servers where one can share their public key in case someone else wants to encrypt the data. One such server is run by MIT at$ gpg --keyserver --search-keys
Step3: Once the user obtains my public key, then encrypting data is really easy.test$ gpg --output secret.txt.gpg --encrypt --recipient secret.txt
The command above will create an encrypted file named secret.txt.gpg which can be shared via email or any other means. Once I get the encrypted file, I can decrypt it using my private keyaditya$ gpg --output secret.txt --decrypt secret.txt.gpg
How to create GPG keys to receive data?Now assume a scenario where "test" user wants to create a set of GPG keys in order to share the public key and receive encrypted data.
Step1: Generate a key pair. The command will present you some options (stick to defaults if you are not sure) and ask for some data like your name and email address etc.test$ gpg --gen-key
Step2: Check the keys.
test$ gpg --list-secret-keys/home/test/.gnupg/secring.gpg-----------------------------sec   2048R/E46749BB 2014-11-23uid                  Aditya TestKeys (This is not a valid key) <>ssb   2048R/C5E57FF2 2014-11-23

Step3: Upload the key to a public server using the id from the above.test$ gpg --keyserver --send-key E46749BB
Now others can search for the key, use it to encrypt the data and send it to the "test" user. 
To use GPG for saving password, have a look at pass utility. It uses GPG to encrypt passwords and other data and store it in a hierarchical format. 
Categories: FLOSS Project Planets

A first Python one-liner

Tue, 2014-11-25 14:37

By Vasudev Ram

1. Install Python 2.7 (if you don't have it already).

2. Run this at the command line:
python -c "print ''.join(list(reversed('!dlrow olleH')))"

- Vasudev Ram - Dancing Bison Enterprises

Contact Page

Share | var addthis_config = {"data_track_clickback":true}; Vasudev Ram

Categories: FLOSS Project Planets

Memorable Quotes – Part 4

Mon, 2014-11-24 05:18
A follow on from:
- Alan Shore: My, uh, best friend has Alzheimer's, in the, uh, very early stages, it hasn't... He is a grand lover of life, and will be for some time. I believe even when his mind starts to really go, he'll still fish he'll laugh and love, and as it progresses he'll still want to live because there will be value for him, in a friendship, in a cigar... The truth is I don't think he will ever come to me and say, this is the day I want to die, but the day is coming and he won't know it... This is perhaps the, the most insidious thing about Alzheimer's... but you see he trusts me to know when that day has arrive, he trusts me... to safe guard his dignity, his legacy, and self respect. He trusts me to prevent his end from becoming a mindless piece of mush and I will. It will be an unbearably painful... thing for me, but I will do it, because I love him. I will end his suffering, because it is the only decent humane and loving thing a person can do.
- "We are strategic but we stop at number crunching, we plan but we don't over manage, we inspire but we don't preach, we code but we're not monkeys." - It was either Otto von Bismarck or Claud Cockburn who said, "Never believe anything until it has been officially denied." Whoever it was, and the internet seems a little confused on the matter, they were on to something. - "Change is a big word that everyone is using. (United States President Barack) Obama uses it, but you have to actually feel it."
- Sandschneider agrees that personal relations have an impact on political relations: "International politics is not a dehumanized process. It is about people coming together. And it is true that it is easier for two people who get along well to negotiate and solve problems than two people who can't stand each other."
- "Skeptics don't make history"
- "Germany won," said Glasman at the debate. "We have a Champions League final between two supporter-owned and democratically governed football clubs. Tradition and the preservation of institutional virtue are a source of energy and modernisation precisely because change and continuity work together; a balance of power is the best system; a negotiated settlement is better than one that is imposed, the domination of any interest violates the demand of what is good; the discovery of the common good between forces that are estranged is the best good of all. It takes longer to get there but the benefits are more enduring." Secondly, for web site owners. Assume the entire world is out to get you. All of it; and everyone living there. It's easier that way! Do whatever you feel necessary to keep your name out of the press. Then do everything that isn't necessary, because it may-well prove to be necessary in the future. And if you're not sure what I mean, get advice, urgently. In his seminal 1931 book, Equality, R H Tawney lamented that the public did not seem resentful of the rich so much as fascinated by their goings-on. Little has changed. For most Brits, stupendous wealth has always been something that is aspired to more than resented. The post-crash fuss about the 1 per cent often seemed to be a civil dispute between its members: well-heeled activists, journalists and union chiefs castigating those who nabbed the best tables in restaurants or pushed up prices of Tuscan villas. And as successive prime ministers have realised, no government anywhere has helped the low-paid by railing against high wages.

The rich, to adapt Jesus in St Matthew's Gospel, will always be with us; the 1 per cent are likely to pull ever further away. But this has its compensations. The lower-paid half of the British populace have never had to pay a smaller share of income tax than today, because the wealthy have never forked out more. And while there is not much David Cameron can do about the rich, there is still plenty he can do about the poor. He doesn't shout about it. But he has rightly concluded that this is where his attention is best focused. "The problem is not ammunition, it's experience," one said, adding: "If we were fighting Americans we would all have been killed by now. They would have killed us with their drone without even needing to send a tank.

"The rebels are brave but they don't even know the difference between a Kalashnikov bullet and a sniper bullet. That weakens the morale of the men," he said. Obama said that "at a time when anyone with a cellphone can spread offensive views around the world with the click of a button," the notion that governments can control the flow of information is obsolete.Obama said that "at a time when anyone with a cellphone can spread offensive views around the world with the click of a button," the notion that governments can control the flow of information is obsolete. Only about 1 in 1,000 Web readers clicks on the average display ad. On Facebook, that number is closer to 1 in 2,000, according to Webtrends. Even ads sent by unsolicited postal mail generate a response rate that is many times higher, according to published industry numbers.,0,4871607.story
- Famous night owls include Winston Churchill, President Obama, Charles Darwin, James Joyce, Marcel Proust, Keith Richards and Elvis Presley. Famous early risers include Napoleon, Ernest Hemingway and George W. Bush.

Professor Jim Horne, of Loughborough University, said: "Evening types tend to be the more extrovert creative types, the poets, artists and inventors, while the morning types are the deducers, as often seen with civil servants and accountants. Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed.
This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter with a half-million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. . . . This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron.[1][4]
- Decades of reform. Globalisation, and the global financial crisis. The uncertainties of the post-September 11 world. Eric Knight: "Those circumstances are ripe for misinterpretation, for populist interpretation, interpretation that focuses on the surface of things and often misses the deeper logic of what's happening." "Falling in love is very real, but I used to shake my head when people talked about soul mates, poor deluded individuals grasping at some supernatural ideal not intended for mortals but sounded pretty in a poetry book. Then, we met, and everything changed, the cynic has become the converted, the sceptic, an ardent zealot."E.A. Bucchianeri, Brushstrokes of a Gadfly
- "No one ever fell in love gracefully."Connie Brockway, The Bridal Season
- "Have you ever longed for someone so much, so deeply that you thought you would die? That your heart would just stop beating? I am longing now, but for whom I don't know. My whole body craves to be held. I am desperate to love and be loved. I want my mind to float into another's. I want to be set free from despair by the love I feel for another. I want to be physically part of someone else. I want to be joined. I want to be open and free to explore every part of them, as though I were exploring myself."Tracey Emin, Strangeland - "Martin's dream is a vision not yet to be realized, a dream yet unfilled, and we have much to do before we can celebrate the dream as reality, as the suppression of voting rights and horrific violence...has so painfully demonstrated."
- Love is more easily experienced than defined. As a theological virtue, by which we love God above all things and our neighbours as ourselves for his sake, it seems remote until we encounter it enfleshed, so to say, in the life of another - in acts of kindness, generosity and self-sacrifice. Love's the one thing that can never hurt anyone, although it may cost dearly. The paradox of love is that it is supremely free yet attaches us with bonds stronger than death. It cannot be bought or sold; there is nothing it cannot face; love is life's greatest blessing.
Categories: FLOSS Project Planets

Make Foresight to ask continue with update? [Y/n]

Mon, 2014-11-24 04:22

From scratch, you won’t get the question when installing/updating/removing applications. That need to be enabled in your system. It will assume you want to do the action and do it. To make it ask first, you need to open a file and add a setting for it. To do it, follow this guide:

sudo gedit /etc/conaryrc

Add this line on a new row:

interactive True

Save the file, now it will ask like you see below.


[tforsman@tforsman ~]$ sudo conary install chromium
[sudo] password for tforsman:
The following updates will be performed:
Install chromium(:rpm)=39.0.2171.65_1.el7.centos-1-1
continue with update? [Y/n]


Categories: FLOSS Project Planets

Possible to download recipes – Foresighters repo

Sun, 2014-11-23 16:29

Iv’e been busy to find a way for users to see what’s been added to foresighters repo and able to download the recipe for the package. And now it’s possible.

First, you can see latest added recipes in the widget on the right side and browse all recipes here:

Don’t forget to look at Videos section, as Iv’e been planning to make some videos in the near future.

Wondered how Foresight Linux 7 looks like? Take a look at the video below.

Categories: FLOSS Project Planets

youtube-dl, Python video download tool, on front page of Hacker News

Sun, 2014-11-23 15:47

By Vasudev Ram

youtube-dl is a video download tool written in Python.

I had blogged about youtube-dl a while ago, here:

youtube-dl, a YouTube downloader in Python [1]

and again some days later, here:

How to download PyCon US 2013 videos for offline viewing using youtube-dl

(The comments on the above post give some better / easier ways to download the videos than I gave in the post.)

Today I saw that a Hacker News thread about youtube-dl was on the front page of Hacker News for at least part of the day (up to the time of writing this). The thread is here:

youtube-dl (on Hacker News)

I scanned the thread and saw many comments saying that the tool is good, what different users are using it for, many advanced tips on how to use it, etc. The original creator of youtube-dl, Ricardo Garcia, as well as a top contributor and the current maintainer (Filippo Valsorda and Philipp Hagemeister, respectively) also participated in the HN thread, as HN users rg3, FiloSottile and phihag_, respectively. I got to know from the thread that youtube-dl has many contributors, and that its source code is updated quite frequently (for changes in video site formats and other issues), both points which I did not know earlier. (I did know that you can use it to update itself, using the -U option).

Overall, the HN thread is a worthwhile read, IMO, for people interested in downloading videos for offline viewing. The thread had over 130 comments at the time of writing this post.

(On a personal note, since I first got to know about youtube-dl and downloaded it, I've been using it a fair amount to download videos every now and then, for offline viewing, and it has worked pretty well. There were only a few times when it gave an error saying the video could not be downloaded, and I am not sure whether it was due to a problem with the tool, or with the video site.)

[1] My first post about youtube-dl also had a brief overview of its code, which may be of interest to some Pythonistas.

This other post which mentions youtube-dl may also be of interest:

The most-watched Python repositories on Github

since youtube-dl was one of those most-watched repositories, at the time of writing that post.

- Vasudev Ram - Dancing Bison Enterprises

Signup for emails about new products from me.

Contact me for Python consulting and training.

Share | var addthis_config = {"data_track_clickback":true}; Vasudev Ram

Categories: FLOSS Project Planets

Foresighters repo up and running for F7

Sun, 2014-11-23 12:56

We have created a foresighters repository for adding additional packages that don’t belong into main repository or in epel.

To be able to use all packages without thinking of specify the label, you can add a search line into system-model and add it in .conaryrc to make it work with conary rq ***

Categories: FLOSS Project Planets

xzgrep for searching in compressed files

Sun, 2014-11-23 07:46
grep is a very powerful tool for everyone who works with text and strings. For searching through logs, errors and other text based data. But if the same data is present inside a compressed archive, like .bz2 or a .xz. Then we need to uncompress it and then use grep on the files.

If the number of such compressed files are too many, uncompressing all of them with out knowing which one contains the data that we are looking for could be a waste of time. This is were xzgrep can come to rescue.

xzgrep can search through compressed files of the formar .bz2,.xz etc and look for strings in the files like grep does. The only difference is that xzgrep can only confirm whether the search string is present in the compressed file or not and not be able to list further details like grep does.

For example let us take two files





Let us create a tar file

tar -cf hello.tar hello1 hello2

Compress it using bunzip

bzip2 -z hello.tar

This will create the compressed file hello.tar.bz2

Now to search for text inside this compressed file.

$ xzgrep 12 hello.tar.bz2 Binary file (standard input) matches

The string 12 is present is hello1 thus the ouput says that a match is found.

$ xzgrep 78 hello.tar.bz2

If match is not found, xzgrep does not mention any thing.

But note that the xzgrep works only on the text files inside the compressed file, like grep works only on text files. Thus if the search string is inside a pdf or any other document, xzgrep will not be able to pick it up.

Categories: FLOSS Project Planets

Encrypt Everything: How to encrypt the disk to protect the data

Sat, 2014-11-22 14:39
Recently, at, some of our services got compromised. We use Amazon Web Services extensively. The person (or group) who attacked us mounted one of our backups and managed to steal some of the data. We could have prevented this simply by ensuring that we use encrypted disks which would have made this attack useless. Learning from our mistakes, we have recently started encrypting everything and I am going to show you how to do that. One point worth noting here is that Amazon AWS does provide encryption support for the EBS volumes but that is transparent and would not help in case of the account getting compromised. I am going to use dm-crypt which is supported by Linux kernel so the steps are quite generic and would work on any kind of disk, on any kind of environment, including Amazon AWS, Google Compute Engine, physical disks in your datacenter.

Our goal is to encrypt /home. To achieve this, we'll attach a disk, encrypt it, move the entire /home data to this disk and create a symbolic link to /home.

Step1: We are going to use Linux Unified Key Setup. For that we need to install cryptsetup package.
# yum install cryptsetup

Step2: While using AWS, never attach the volume to be encrypted while launching the instance. If we do so, the instance will fail to boot up next time because it'll ask for decryption password while booting up which is not possible to supply in AWS. Still if it is absolutely mandatory to do this then I suggest trying to remove entries from fstab and crypttab but it is much easier to just attach the disk after the launching of the instance is done. Assuming that the attached disk is available at /dev/xvdf, we'll setup the encryption now.
# cryptsetup -y -v luksFormat /dev/xvdf
This will overwrite data on /dev/xvdf irrevocably.

Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase:
Verify passphrase:

Command successful.

We can verify the encryption parameters as well. Default is AES 256 bit.
# cryptsetup luksDump /dev/xvdf

Step3: We'll open the device and map it to /dev/mapper/home so that we can use it.
# cryptsetup luksOpen /dev/xvdf home
Enter passphrase for /dev/xvdf:

Step4: This step is optional. To further protect our data, we can zero out the entire disk before even creating the filesystem.
# dd if=/dev/zero of=/dev/mapper/home

Step5: Now we'll create a filesytem
# mkfs.ext4 /dev/mapper/home

Step6: Let us mount and copy the data from /home
# mkdir /myhome
# mount /dev/mapper/home /myhome
# cp -a /home/* /myhome/
# rm -rf /home
# ln -s /myhome /home

Great! Our /home directory is encrypted. But wait a minute.. this approach has a short coming. We have deliberately designed it so that the disk won't auto-mount during the boot because there is no way to give it a password in cloud environment during the boot. Since the disk won't mount, we won't be able to ssh into the machine because the authorized_keys file is kept inside the home directory of the user. To address this problem, either change the "AuthorizedKeysFile" in sshd_config or create a user with home directory in /var/lib or /opt and grant sudo for cryptsetup and mount commands. So after reboot, if we take the first approach, we would be able to ssh without any problem or we'll ssh via other user, mount the encrypted drive and then use it normally.

$ ssh mountuser@<ip>
$ sudo /sbin/cryptsetup luksOpen /dev/xvdf home
$ sudo /bin/mount /dev/mapper/home /myhome/

Couple of points to remember:
  • Do not forget the LUKS password. It cannot be retrieved, if lost.
  • Try it a couple of times on staging machines before doing it on the machines that matter.

Categories: FLOSS Project Planets

Based on Centos 7 – Possible to install now

Sat, 2014-11-22 02:37

Earlier we planned to use Fedora to build Foresight Linux upon. But some issues made it impossible to make that happen. So we will use Centos 7 as core and continue from there.

Now it’s possible to install centos 7 and get conary to work with it.

We have re-written the installation, so you can read how to install everything and get started.

Read more at:


Categories: FLOSS Project Planets

Paramiko’s SFTPFile.truncate()

Fri, 2014-11-21 09:49
Paramiko is the go-to module for utilizing SSH/SFTP in Python.  One one the best features of Paramiko is being able to being able to a remote file and simply use it like you would use a local file.  SFTPClient's open() returns an SFTPFile which is a file-like object that implements theoretically the same behavior as Python's native file object.
But the catch here is file-like.  It is like a file, except when it is not like a file.
The non-likeness I encountered concern's SFTPFile's truncate method.  The native Python file object has a truncate method where the size is option, if not specified it will default to the current offset of the file.  However SFTPClient's truncate method requires the size to be specified.  Failure to specify an size value results in a TypeError exception concerning incorrect number of parameters.
Categories: FLOSS Project Planets

Centos/Redhat Load Balancer – Securing your Piranha Gui

Fri, 2014-11-21 07:26

Way back in 2010 I wrote a post on setting up a CentOS/Redhat load balancer using piranha and the Linux Virtual Server project to provide a load-balancing solution for your critical applications and infrastructure.  These days we mainly use Ubuntu for its up-to-date packages, cloud ubiquity and ease of version upgrade and management; but we still get clients running CentOS and piranha gui for load-balancing.

Linux Load Balancer

Setting up the load-balancer gui is documented in my previous post but one thing that always bothered me was that the piranha-gui is server up over http instead of over https. There is no encryption of traffic to and from the gui front-end and it uses basic authentication, Basically your login credentials are sent over the wire in clear text. Well, Ok, its base 64 encoded but that's not encryption.

Considering that load-balancers are often deployed at remote data-centres, where critical applications are housesd, and administrators access these high-availability devices from an office, over the internet, the risk of a security compromise is just to great to allow this default configuration to be used.

Securing Your Centos/RedHat Load Balancer

Luckily securing piranha is not hard. It is a simple php application that is hosted in an Apache server so configuring it to support SSL is the same as what one would do to secure your Apache HTTP server.

  1. First we need to generate some SSL certificates. We will use self-signed SSL certificates in this exercise as the main purpose is to encrypt traffic between the browser and the remote server. If you want to ensure authenticity of the destination host then get the cert signed by a certificate authority or setup your own and add the CA cert to your list of trusted CAs.

    "openssl req -new -x509 -out /etc/sysconfig/ha/conf/piranha.crt -keyout /etc/sysconfig/ha/conf/piranha.key -nodes"
  2. The piranha.crt is your public key and piranha,key is your super secret private key. Make sure your private key is only readable by the piranha user and is owned by them too.

    "chmod -o-r /etc/sysconfig/ha/conf/piranha.key; chown piranha:piranha /etc/sysconfig/ha/conf/piranha.key"

  3. Now we need to edit the piranha configuration file via "vi /etc/sysconfig/ha/conf/httpd.conf". Add the following lines to the file :

    71 DocumentRoot "/etc/sysconfig/ha/web"  ==> this line already exists. I just put the directives after this.
    72 SSLEngine  on 
    <== Add this line!
    73 SSLCertificateFile /etc/sysconfig/ha/conf/piranha.crt <== Add this line!
    74 SSLCertificateKeyFile /etc/sysconfig/ha/conf/piranha.key <== Add this line!
        85    <Directory />
        86        Options FollowSymLinks
        87        AllowOverride None
        88        SSLRequireSSL <== Add this line!
        89    </Directory>
  4. You will also need to install the mod_ssl package via

    "yum install mod_ssl"

  5. Restart the piranha-gui with "service piranha-gui restart" and enjoy secure administration of your load-balancer :) 
Categories: FLOSS Project Planets

Google Contributor, a new monetization option for online publishers

Thu, 2014-11-20 14:41

By Vasudev Ram

I saw this via a tweet by GigaOm:

Google launches Contributor, a crowdfunding tool for publishers

Excerpts (shortened and partly re-worded) from the GigaOm article:

... Google Contributor, which is designed to allow web users to pay sites that they visit a monthly fee, and in return see no Google ads when they visit those sites.
the new feature is launching with 10 publishing partners, including Mashable, Imgur, WikiHow and Science Daily
the user who goes to the Contributor web site sees a list of participating web sites, and can decide to give them $1, 2 or 3 per month.
The site gets paid when the user actually visits it. The formula for payment is not specified in the GigaOm article.
Earlier, Google also launched a contribution system for YouTube video creators called “Fan Funding,” which allows viewers to donate anywhere from $1 to $500 to the channel of their choice.

Here is the Google Contributor site.

Based on the article, Google Contributor seems like a potentially good idea for web publishers, such as big sites as well as small sites and blogs. Time will tell, though, how useful it turns out to be. I signed up for an invite, and if I get invited, I'll try it out and may write about my experience with it, here on this blog.

Update: Here is another article about Google Contributor, by NextWeb:

- Vasudev Ram - Dancing Bison Enterprises

Signup to be notified about new products from Vasudev Ram.

Contact Page

Share | var addthis_config = {"data_track_clickback":true}; Vasudev Ram

Categories: FLOSS Project Planets

Find if a Python string is an anagram of a palindrome

Wed, 2014-11-19 14:24

By Vasudev Ram

I saw this interesting thread on Hacker News some 10-odd days ago:

HN: Rust and Go

Apart from being generally of interest, it had a sub-thread that was about finding if a given string is an anagram of a palindrome. A few people replied in the thread, giving solutions in different languages, such as Scala, JavaScript, Go and Python.

Some of the Python solutions were already optimized to some extent (e.g. using collections.Counter and functools.partial - it was a thread about the merits of programming languages, after all), so I decided to write one or two simple or naive solutions instead, and then see if those could be optimized some, maybe differently from the solutions in the HN thread.

Here is one such simple solution to the problem, of finding out if a string is an anagram of a palindrome. I've named it (for Is Anagram Of Palindrome, version 01). The solution includes a scramble() function, to make an anagram of a palindrome, so that we have input for the test, and a main function to run the rest of the code to exercise things, for both the case when the string is an anagram of a palindrome, and when it is not.

The logic I've used is this (in pseudocode, even though Python is executable pseudocode, ha ha):
For each character c in the string s:
If c already occurs as a key in dict char_counts,
increment its count (the value corresponding to the key),
else set its count to 1.
After the loop, the char_counts dict will contain the counts
of all the characters in the string, keyed by character.
Then we check how many of those counts are odd.
If at most one count is odd, the string is an anagram of
a palindrome, else not.

And here is the Python code for
Program to find out whether a string is an anagram of a palindrome.
Based on the question posed in this Hacker News thread:

from random import shuffle

def anagram_of_palindrome(s):
char_counts = {}
for c in s:
char_counts[c] = char_counts.get(c, 0) + 1
odd_counts = 0
for v in char_counts.values():
if v % 2 == 1:
odd_counts += 1
return odd_counts <= 1

def scramble(s):
lis = [ c for c in s ]
return ''.join(lis)

def main():
# First, test with a list of strings which are anagrams of palindromes.
aops = ['a', 'bb', 'cdc', 'foof', 'madamimadam', 'ablewasiereisawelba']
for s in aops:
s2 = scramble(s)
print "{} is an anagram of palindrome ({}): {}".format(s2, \
s, anagram_of_palindrome(s2))
# Next, test with a list of strings which are not anagrams of palindromes.
not_aops = ['ab', 'bc', 'cde', 'fool', 'padamimadam']
for s in not_aops:
s2 = scramble(s)
print "{} is an anagram of a palindrome: {}".format(s2, \

And here is the output of running it: $ python
a is an anagram of palindrome (a): True
bb is an anagram of palindrome (bb): True
ccd is an anagram of palindrome (cdc): True
ffoo is an anagram of palindrome (foof): True
daadmamimma is an anagram of palindrome (madamimadam): True
srewaeaawbeilebials is an anagram of palindrome (ablewasiereisawelba): True

ba is an anagram of a palindrome: False
bc is an anagram of a palindrome: False
dec is an anagram of a palindrome: False
loof is an anagram of a palindrome: False
ampdaaiammd is an anagram of a palindrome: False
One simple optimization that can be made is to add these two lines: if odd_counts > 1:
return False
just after the line "odd_count += 1". What that does is stop early if it finds that the number of characters with odd counts is greater than 1, even if there are many more counts to be checked, since our rule has been satisfied.

If I think up more optimizations to the above solution, or any alternative solutions, I'll show them in a future post. Update: Since it is on a related topic, you may also like to check out this other post I wrote a while ago: A simple text file indexing program in Python.

BTW, the two longer palindromes are lower-cased, scrunched-together versions of these well-known palindromes:

Madam, I'm Adam.

Able was I ere I saw Elba

(attributed to Napoleon).

- Vasudev Ram - Dancing Bison Enterprises

Signup for news about products from me.

Contact Page Share | var addthis_config = {"data_track_clickback":true}; Vasudev Ram

Categories: FLOSS Project Planets

Welcome to Emmett Stewart – Guest Blogger

Wed, 2014-11-19 05:08
Hello CafeNinja fans,
I've been asked by CafeNinja to help return content to his blog.  Since I have worked with him for a long time and we have very similar political views, I felt it would be a good fit.  So please keep an eye out for new content coming from me on this blog.

Emmett Stewart

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
Categories: FLOSS Project Planets

Scaled Inference, a cloud AI startup by ex-Googlers, gets Khosla Ventures $8M funding

Sat, 2014-11-15 16:38

By Vasudev Ram

Saw the news via this tweet by @asenkut - Aydin Senkut, Google's first product manager, and founder of Felicis Ventures.

Here is a TechCrunch article about the funding of Scaled Inference by Khosla Ventures:

Excerpts from the article:

Scaled Inference, a startup founded by two ex-Googlers that is building a cloud-based platform for third parties that want to use artificial intelligence and machine learning tools to run their apps and services – has raised another round of funding to continue its development and hiring, a Series A round of $8 million from Khosla Ventures.
has been putting together some of the first products (or services) that will run on top of that platform: pattern recognition, anomaly detection, prediction, and predictive ranking, which will be accessible by developers by way of a set of APIs.
As an example of where pattern recognition might be applied, he says, take a bank or credit card company like Visa.
“The pattern recognition APIs can then be used to detect correlations such as increased spending during certain time periods, at certain locations, by certain customers, on certain items, for certain combinations of these attributes,” he says. In turn, this type of insight can help guide important business decisions
this is a long-term vision, but this is one of the reasons that Scaled Inference went with the investors that it has done, Sercinoglu says. “Vinod Khosla is a long term investor, one of the longest-term thinkers in the business, and ours is a long term vision for AI and machine learning. That really resonated with him.”

Longer term, he says, “We seek to offer the same powerful technology as a public cloud API to everyone and for virtually any application; anything from personalized magazines to intelligent context-sensitive address books, app launchers, e-commerce sites,
They are not open to the public yet.

The idea seems interesting, not just for the applications mentioned, but also for the fact that they plan to offer the service as a public cloud API, available to everyone, so looks like it could have a lot of potential.

- Vasudev Ram - Dancing Bison Enterprises

Sign up to know about new products from me..

Contact Page

Share | var addthis_config = {"data_track_clickback":true}; Vasudev Ram

Categories: FLOSS Project Planets