Category Archives: Uncategorized

New Rails Apps: Flicky and Text-2-Spotify

I’ve spent the last couple weeks learning how to build web apps in Rails. I’m happy to say I finally pushed and published 2 of my favorites to Heroku today!

The first application is called ‘Text-2-Spotify’, and it allows users to text songs to add to their Spotify playlist. I envisioned it being an easy way to give a party the ability to make a collaborative playlist without relying on the Spotify app. You can find the source here and the application is hosted here.

The second application is called ‘Flicky’, and it helps indecisive groups of movie watchers find group consensus on what to watch by individually voting on their favorite films. You can find the hosted app here (Takes about 5 seconds to load from sleep) and the source here.

Rails has been absolutely fantastic to develop on. The community is huge, integrating with API’s is incredible simple, and particularly so when theres an API wrapper written for Ruby. I’d highly recommend anyone interested in learning Rails to consult the fantastic Rails 5 Tutorial by Michael Hartl.

Code Challenge: Girl / Boy Proportion Problem

Code Challenge: Girl / Boy Proportion Problem

This weekend my roommate shared a little puzzle with me, which goes as follows:

In a country in which people only want boys, every family continues to have children until they have a boy. If they have a girl, they have another child. If they have a boy, they stop. What is the proportion of boys to girls in the country?

I think its tempting to initially think that there will be more boys, but after you consider the number of females that could be born waiting for a boy, you might think the opposite.

He was trying to solve it mathematically using the sum of infinite series, but we had a little race to see who could do the Monte-Carlo simulation first. I was really happy with my 6 line solution!

In [52]:
# Simulate a birth.  0 is male, 1 is female
def birth():
    return np.random.binomial(1, .5)
In [53]:
# Input: number of families to simulate
# Output: proportion of males to females born
def new_society(int):
    female = 0
    for i in range(int):
        while (birth()==0): 
            female = female + 1
    return int/(female+int)
In [54]:
# Simulate 100,000 families trying for a boy
new_society(100000)
Out[54]:
0.49985004498650404

For fun, I wrote another function to measure what the largest family would be in this society.

In [55]:
def new_society_v2(int):
    female = 0
    longest_fam = 0
    temp_size = 0
    for i in range(int):
        while (birth()==0): 
            female = female + 1
            temp_size = temp_size + 1
        if(temp_size > longest_fam):
            longest_fam = temp_size
        temp_size = 0
    return int/(female+int), longest_fam
In [57]:
new_society_v2(100000)
Out[57]:
(0.5025226637721362, 19)

19 kids! Thats a lot of females just to get your male heir.

Hey, thanks for stopping by! Want some tea..? Come in, come in. I’ll get the kettle going.
Let me show you around. Over to the right and below I have some machine learning tutorials written in Python on a Jupyter notebook.  If you’re new to ML, or just desire continuity in writing, I recommend browsing in the following order:

I have some write ups about other projects as well, including my experiments with Fiverr.com, some Ruby on Rails apps I’ve built, and other interesting

If you see anything blatantly incorrect or something I should improve, please do drop a line! I’m a new student to the game and looking for as much help as possible.