Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / rails31init.md
Created May 24, 2011 17:03
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@jraines
jraines / docsplit.md
Created June 9, 2011 22:08
Docsplit notes

Dependencies

  • GraphicsMagick
  • poppler-utils
  • open office -- will this work with Open Office on server?
gem 'docsplit'

Extraction

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 / 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
@jraines
jraines / html5css3.md
Created August 14, 2011 16:44
HTML5 course notes

High Level Tags

Doctype

<!Doctype html>

Links

No longer need type attributes, such as type='text/css'

Header tag

LoadModule proxy_module
LoadModule proxy_balancer_module
<Proxy balancer://mycluster>
BalancerMember http://www.lessonplanet.com/ loadfactor=10
BalancerMember http://beta.lessonplanet.com/ loadfactor=1
ProxySet stickysession=_session_id
</Proxy>
ProxyPass / balancer://mycluster
# Hash for each brand.
# Each key is an item of that brand, in a format like 'id:type:name'.
# Each value is a json string representing an array of user ids.
# For this query we would:
# iterate over each brand
# pull the the keys that match our type ('*jeans*') and
# get the user ids array for each brand of jeans.