Gabe Kopley
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 'benchmark' | |
array = (0..10000000).to_a | |
benchmark = Benchmark.bm(10) do |x| | |
x.report("Ruby 2.0: ") do | |
100000.times { array.bsearch { |e| 7777777 <=> e } } | |
end | |
require 'bsearch' | |
x.report("bsearch gem:") do |
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
gabe2@moth:~/play $ diff rails-standard-app/Gemfile.lock rails-api-app/Gemfile.lock | |
33,39d32 | |
< coffee-rails (3.2.2) | |
< coffee-script (>= 2.2.0) | |
< railties (~> 3.2.0) | |
< coffee-script (2.2.0) | |
< coffee-script-source | |
< execjs | |
< coffee-script-source (1.4.0) | |
41,42d33 |
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 'https://rubygems.org' | |
gem 'rails', '3.2.3' | |
# authentication | |
gem 'devise' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.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
# This simple solution permanently adds a method on Object that | |
# will never be used outside this file. | |
def compile_asset?(path) | |
# ... lots of complicated logic ... | |
# returns boolean | |
end | |
Foo::Application.configure do | |
... |
||
and &&
bind with the precedence that you expect from boolean operators in programming languages (&&
is very strong, ||
is slightly less strong).
and
and or
have lower precedence.
For example, unlike ||
, or
has lower precedence than =
:
> a = false || true
=> true
> a
=> true
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 "https://rubygems.org" | |
# these are the Ruby bindings for the etherpad-lite API | |
gem "etherpad-lite" | |
# leverages unix diff to discover changes to pad content | |
gem "diff-lcs" | |
# boilerplate debugging tool | |
gem "pry" |
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 'etherpad-lite' | |
require 'piggy_latin' | |
require 'pry' | |
require 'pry-nav' | |
ether = EtherpadLite.connect('http://pad.coshx.com', 'KHoaXT0XuEH2lkXkeAmYry4W3k1emR15') | |
pad = ether.pad('noisebridge') | |
i = 0 |
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
$(document).ready -> | |
ws = new WebSocket("ws://localhost:9000/chat") | |
ws.onopen = -> | |
console.log "connected..." | |
ws.onmessage = (event) -> | |
console.log event | |
$("<li>#{event.data}</li>").prependTo("#msg") |
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 'bundler/setup' | |
Bundler.require | |
require 'goliath/websocket' | |
class Chat < Goliath::WebSocket | |
include Goliath::Rack::Templates | |
def on_open(env) | |
env.logger.info("CHAT OPEN") |