Skip to content

Instantly share code, notes, and snippets.

@noomerikal
noomerikal / node-and-npm-in-30-seconds.sh
Created July 16, 2011 09:33 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@noomerikal
noomerikal / sinatra_req_headers.rb
Created July 17, 2011 05:46
sinatra request headers helper
require 'rubygems'
require 'sinatra'
helpers do
def request_headers
env.inject({}){|acc, (k,v)| acc[$1.downcase] = v if k =~ /^http_(.*)/i; acc}
end
end
get '/headers' do
@noomerikal
noomerikal / example.html
Created July 19, 2011 17:33 — forked from joelnet/example.html
Unobtrusive Knockout support library for jQuery
Choose a ticket class: <select id="tickets"></select>
<p id="ticketOutput"></p>
<script id="ticketTemplate" type="text/x-jquery-tmpl">
{{if chosenTicket}}
You have chosen <b>${ chosenTicket().name }</b>
($${ chosenTicket().price })
<button data-bind="click: resetTicket">Clear</button>
{{/if}}
@noomerikal
noomerikal / cellcounter.rb
Created July 28, 2011 00:11
CellCounter for HBase Scan with TimeRange
=begin
Usage: /bin/hbase shell cellcounter.rb
=end
import java.text.SimpleDateFormat
import java.text.ParsePosition
import java.util.Date
import org.apache.hadoop.hbase.client.HTable
import org.apache.hadoop.hbase.client.Scan
@noomerikal
noomerikal / rowdeleter.rb
Created August 2, 2011 19:41
RowDeleter for HBase Scan with TimeRange
=begin
Usage: /bin/hbase shell rowdeleter.rb
=end
import java.text.SimpleDateFormat
import java.text.ParsePosition
import java.util.Date
import org.apache.hadoop.hbase.client.Delete
import org.apache.hadoop.hbase.client.HTable
@noomerikal
noomerikal / Makefile
Created August 8, 2011 08:30
JSON to BSON conversion in C
all: json2bson
clean:
rm -f json2bson
json2bson: json2bson.c
${CC} $(shell pkg-config --cflags json libmongo-client glib-2.0) -Wall -O0 -ggdb3 -std=c99 ${CFLAGS} \
$(shell pkg-config --libs json libmongo-client glib-2.0) -o $@ $^
check: all
./json2bson <test.json >test.bson
@noomerikal
noomerikal / index.html
Created September 17, 2011 09:38 — forked from mbostock/.block
HTML Overlay with pageX / pageY
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.27.1"></script>
<style type="text/css">
div.tooltip {
position: absolute;
text-align: center;
width: 60px;
@noomerikal
noomerikal / NokogiriParser
Created December 23, 2011 08:03
mechanize nokogiri pluggable parser
require 'rubygems'
require 'mechanize'
require 'nokogiri'
class NokogiriParser < Mechanize::Page
attr_reader :noko
def initialize uri = nil, response = nil, body = nil, code = nil
@noko = Nokogiri.
super uri, response, body, code
end
@noomerikal
noomerikal / api.rb
Created February 20, 2012 06:55
kodagraph api
require 'sinatra'
require 'mongoid'
require 'json'
require 'jsonp'
require 'rack/throttle'
require 'dalli'
set :cache, Dalli::Client.new("localhost:11211")
set :short_ttl, 400
set :long_ttl, 4600
@noomerikal
noomerikal / area_graph.js
Created February 20, 2012 06:57
D3.js Area Graph script
var area_graph = {
margin: [40, 40, 40, 100],
width: 1160,
height: 460,
div_id: '#areagraph',
json: '',
draw: function() {
var computed_height = this.height - this.margin[1] - this.margin[3];
var computed_width = this.width - this.margin[0] - this.margin[2];