Skip to content

Instantly share code, notes, and snippets.

To tear down a factory or to revolt against a government or to avoid repair of a motorcycle because it is a system is to attack effects rather than causes; and as long as the attack is upon effects only, no change is possible. The true system, the real system, is our present construction of systematic thought itself, rationality itself, and if a factory is torn down but the rationality which produced it is left standing, then that rationality will simply produce another factory. If a revolution destroys a systematic government, but the systematic patterns of thought that produced that government are left intact, then those patterns will repeat themselves in the succeeding government. There’s so much talk about the system. And so little understanding. ― Robert M. Pirsig

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4HMAJcfOeQkAQFaMI0orbCPpPhm76/3EypNOpoOGXvN7oYJMVrJWdJ+g5zTLsouZA0YJlECTXVi+rDkNxjTCB97doLpYkKPBblsOjde/1XYfguOLtIfjQQ6XxRZSm8j+d75zjYZCW2Xply30f5XCQyVSmU5dZ+w8wtNQkz2hb1ijn2c6EhiiE6bPmGkXn8E+pxZG4b2ZwnN6gV99KcDNNv3PJW/A0Lwwdc6RuEuwS8j6/C52qxN9OahiKsjwyr6SaU07hkqwTlz5CWUaprRv99DDiQjEojw9fFzl/NzOhWhodMZw8hliKjNvwMAn8usmzpavXPjTiIMe56L+OrroBw== sreeix@Sreekanth-Vs-MacBook-Pro.local
@sreeix
sreeix / server.js
Created April 11, 2011 22:42
Posts example using express jade and alfred
var express = require('express'),
http = require('http'),
sys = require('sys'),
fs = require('fs'),
path = require('path'),
alfred = require('alfred');
var app = express.createServer();
app.set('views', __dirname + '/views');
@sreeix
sreeix / simple_em.rb
Created April 20, 2011 11:44
Simple em stuff
require 'fiber'
class SimpleEm
def self.async_fetch(url)
f = Fiber.current
http = EventMachine::HttpRequest.new(url).get :timeout => 10
http.callback { f.resume(http) }
http.errback { f.resume(http) }
@sreeix
sreeix / app.js
Created April 20, 2011 18:58
Node JS. chat client.
var http = require('http'),
express = require("express"),
sys = require("sys"),
io = require('socket.io');
var app = express.createServer();
app.set('view engine', 'jade');
app.get("/", function(req, res){
@sreeix
sreeix / view
Created May 4, 2011 19:40
What's wrong with this couchdb view?
function(doc) {
if(doc.expires && doc.status && (doc.status == 'live' || doc.status == 'active')){
var expiryDate = doc.expires.split(/-/); // date format is dd, mm, yy
var expiresOn = new Date(expiryDate[0], expiryDate[1], expiryDate[2]);
var timeNow = new Date();
log('Now '+ timeNow);
log('Expires '+ expiresOn);
if( timeNow.getTime() >= expiresOn.getTime())
emit(doc.coupon_id, null);
}
@sreeix
sreeix / caching_helper.rb
Created May 9, 2011 08:11
Around wrapper to do simple memcached peruser
module CachingHelper
def self.included(claz)
claz.extend ClassMethods
end
module ClassMethods
def sf_cache(wrapped_method)
send(:around_filter, :cache_result)
end
@sreeix
sreeix / gist:990476
Created May 25, 2011 06:52
My local machine ssh key. gaddafi.local
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlVGztIM7TTYcmX36qwYSM9wvEutM10J5o6LIog4h9s0QeghBqzAgGL+mHopdE2xqIMJnmchTwiEn4I+8EJQBbY8T3eeQBMzOhuCMwupnidLgUJiDROB+PN8xNv/CDEFOnRmaYJEne2WpFWdzaiWGpoBSeJAtOBiu2XvmRncU4z9GrP22GAyQqIsT+S+54Mg2i5hcdAR4Qjx8aTBHv9Gj9+o2fCgVSQ4F1oHLlf8mJqmJ0jC+7DGjBnIw6NFU3IDX9bOfTTCIK+cWiv2hvs6Jx8K/7D48lydHlYvgPMmjpZKY1VusyaBN2b1dYybIVzisZAwD8YW5yfGL5wl/Q8PleQ== sreeix@gaddafi.local
@sreeix
sreeix / redis_subscribe.rb
Created May 31, 2011 13:54
Subscription for the users timeline fetch
require 'json'
redis = Redis.new
redis.subscribe(:vsagarv_channel) do |on|
on.subscribe do |channel, subscriptions|
puts "Subscribed to ##{channel} (#{subscriptions} subscriptions)"
end
on.message do |channel, message|
@sreeix
sreeix / gist:1047810
Created June 26, 2011 18:06
View to check overlap
function(doc) {
if (doc.type && doc.type === 'commission' && doc.affiliate_network && doc.begins && doc.ends) {
var current = doc.begins.split(/-/);
var ends = doc.ends.split(/-/);
var current_date = new Date(parseInt(current[0], 10), parseInt(current[1], 10) - 1, parseInt(current[2], 10) + 1); // javascript month starts at 0
var ends_date = new Date(parseInt(ends[0], 10), parseInt(ends[1], 10) - 1, parseInt(ends[2], 10) + 1); // javascript month starts at 0
while( current_date < ends_date){
emit([doc.network, doc.provider, current_date.getFullYear(), current_date.getMonth()+1, current_date.getDate()], null);
current_date = new Date(current_date.getTime() + 86400000);
}