Skip to content

Instantly share code, notes, and snippets.

# The language list was generated using the following lines of Python
from pygments.lexers import get_all_lexers
import json
xs = [ (x[0], i) for i, x, _, _ in get_all_lexers() ]
xs.sort()
f = open('file', 'w')
json.dump(xs, f)
We couldn’t find that file to show.
/*
* Mclarens Bar: Redis based Instant Messaging
* Nikhil Marathe - 22/04/2010
* A simple example of an IM client implemented using
* Redis PUB/SUB commands so that all the communication
* is offloaded to Redis, and the node.js code only
* handles command interpretation,presentation and subscribing.
*
* Requires redis-node-client and a recent version of Redis
@nikhilm
nikhilm / suncirc.cfdg
Created November 22, 2010 13:30
Draws a 'sun', coloured blue using ContextFreeArt
startshape sun
rule sun {
sq { }
36* { r 10 } sq { }
}
rule sq {
CIRCLE { hue 200 saturation 150 }
sq { x 1 y 1 s 0.8 brightness 0.3 }
# Simple script which runs code when a file is modified
#
# You will have to install pyinotify
#
# Run with the directory to watch
# eg. python autobuild.py ./
# currently hardcoded to use
#
# (c) 2009, Nikhil Marathe <nsm.nikhil@gmail.com>
# Licensed under the MIT License
var http = require('http');
http.createServer(function (req, res) {
var result = req.url.match(/^\/user\/([a-z]+)$/);
if( result ) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<html><head><title>Greeting App</title></head><body><h1>Hello '+ result[1] + '!</h1></body></html>');
}
else {
res.writeHead(403);
res.end("You aren't allowed here!");
@nikhilm
nikhilm / 1
Created February 22, 2011 20:40
initial cmake support for HUpnp
#toplevel in herqq/
project(HUpnp)
set(HUpnp_MAJOR_VERSION 0)
set(HUpnp_MINOR_VERSION 9)
set(HUpnp_PATCH_VERSION 0)
find_package(Qt4 COMPONENTS QtCore QtXml QtNetwork REQUIRED)
add_subdirectory(hupnp)
@nikhilm
nikhilm / gist:2145665
Created March 21, 2012 08:49
why java feels enterprisey!
Overcomplicated shit:
mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.mycompany.app \
-DartifactId=my-app
@nikhilm
nikhilm / AllColumnsIterator.java
Created April 1, 2012 03:30
Apache Cassandra: Iterate over all columns of a row in batches of count rows.
// Made by Nikhil Marathe <nsm.nikhil@gmail.com>
// This code is in the public domain.
import java.util.Iterator;
import java.util.List;
import me.prettyprint.hector.api.beans.ColumnSlice;
import me.prettyprint.hector.api.beans.HColumn;
import me.prettyprint.hector.api.exceptions.HectorException;
@nikhilm
nikhilm / jscrush-compress-pseudo.js
Created April 15, 2012 17:00
JSCrush 'reverse engineering'
segmentLengthBound = ... // B, originally set to s.length/2
counter = {} // o
bestSavings = 0 // M
maxRepetitions = 0 // N
bestSegment = 0 // e
longestSegmentLength = 0 // Z
segmentLength = 0 // t
while (segmentLength <= segmentLengthBound) {
start = 1;