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
View encrypt.py
#!/usr/bin/env python3
import sys
# Map the uppercase letters forwards:
_MAPPING = {
'Q': 'P',
'W': 'O',
@brainix
brainix / rss.xml
Created Jun 23, 2016
iTunes top songs
View rss.xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:im="http://itunes.apple.com/rss" xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<id>https://itunes.apple.com/us/rss/topmusicvideos/limit=200/explicit=true/xml</id><title>iTunes Store: Top Music Videos</title><updated>2016-06-22T20:09:58-07:00</updated><link rel="alternate" type="text/html" href="https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?cc=us&amp;id=1&amp;popId=5"/><link rel="self" href="https://itunes.apple.com/us/rss/topmusicvideos/limit=200/explicit=true/xml"/><icon>http://itunes.apple.com/favicon.ico</icon><author><name>iTunes Store</name><uri>http://www.apple.com/itunes/</uri></author><rights>Copyright 2008 Apple Inc.</rights>
<entry>
<updated>2016-06-22T20:09:58-07:00</updated>
<id im:id="1125405366">https://itunes.apple.com/us/music-video/this-is-what-you-came-for/id1125405366?uo=2</id>
View nettools.py
import jnettool.tools.Routing
import jnettool.tools.elements.NetworkElement
class NetworkElementError(Exception):
pass
class NetworkElement(object):
View p_vs_np_2.py
from nettools import NetworkElement
with NetworkElement('171.0.2.45') as ne:
for route in ne.routing_table:
print '%15s -> %s' % (route.name, route.ipaddr)
View p_vs_np_1.py
# 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
brainix / spool.tv-api.md
Last active Aug 29, 2015
The spool.tv Public REST API
View spool.tv-api.md

Public REST API

Overview

spool.tv 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: spool@74inc.com Happy hacking!

Paths

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
brainix / install_do_postgres.sh
Last active Jan 3, 2016
Install the do_postgres gem with Postgres.app
View install_do_postgres.sh
gem install do_postgres -- \
--with-pgsql-server-dir=/Applications/Postgres.app/Contents/Versions/9.3 \
--with-pgsql-server-include=/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/server
View nginx.conf
# /etc/nginx/nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
@brainix
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
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
end
end
You can’t perform that action at this time.