Skip to content

Instantly share code, notes, and snippets.

View reddragon's full-sized avatar
🤖
Too much to do, too little time.

Gaurav Menghani reddragon

🤖
Too much to do, too little time.
View GitHub Profile
[gauravm@dev675 ~] cowsay I\'m the cache cow
___________________
< I'm the cache cow >
-------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
@reddragon
reddragon / get_data.py
Last active February 20, 2017 09:53
Getting Lat/Long Coordinates of my Twitter friends' locations
import urllib
import simplejson as json
def get_followers_url(handle):
return 'https://api.twitter.com/1/followers/ids.json?cursor=-1&screen_name=' + handle
def get_followers(handle):
return json.load(urllib.urlopen(get_followers_url(handle)))['ids']
def get_friends_url(handle):
@reddragon
reddragon / index.html
Last active December 11, 2015 15:48
Putting my Twitter Friends on the Map - II
var countries_data = {"type":"FeatureCollection","features":[
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[74.92,37.24],[74.57,37.03],[72.56,36.82],[71.24,36.13],[71.65,35.42],[71.08,34.06],[69.91,34.04],[70.33,33.33],[69.51,33.03],[69.33,31.94],[66.72,31.21],[66.26,29.85],[62.48,29.41],[60.87,29.86],[61.85,31.02],[60.84,31.5],[60.58,33.07],[60.94,33.52],[60.51,34.14],[61.28,35.61],[62.72,35.25],[63.12,35.86],[64.5,36.28],[64.8,37.12],[66.54,37.37],[67.78,37.19],[69.32,37.12],[70.97,38.47],[71.59,37.9],[71.68,36.68],[73.31,37.46],[74.92,37.24]]]]},"properties":{"name":"Afghanistan"},"id":"AF"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[19.44,41.02],[19.37,41.85],[19.65,42.62],[20.07,42.56],[20.59,41.88],[20.82,40.91],[20.98,40.86],[20.01,39.69],[19.29,40.42],[19.44,41.02]]]]},"properties":{"name":"Albania"},"id":"AL"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[2.96,36.8],[8.62,36.94],[8.18,36.52],[8.25,34.64],[7.49,33.89],[9.06,3
@reddragon
reddragon / gist:4161673
Created November 28, 2012 14:34
Reading List
Now Reading
-----------
The Google File System
(http://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/en/us/archive/gfs-sosp2003.pdf)
[November 28, 2012]
Next Up
-------
Big Table
Dremel
@reddragon
reddragon / gist:4142492
Created November 25, 2012 05:25
Output of 'strace ls'
execve("/bin/ls", ["ls"], [/* 18 vars */]) = 0
brk(0) = 0x916c000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7711000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=65263, ...}) = 0
mmap2(NULL, 65263, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7701000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
@reddragon
reddragon / get_data.py
Created August 20, 2012 04:08
Get Lat/Long coords of my Twitter Friends and Followers
import urllib
import simplejson as json
def get_followers_url(handle):
return 'https://api.twitter.com/1/followers/ids.json?cursor=-1&screen_name=' + handle
def get_followers(handle):
return json.load(urllib.urlopen(get_followers_url(handle)))['ids']
def get_friends_url(handle):
@reddragon
reddragon / logs.sh
Created March 6, 2012 06:41
Use it for finding the total CPU time taken by tasks on Hadoop, after making the change.
#!/bin/bash
LOGS_PATH="logs/userlogs/"
declare JOB=`ls $LOGS_PATH`;
JOB_PATH="$LOGS_PATH$JOB";
COMMAND="ls -1 --hide=job* $JOB_PATH/";
declare RET=`$COMMAND`;
`rm cputime.out`;
`touch cputime.out`;
for TASK in $RET
do
%{
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
extern "C" int yylex();
extern "C" int yyparse();
extern "C" FILE *yyin;
@reddragon
reddragon / Palindrome.java
Created January 29, 2012 01:24
Finding the number of palindromes in a text corpus using Hadoop
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
@reddragon
reddragon / Wordcount.java
Created January 29, 2012 01:22
Hadoop Word Count Example
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;