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
require 'active_model' | |
module Ohm | |
module ActiveModelCompliant | |
def self.included(base) | |
base.send(:extend, ActiveModel::Naming) | |
base.send(:include, ActiveModel::Conversion) | |
base.send(:include, InstanceMethods) | |
end |
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
# Don't use this in a real project never!!! | |
class SingletonFoo < Object | |
def self.new(*args) | |
first_instance = ObjectSpace.each_object(self).first | |
return first_instance if first_instance | |
object = allocate | |
object.send(:initialize, *args) | |
object | |
end | |
end |
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
1) Failure: | |
test_using_hash_resource(RespondWithControllerTest) | |
[/Users/guille/code/rails/actionpack/test/controller/mime_responds_test.rb:659:in `test_using_hash_resource' | |
/Users/guille/code/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `run' | |
/Users/guille/code/rails/activesupport/lib/active_support/callbacks.rb:426:in `_run_setup_callbacks' | |
/Users/guille/code/rails/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks' | |
/Users/guille/code/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:65:in `run' | |
kernel/bootstrap/array.rb:66:in `each' | |
kernel/bootstrap/array.rb:66:in `each']: | |
<"{\"result\":{\"name\":\"david\",\"id\":13}}"> expected but was |
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
object HighFunction { | |
def foo(num : Int)(f : Int => Int) = f(num) | |
} |
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
#include <stdio.h> | |
#include <ruby.h> | |
int main(int argc, char *argv[]) { | |
// Open file | |
FILE *fp; | |
fp = fopen(argv[1], "r"); | |
if(fp == NULL) { | |
return 1; |
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
require 'rubygems' | |
require 'java' | |
require 'mvn:org.clojure:clojure' | |
require 'mvn:org.clojure:clojure-contrib' | |
require 'clojure-jsr223' | |
java_import 'javax.script.ScriptEngineManager' | |
factory = ScriptEngineManager.new | |
engine = factory.get_engine_by_name 'Clojure' |
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
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/ | |
1.) Open any application | |
2.) Press and hold the power button until the slide to shutdown swipe bar appears. | |
3.) Release Power button | |
4.) Press and hold Home button Lightly | |
until screen returns to icon screen |
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
source :gemcutter | |
gem 'goliath', :git => 'git://github.com/postrank-labs/goliath.git' | |
gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git' |
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
desc "Compile all the assets named in config.assets.precompile" | |
task :precompile do | |
# We need to do this dance because RAILS_GROUPS is used | |
# too early in the boot process and changing here is already too late. | |
if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty? | |
ENV["RAILS_GROUPS"] ||= "assets" | |
ENV["RAILS_ENV"] ||= "production" | |
Kernel.exec $0, *ARGV | |
else | |
Rake::Task["environment"].invoke |
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
require 'thread' | |
require 'json' | |
require 'net/http' | |
require 'uri' | |
require 'betabrite' | |
require 'psych' | |
require 'usb' | |
class StreamClient | |
def initialize user, pass |