Skip to content

Instantly share code, notes, and snippets.

@ngsankha
ngsankha / README.md
Created June 2, 2012 09:08
Creates an archive of tweets as a git repo

This Python script creates a git repo with your tweets. Obviously its limited by Twitter API limitations as you cannot retrieve more than 3200 tweets at a time.

Given the fact that Twitter doesn't give a fuck about our data, you may not find your old tweets ever again. So nothing is better than keeping an archive of tweets as a Git repo.

This is inspired by @holman's tweets repo. But this doesn't have a dependency on Madrox. Just plain Python and Git.

Usage

To create an archive of tweets initiate a git repo in a directory with git init. Then put the script in the directory and execute:

@ngsankha
ngsankha / mozbuild.sh
Created December 15, 2012 11:27
Mozilla build completion notifier. Uses Coocoo - https://github.com/sankha93/coocoo
cd oss/nightly/mozilla-central
./mach build
cd ../../..
python coocoo-notifier.py 127.0.0.1 "buildbot" "mozilla-central build complete"
@ngsankha
ngsankha / fit.R
Last active December 11, 2015 01:18
Computing trends in programming languages
# Read all the collected data
java = read.csv(file = "java.csv", header = F, sep = ",")
javascript = read.csv(file = "javascript.csv", header = F, sep = ",")
python = read.csv(file = "python.csv", header = F, sep = ",")
ruby = read.csv(file = "ruby.csv", header = F, sep = ",")
# Sort the data by watchers/forks to format them
java_sorted = java[order(java$V4),]
javascript_sorted = javascript[order(javascript$V4),]
python_sorted = python[order(python$V4),]
@ngsankha
ngsankha / github-scrape.py
Last active December 11, 2015 01:18
Collect data from Github
import csv, httplib, json
from string import ascii_lowercase
con = httplib.HTTPSConnection('api.github.com')
languages = ['java', 'c', 'ruby', 'python', 'javascript']
for lang in languages:
with open(lang + '.csv', 'wb') as csvfile:
csvwriter = csv.writer(csvfile, delimiter = ',', quotechar='"', quoting = csv.QUOTE_MINIMAL)
for ch in ascii_lowercase:
print("Processing repos with " + ch + " for language " + lang)
@ngsankha
ngsankha / client.js
Created May 25, 2013 19:04
A minimal chat client based on Redis pub/sub
var redis = require('redis'),
util = require('util'),
client1 = redis.createClient(),
client2 = redis.createClient();
channel = 'chatroom';
process.stdin.resume();
client1.on('error', function(err) {
console.log("Error: " + err);

What is it?

A static blogging tool for hackers. You create your posts in a GitHub Gist. Add them to your blog on Grite and it just shows up.

Why?

Other static site generators need you to generate the site, once you change the content. Here you don't need to. You create or update a gist, and you can add posts to your blog, all of it online from GitHub!

This means that you can use all the goodness of Git in your posts, you have revision history, you can fork other posts, etc. You do this all online, without cloning the repository on your machine.

##How to start?

  1. Fork the repository on GitHub.
  2. Create your public gists (aka posts).
  3. Note the gist ID number. It’s usually a longish number like 5711471.
  4. Edit the config.js file on GitHub online to add the post ID.

You can find out the details of changing other settings of your blog on the wiki page.

##Issues

@ngsankha
ngsankha / events.js
Last active December 19, 2015 01:19
Simple event handling mechanism
"use strict";
/* EventEmitter - simple event handling
*
* Use var myObj = Object.create(EventEmitter) to inherit the functions
* Use myObj.on('event', callback) to attach event handlers
* Use emit('event') to trigger the event handlers
*/
var EventEmitter = {
@ngsankha
ngsankha / JSON-RPC.md
Last active December 19, 2015 08:28
Demo JSON-RPC implementation

This is a very simple implementation of the JSON-RPC spec v1 in PHP. Take a look at it at http://json-rpc.org/wiki/specification.

Here what you do from your webapp.

$.post('/rpc.php', {'method': 'echo',
                    'params': ['Hello JSON-RPC'],
                    'id': Math.floor(Math.random()*100)
                   }, function (data) {
                        alert("I received result: " + data.result);
@ngsankha
ngsankha / clone
Last active December 20, 2015 03:39
Clones all your original repositories at once.
#!/usr/bin/python
import sys, httplib, json, subprocess
con = httplib.HTTPSConnection("api.github.com")
def cloneRepos(user):
request = "/users/" + user + "/repos"
con.request("GET", request)
obj = json.load(con.getresponse())
for repo in obj: