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
# From http://nathansjslessons.appspot.com/lesson?id=1080 | |
counter = ( -> | |
count = 0 # cannot be accessed as it's tied to the closure | |
f = -> | |
count += 1 | |
f | |
)() | |
console.log counter() # 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
console.log("%o", window.location); |
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
.wrap-words { | |
word-wrap: break-word; | |
} |
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
# see https://github.com/rails/rails/blob/v2.0.2/railties/builtin/rails_info/rails/info.rb | |
@properties = { | |
:ruby => "#{RUBY_VERSION} (#{RUBY_PLATFORM})", | |
:rubygem => Gem::RubyGemsVersion, | |
:rails => Rails::VERSION::STRING, | |
:app_root => File.expand_path(RAILS_ROOT), | |
:env => RAILS_ENV, | |
:db_adapter => ActiveRecord::Base.configurations[RAILS_ENV]['adapter'], | |
:db_schema_version => (ActiveRecord::Migrator.current_version || nil), |
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
# | |
# = Hash Recursive Merge | |
# | |
# Merges a Ruby Hash recursively, Also known as deep merge. | |
# Recursive version of Hash#merge and Hash#merge!. | |
# | |
# Category:: Ruby | |
# Package:: Hash | |
# Author:: Simone Carletti <weppos@weppos.net> | |
# Copyright:: 2007-2008 The Authors |
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
ruby-1.8.7-p302 > tree_printer.call tree | |
Exception | |
IRB::Abort | |
NoMemoryError | |
ScriptError | |
LoadError | |
NotImplementedError | |
SyntaxError | |
SignalException | |
Interrupt |
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
ArgumentError in 'Fog::Vcloud power_on with a vapp uri that doesn't exist should == {:type=>"application/vnd.vmware.vcloud.org+xml", :name=>"Boom Inc.", :href=>"https://fakey.com/api/v0.8/MockOrganization/2174953160"}' | |
Unrecognized arguments: username, module, password, versions_uri | |
/Users/arnab/code/github/fog/lib/fog/core/service.rb:141:in `validate_arguments' | |
/Users/arnab/code/github/fog/lib/fog/core/service.rb:43:in `new' | |
/Users/arnab/code/github/fog/spec/vcloud/terremark/ecloud/requests/../../../spec_helper.rb:276: |
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
import java.io.Console; | |
public class NumberGuess { | |
private int small; | |
private int big; | |
private int guess; | |
private void guess(){ | |
this.guess = nextGuess(); | |
String verdict = System.console().readLine(guess + ": smaller/bigger/start-over? "); |
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 "fog" | |
CREDS_FILE = 'Somewhere' | |
DOMAIN = 'Dogs' | |
ATTRIBS_TO_CHANGE = { | |
'color' => 'white' | |
} | |
OPTIONS = { | |
:replace => ['color'], | |
:expect => { |
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 "pp" | |
class String | |
def all_substrings | |
substrs = [] | |
start_index, end_index = [0, self.length - 1] | |
start_index.upto end_index do |i| | |
i.upto end_index do |j| | |
# puts "#{self}[#{i}, #{j}] => #{ss}" | |
substrs << self[i..j] |