Skip to content

Instantly share code, notes, and snippets.

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
function city_map() {
emit({state:this.state, city:this.city}, {zips:1, pop:this.pop});
}
function city_reduce(key, values) {
out = {zips:0, pop:0};
values.forEach(function (val) {
out.zips += val.zips;
out.pop += val.pop;
});
source 'http://rubygems.org'
#gem 'rails', '3.0.0.beta3'
# Bundle edge Rails instead:
gem 'rails', :git => 'git://github.com/rails/rails.git', :branch => 'master'
# Use unicorn as the web server
# gem 'unicorn'
-module(base36).
-export([encode/1]).
encode(Input)->
encode(Input, "").
encode(Input, Encoded) ->
if Input > 36 ->
E = lookup(Input rem 36),
encode(Input div 36,[E|Encoded]);
@Sedward
Sedward / twitter_fetcher.rb
Created January 17, 2011 22:54
consumer streaming tweets and stuff them into indextank
class TwitterFetcher
def perform
api = IndexTank::Client.new(ENV['INDEXTANK_API_URL'] || index_tank_url)
index = api.indexes 'idx'
streaming_url = 'http://stream.twitter.com/1/statuses/sample.json'
EventMachine.run do
http = EventMachine::HttpRequest.new(streaming_url).get :head => { 'Authorization' => [ TWITTER_USERNAME, TWITTER_PASSWORD ] }
@Sedward
Sedward / gist:886096
Created March 24, 2011 23:26
unset a key in mongodb
db.tweets.update({}, {'$unset' : {'reply_count' :1}}, false, true)
@Sedward
Sedward / application_controller.rb
Created August 17, 2011 16:48
example of ActiveRecord 404 in ApplicationController
class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
private
def record_not_found
render :text => "404 Not Found", :status => 404
end
end
@Sedward
Sedward / test_one.rb
Created November 2, 2011 16:40
CoTweet Refactor Challenge One
class TestOne
def initialize(logger)
@logger = logger
end
def load_doc
begin
@logger.debug('Starting Document load')
@doc = Document.load('resume.txt')
require 'rspec'
require 'koala'
describe "new stuff" do
before do
@graph = Koala::Facebook::API.new("AAACNTDIeX5MBAEZCdoXPE7nsltT3tVuqiCassXFqRzU2uBb1hTdZBtT3kq2YNcsnJOlsZAqRpmi8wZDZD")
end
describe "hiding page posts" do
@Sedward
Sedward / gist:2246055
Created March 30, 2012 02:52
get milestones
#first instantiate the graph api with our access token
@graph = Koala::Facebook::API.new("ACFTHNIWeX5MBAEZCdoXPE7nsltT3tVuqiVoKCIO0CassXFqRzU2uBb1htT3kq2YNcsnJOlsZAqRpmi8wZDZD")
#retrieve a page's milestones
milestones = @graph.get_connection("256490626309681", "milestones")