Skip to content

Instantly share code, notes, and snippets.

@alanho
alanho / BeatBoxFinal.java
Created October 19, 2012 12:50 — forked from michellesun/BeatBoxFinal.java
Beatbox with GUI and chat function
// make a beatbox
import java.awt.*;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.io.*;
import javax.sound.midi.*;
import java.util.*;
@alanho
alanho / gist:2906165
Created June 10, 2012 15:20
Rails Monkey Patch
ActionDispatch::Callbacks.to_prepare do
# monkey patch here
end
@alanho
alanho / gist:2833791
Created May 30, 2012 04:34
Monkey patch in Rails Initializers example
ActionDispatch::Callbacks.to_prepare do
Devise::Oauth2Providable::Client.class_eval do
attr_accessible :name, :website, :redirect_uri, :development_mode
end
end
@alanho
alanho / gist:1020716
Created June 11, 2011 16:14
call me a geek...
a = "\"\n\nprint \"a = \\\"\"\nprint a.inspect[1..-2]\nprint a\n"
print "a = \""
print a.inspect[1..-2]
print a
module MongoInstrumenter
class LogSubscriber < ActiveSupport::LogSubscriber
def self.runtime=(value)
Thread.current["mongoid_query_runtime"] = value
end
def self.runtime
Thread.current["mongoid_query_runtime"] ||= 0
end
module Mongo
module ControllerRuntime
extend ActiveSupport::Concern
protected
attr_internal :mongo_runtime
def cleanup_view_runtime
#place this inside config/initializers/
require 'oauth/request_proxy/typhoeus_request'
module OAuthFix
def self.included(base)
base.send :include, InstanceMethods
base.module_eval %q{
alias_method :old_post_parameters, :post_parameters