Friday, November 21, 2014

Google Contributor, a new monetization option for online publishers

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

Thursday, November 20, 2014

Find if a Python string is an anagram of a palindrome

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 iaop_01.py (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 iaop_01.py:

"""
Program to find out whether a string is an anagram of a palindrome.
Based on the question posed in this Hacker News thread:
    https://news.ycombinator.com/item?id=8575589
"""

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 ]
    shuffle(lis)
    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))
    print
    # 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, \
            anagram_of_palindrome(s2))

main()
And here is the output of running it:
$ python iaop_01.py
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

Sunday, November 16, 2014

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

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

Wednesday, November 12, 2014

Visual Studio 2013 Community Edition - free for individuals and teams of five

By Vasudev Ram

Just saw this via a thread on Hacker News (HN):

Visual Studio 2013 Community Edition now available (visualstudio.com) (HN thread)

(Also, just saw a TechCrunch article about Visual Studio Community Edition.)

Excerpt from the TechCrunch article:

[ It’s basically a full version of Visual Studio with no restrictions, except that you can’t use it in an enterprise setting and for teams with more than five people (you can, however, use it for any other kind of commercial and non-commercial project). ]

UPDATE: New HN thread in which this news about Visual Studio Community edition is just a subset: Microsoft takes .NET open source and cross-platform.

Excerpt from that article:

[ NEW YORK — Nov. 12, 2014 — On Wednesday, Microsoft Corp. reinforced its commitment to cross-platform developer experiences by open sourcing the full server-side .NET stack and expanding .NET to run on the Linux and Mac OS platforms.
...
Delivering on its promise to support cross-platform development, Microsoft is providing the full .NET server stack in open source, including ASP.NET, the .NET compiler, the .NET Core Runtime, Framework and Libraries, enabling developers to build with .NET across Windows, Mac or Linux. Through this implementation, Microsoft will work closely with the open source community, taking contributions for future improvements to .NET and will work through the .NET Foundation. ]

Whew! That's pretty big news if it all works out the way they say.

HN thread about the open sourcing of .NET (with over 425 comments, when I first saw it)

The actual site for Visual Studio Community Edition.

Excerpts from the post:

[ Tools: Designers, editors, debuggers, profilers - all packaged up in a single environment.

Languages: Code in C++, Python, HTML5, JavaScript, and of course C#, VB, and F#.

Why this news is of interest to Pythonistas is because the edition supports Python as a language, my guess is, via the add-on or plugin called Python Tools for Visual Studio, about which I've read some good reviews, including one by Scott Hanselman, a while ago; also interesting news because of that fact that if you're an individual or a small team of up to five people, you can develop both free and paid applications using this edition of Visual Studio. And finally, they say that is not a limited version like the Visual Studio Express Editions, but a full version of Visual Studio.

Web: Extensive web tooling for ASP.NET, Node.js, and JavaScript.

And from their Q&A:

Q: Who can use Visual Studio Community?
A: Here’s how individual developers can use Visual Studio Community:
Any individual developer can use Visual Studio Community to create their own free or paid apps.

(There are other terms for companies - check the above site and the TechCrunch article.) ]

I've used Visual Studio products at various times in the past, and this looks interesting. Going to check it out, and will report here in another post if I find anything interesting.

Here is the Wikipedia page for Visual Studio. It has already been updated for the news about the Community Edition.

- Vasudev Ram - Dancing Bison Enterprises

Sign up to know about new products from me.

Contact Page

Alley in park, Bucharest, Romania

By Vasudev Ram



An alley in Herăstrău Park, Bucharest, Romania.

"Every once in a while, take the road less traveled."

- Vasudev Ram - Dancing Bison Enterprises

Contact Page