This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/auth/twitter' do | |
oauth = OAuth::Consumer.new(Settings::TWITTER_OAUTH_CONSUMER_KEY, | |
Settings::TWITTER_OAUTH_CONSUMER_SECRET, | |
{ :site => "http://twitter.com" }) | |
request_token = oauth.get_request_token(:oauth_callback => full_uri('/auth/twitter/callback')) | |
session[:oauth_twitter_reqtoken] = request_token.token | |
session[:oauth_twitter_reqtoken_secret] = request_token.secret | |
redirect request_token.authorize_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib/action_controller/dispatcher.rb | |
dispatch method | |
calls handle_request | |
calls Routing::Routes#recognize(request) to figure out the correct 'controller' | |
once the controller has been identified, calls controller.process | |
if an exception gets thrown, do failsafe_rescue(exception) | |
failsafe_rescue | |
calls ApplicationController or ActionController::Base's process_with_exception (for Base, it's defined in rescue.rb) | |
lib/action_controller/rescue.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def foo | |
puts "fofo" | |
end | |
end | |
# Module#instance_method | |
# => returns an UnboundMethod object | |
unbound_foo = Foo.instance_method(:foo) | |
p unbound_foo # => #<UnboundMethod: Foo#foo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTRUCTIONS FOR GETTING MEMPROF WORKING ON SNOW LEOPARD | |
We'll compile and install a different version of ruby and ruby-gems alongside the default versions that ship with Snow Leopard. | |
Compile and install ruby | |
Get ruby-1.8.7-p299.tar.gz (or the latest version) & untar it somewhere | |
./configure --prefix=/path/to/ruby/directory/you/want \ | |
--with-readline-dir=/opt/local \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
LOCAL=$1 | |
REMOTE=$2 | |
BASE=$3 | |
araxiscompare -nowait -2 "$LOCAL" "$REMOTE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Parser { | |
public static <T> Map<String, T> getMapFromKeyValuePairs(String str, Convertor<T> convertor) { | |
Map<String, T> map = new HashMap<String, T>(); | |
String[] symbols = str.split(","); | |
if (symbols.length > 0) { | |
for (String symbol : symbols) { | |
String[] tuple = symbol.split(":"); | |
if (tuple.length == 2) { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Emulating Ruby-style code blocks in Python. | |
This example was demonstrated in the PyCon'10 talk titled "Python Metaprogramming". | |
""" | |
import sys | |
import types | |
def receive_block(func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Setting up Eclipse for Hadoop Dev | |
* Create a new Java project from existing source (point to the top-level folder which has src/ folder inside). | |
* Turn off build-automatically from “Projects” menu. | |
* Right-click build.xml, choose "Run as > Ant build..."; Choose “compile, eclipse-files” targets. | |
* Build once. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple python program demonstrating how certain blocking syscalls can be offloaded to a thread-pool and | |
then be able to fetch the results from these system calls in a non-blocking way by doing select() on | |
a pipe between the main thread and the threads in the pool. | |
This is the technique being used by node.js to offer a unified non-blocking Javascript API even for | |
things like file I/O which is traditionally done via blocking syscalls. This idea was described by | |
Ryan Dahl at JSConfEU 2009. | |
-- Harish Mallipeddi - Dec 3 2009 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Tumblore - Tumblr blog backup tool | |
;; | |
;; Harish Mallipeddi | |
;; Dec 1 2009 | |
(ns in.poundbang.tumblore | |
(:use [clojure.http.client :only [request]] | |
[clojure.contrib.duck-streams :only [spit]]) | |
(:import (java.io ByteArrayInputStream))) |