Skip to content

Instantly share code, notes, and snippets.

@jraines
jraines / life.coffee
Created August 11, 2011 16:44
Conway's game of life for iPad
win = Ti.UI.createWindow()
wrapNorth = (y) ->
if y is 0
36
else
y - 1
wrapSouth = (y) ->
if y is 36

fixture_file_upload is a good way to simulate an uploaded file in tests. In Rspec, make sure to include ActionDispatch::TestSupport

Useful Rspec custom matcher to write: with_layout(layout)

assign(:variable, 'value') in your specs

Anonymous controllers in tests for testing filters

Testing nested hashes

@jraines
jraines / richapps.md
Created May 19, 2011 15:19
Building Rich Apps - RailsConf 11 notes

###If I'm just sending JSON back and forth, why do I need Rails?

Rails is a rich HTTP abstraction, handles a lot for you

Read the HTTP spec

##ActionDispatch

###Middleware

@jraines
jraines / em-intro.md
Created May 19, 2011 17:43
EventMachine intro

Don't block the reactor loop

Use blocks as callbacks

Use async libraries

EM.start_server('0.0.0.0', 1337, ChatClient)

Instance variables keep state on a per Connection basis

@jraines
jraines / worker-pattern.md
Created May 18, 2011 20:32
Horizontal scaling with the Worker pattern

Note - reference these slides; good diagrams

##High traffic

Problem: Heavy lifting inside the request cycle

  • Bound by slowest API
  • Potential redundant retrieval (popular search term)

The Worker Pattern decouples web request from services required to respond to request

@jraines
jraines / bundler-deploy.md
Created May 18, 2011 19:19
Deploying with bundler - RailsConf 11 notes

####Scope your gems to your app:

bundle install --path vendor/bundle

####Ensure that bundle install has been run locally

(ie, there are no gems in Gemfile that do not match the lockfile

bundle install --frozen

@jraines
jraines / searchbox.md
Created May 18, 2011 15:48
Notes on "Enhanching the Search Box" - RailsConf 2011

###Autocomplete

  • the big lebowski
  • Prefix search
  • rails-3-jquery-autocomplete Gem
    • rails g autocomplete
    • javascript_include_tag "autocomplete-rails.js"
    • autocomplete :resource, :title #, :full => true
    • autocomplete_field_tag
  • Not really flexible over multiple models
@jraines
jraines / eventmachine.md
Created May 18, 2011 18:52
EventMachine Railsconf notes

Implementation of the Reactor pattern

  • Most web apps are I/O bound, not CPU bound
  • Instead of waiting on a response from the network, use that time to process other requests
  • Handle 5-10k concurrent connections with a single Ruby process
EM.run do 
  EM.start_server '0.0.0.0', 2202, EchoServer
end
@jraines
jraines / SASS-notes.md
Created May 18, 2011 15:18
Notes on SASS presentation - RailsConf 2011

Use this format to assign variables:

$error-red: #911

Transformations:

background-color: lighten(red, 10%)

Functions:

@jraines
jraines / deployment.md
Created May 17, 2011 21:06
21 Deployment Tips in 50 minutes

Vagrant

gem install vagrant

vagrant up

vagrant halt

  • Ruby DSL for provisioning VirtualBox VMs
  • creates a user named vagrant, with password 'vagrant'