Skip to content

Instantly share code, notes, and snippets.

source :rubygems
gem 'sinatra', '1.0'
gem 'oauth2'
gem 'json'
group :development do
gem 'shotgun'
end
# crappy server implementation using technoweenie/oauth2 (server branch)
# http://github.com/technoweenie/oauth2/compare/master...server
#
# ruby oauth2_example.rb -p 4568
# ruby oauth2_example.rb
# open http://localhost:4567/auth/facebook
require 'rubygems'
require 'sinatra'
require 'oauth2/client'
@noomerikal
noomerikal / db.rb
Created February 27, 2011 09:36 — forked from alg/db.rb
namespace :db do
desc 'Seed database from db/seed.sql file instead of the traditional db/seed.rb'
namespace :seed do
config = Rails::Configuration.new.database_configuration[RAILS_ENV]
seed_sql = File.expand_path(File.dirname(__FILE__) + '/../../db/seed.sql')
if !File.exists?(seed_sql)
puts "Missing RAILS_ROOT/db/seed.sql"
require 'terminal-table/import'
class SubsetSumMatrix
class << self
def create_empty_for(array)
matrix = []
header = [nil] + build_header_from(array)
matrix << header
array.each_with_index do |element,i|
row = header.collect{|value| 'F'}
#!/bin/bash -e
# 2010-09-19 Marc Limotte
# Run continuously (every 30 minutes) as a cron.
#
# Looks for directories in HDFS matching a certain pattern and moves them to S3, using Amazon's new
# distcp replacement, S3DistCp.
#
# It creates marker files (_directory_.done and _directory_.processing) at the S3 destination, so
@noomerikal
noomerikal / tired.rb
Created May 17, 2011 07:53 — forked from karmi/tired.rb
Template for generating a no-frills Rails application with support for ElasticSearch full-text search via the Tire gem
# ===================================================================================================================
# Template for generating a no-frills Rails application with support for ElasticSearch full-text search via Tire
# ===================================================================================================================
#
# This file creates a basic, fully working Rails application with support for ElasticSearch full-text search
# via the Tire gem [http://github.com/karmi/tire].
#
# You DON'T NEED ELASTICSEARCH INSTALLED, it is installed and launched automatically by this script.
#
# Requirements
@noomerikal
noomerikal / bookmarklet.js
Created June 12, 2011 10:26 — forked from kn0ll/bookmarklet.js
advanced bookmarklet template
javascript:(function() {
if(!window.your_bookmarklet) {
var doc = document,
js = doc.createElement('script');
js.type = 'text/javascript';
js.src = 'loader.js';
js.async = true;
@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 / 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 / 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