Skip to content

Instantly share code, notes, and snippets.

# pryrc helper for http
def http_get(url)
Net::HTTP.get URI.parse(url)
end
def http_headers(url)
uri = URI.parse(url)
Net::HTTP.get_response(uri).each_header {|x| x}
end
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
#! /usr/bin/env python
from boto.ses.connection import SESConnection
import os
import sys
import subprocess
import socket
TMPFILE = '/var/run/postgresql/last-wal-archive-error-file.tmp'
if __name__ == '__main__':
@sujithrs
sujithrs / events.js
Last active August 29, 2015 14:27 — forked from findjashua/events.js
Get streams for interaction & mutation events
import {Observable} from 'rx';
import {DOM} from 'rx-dom';
import {toArray, getNodesFromSelector} from './utils';
let interactions_ = {
'click': Observable.fromEvent(document.body, 'click')
}
let mutations_ = DOM
@sujithrs
sujithrs / node-and-npm-in-30-seconds.sh
Created November 28, 2011 17:44 — 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
@sujithrs
sujithrs / app.rb
Created March 24, 2012 03:22 — forked from cpatni/app.rb
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@sujithrs
sujithrs / gist:3098028
Created July 12, 2012 13:14 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
#! /usr/bin/env python
import fileinput
import argparse
from operator import itemgetter
parser = argparse.ArgumentParser()
parser.add_argument('--target-mb', action = 'store', dest = 'target_mb', default = 61000, type = int)
parser.add_argument('vmtouch_output_file', action = 'store', nargs = '+')
args = parser.parse_args()
@sujithrs
sujithrs / How_to_use.html
Created October 13, 2015 16:55 — forked from jcgregorio/How_to_use.html
HTML Templating using the HTML <template> element and exactly 100 lines of JS.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="templating.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<template id=t>
#!/bin/bash
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# Forked from: http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Ubuntu 11.10 Oneiric Ocelot
# Forked from https://gist.github.com/1287170
# Modified to use NGinx + uwsgi instead of Apache, as well as memcached and supervisord, incorporating ideas from
# http://blog.adku.com/2011/10/scalable-realtime-stats-with-graphite.html