Skip to content

Instantly share code, notes, and snippets.

Rajiv Bakulesh Shah brainix

Block or report user

Report or block brainix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
#!/usr/bin/env python3
import sys
# Map the uppercase letters forwards:
'Q': 'P',
'W': 'O',
brainix / rss.xml
Created Jun 23, 2016
iTunes top songs
View rss.xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:im="" xmlns="" xml:lang="en">
<id></id><title>iTunes Store: Top Music Videos</title><updated>2016-06-22T20:09:58-07:00</updated><link rel="alternate" type="text/html" href=";id=1&amp;popId=5"/><link rel="self" href=""/><icon></icon><author><name>iTunes Store</name><uri></uri></author><rights>Copyright 2008 Apple Inc.</rights>
<id im:id="1125405366"></id>
class NetworkElementError(Exception):
class NetworkElement(object):
from nettools import NetworkElement
with NetworkElement('') as ne:
for route in ne.routing_table:
print '%15s -> %s' % (, route.ipaddr)
# XXX -- Top level review comments:
# * Nice exception recovery and logging.
# * Please cleanup code formatting.
# This is a little rough on my eyes.
# * Should we use this as template for other
# short network element scripts?
brainix /
Last active Aug 29, 2015
The Public REST API


Overview is a music video preview website. We aggregate a lot of data about songs, artists, and music genres. If you build anything with our API, we’d love to hear about it! Or if you need some help, please contact us: Happy hacking!


We identify songs, artists, and genres by paths. Paths are lowercased, hyphenated, unique identifiers that correspond to the names of songs, artists, and genres. If you’d like to query for a song, artist, or genre and you don’t know its path, your best bet is to use our search API endpoint. In the search result, you’ll find the song path as path, the artist path as artist_path, and the genre path as genre_path.

Metrics (popularity and freshness)

We score each music video preview according to how popular it is cumulatively (popularity), and how trending it is today (freshness). Lastly, we normalize these scores

brainix /
Last active Jan 3, 2016
Install the do_postgres gem with
gem install do_postgres -- \
--with-pgsql-server-dir=/Applications/ \
View nginx.conf
# /etc/nginx/nginx.conf
# For more information on configuration, see:
# * Official English Documentation:
# * Official Russian Documentation:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
brainix / bidder.conf
Last active Dec 16, 2015
RTB bidder Nginx config
View bidder.conf
# /etc/nginx/conf.d/bidder.conf
upstream unicorn {
server unix:/srv/bidder/shared/unicorn.sock fail_timeout=0;
server {
listen 80 default deferred;
brainix / deprecated.rb
Created Feb 27, 2013
Deprecate routes (URLs) in Sinatra
View deprecated.rb
['/old', '/old2'].each do |path|
get path do
# Deprecated: Please call `/new` instead.
warn "[DEPRECATION] `#{path}` is deprecated. Please call `/new` instead."
url = '/new'
url += "?#{request.query_string}" unless request.query_string.empty?
redirect to(url), 301
You can’t perform that action at this time.