Posts Tagged ‘railsconf’

RailsConf – Day 3 – Lightning talks

June 9th, 2010 by Brian | No Comments | Filed in work

Brian C – DNC

http://github/dnclabs

- client_side_validations – gem that does client side validation for rails
- takes AR validations – serves them via json – used by jquery.validate

how to kill rails
github.com/michel
bad practices by a few rails developers
Don’t reduce yourself to $20/hr, stick to your price, delivery quality
Communication is important!

Democracy.com
Raimond Garcia
Revolutionize Democracy
Parsed Congress web page – created a prototype on heroku in 48 hours
legal palitical party in spain – “partido de internet”

What’s new in RSpec-2
David Chelimsky
in beta right now
Old rspec won’t work with Rails 3
doesn’t work with rails < 3 (yet)

http://github.com/rspec

$rspec spec
modularized, rspec-core is built on micronaut

(more…)

Tags: ,

RailsConf – Day 3 – Persistence Smoothie

June 9th, 2010 by Brian | No Comments | Filed in work

Persistence Smoothie – Blending SQL & NoSQLFlip Sasser (Intridea, Inc.)
@flipsasser

http://github.com/flipsasser/Persistence-Smoothie

NoSQL means no ACID
Keep what you know – don’t throw out your MySQL

DataMapper is the swiss army knife of ORM
- can point different models to different datastores
- Have a lot of refactoring to do

Sample Store App
- Authentication – keep in Reational DB
- Products – store metadata
- Purchases – keep it in RDB
- Activity Stream – denormalize with key/value store

mongofy – gem for moving data from mysql to mongo

Drawbacks
- DataPortability is lowered
- Lot more moving parts
- Say goodbye to all your fun AR mixins

Tags: , , ,

RailsConf – Day 3 – Introduction to Cassandra and CassandraObject

June 9th, 2010 by Brian | No Comments | Filed in work

Introduction to Cassandra and CassandraObjectMichael Koziarski (Koziarski Software Limited)

Scales linearly – increases not only read access, but also write access

A ColumnFamily per query

CassandraObject
- Mostly AR compatible
- In flux
- taking patches

Tags: , ,

RailsConf – Day 3 – Redis, Rails and Resque

June 9th, 2010 by Brian | 1 Comment | Filed in work

Redis, Rails, and Resque – Background Job BlissChris Wanstrath (GitHub)
redis is a key value store for data structures

redis is not use for everything because entire dataset used to have to fit into RAM – would have to shard across machines

github – uses redis for routing, can add, remove.modify routes quickly & easily – can determine what server to put new users on, etc

Old – HAProxy sending to mongrels
New – Unicorn – instead of receiving requests, it asks for one using ‘select’, pooled, forks similar to passenger

Used 6 or 7 different bg – SQS, DelayedJob
Used Delayed job for 2 years

resque is built on redis, jobs are serialized to json and workers can be in any language http://github.com/defunkt/resque

resque has a plugin API – 15 or so plugins already exist – http://wiki.github.com/defunkt/resque/plugins

has admin interface

github has 35 types of background jobs

Notes: lightning fast talker! Lots of good information though. I’d have a beer with this guy!

Tags: , ,

RailsConf – Day 3 – Million Dollar Mongo

June 9th, 2010 by Brian | No Comments | Filed in work

Million Dollar Mongo - Obie Fernandez (Hashrocket), Durran Jordan (Hashrocket)
mongo was a good choice because only one patient record was worked on at a time

get entire object graph in a single query
previously did 35 joins and took 20 minutes to return

comparison between mongo, couch & cassandra
big selling point was dynamic queries – nice happy medium when coming from relational databases
“I don’t want to write any more ****** XML, so goodbye Cassandra”

No universal agreement that a NOSQL solution was the right idea

“Easiest database to install ever (except maybe Redis)”
No schema migrations

Forked MongoMapper -> Monoid
- MongoMapper was very young

Mongoid
- Prefers Embedding Documents
- Atomic Operations by Default, based on attribute changes
- rich criteria api
- master/slave suppor
- simple versioning
- is NOT ActiveRecord (and should be treated as such)
- Features always have performance in mind

mongo – can index in background as of 1.4
regex queries on fields
Denormalization is acceptable, embed as much as possible (no FK constraints)

Hybrid DB model
- Hierarchical Data Stored in MongoDB
- Relational Data stored in MySQL
- Data that required transactions stored in MySQL
- Simple Data in Redis
- Favor suitability over simplicity

It’s ok to use more than one datastore

Working without transactions
- Atomic updates generally cover you
- fairly easy to roll your own optimistic locking
- need to do manual rollback in integration tests
- selenium tests can run in a separate process

in production
- deployed on engine yard cloud / ec2
- 0.5 TB of data
- put mongodb on it’s own utility space
- feed it lots of ram, lots of disk space
- chef scripts easy due to simple installation

Tags: ,

RailsConf – Day 2 – MongoDB Metamorphosis

June 8th, 2010 by Brian | 1 Comment | Filed in work

The MongoDB Metamorphosis: Data as DocumentsKyle Banker (10gen)

http://try.mongodb.com – mini tutorial

MongoDB tries to fit between key-value stores & relational databases

Data as Documents – documents are in BSON (binary json)

mongoDB operates on documents using special syntax

update() takes a query and an update (what to do) .. the update is applied to the results of the query

Embedded documents – i.e. Comments become embedded within Posts
Or you can normalize – Post id within each comment
Decisions to be made on what makes most sense for how you need to access the data

Embedded – fast queries, document always appears with parent

Hash is the object used to represent MongoDB objects

MongoMapper

Very informational, I want to try using this!

Tags: ,

RailsConf – Day 2 – Beyond git push heroku

June 8th, 2010 by Brian | No Comments | Filed in work

Beyond Git Push Heroku: Battle Stories from Cloud SamuraisOren Teich (Heroku), Morten Bagai (Heroku)
heroic had down time this morning, so we’ll talk about that for a bit then resume our normal schedule
use something similar to nagios
problem was occurring somewhere in http stack
form hypothesis & find a way to test it quickly and in a non-disruptive manner – don’t want to make the problem worse
disabled misbehaving systems – took them out of the cluster – didn’t turn off, wanted to diagnose

2 of the 3 cofounders here in room
Do one thing well – deploy a rails application onto the web
$git push heroku master
let developers use tools to deploy that they are already using
“No step 1″

heroku stacks – let’s you target a version of a vm & libraries that you want to target – linux version, ruby, etc

http://docs.heroku.com/rails3

http://www.scvngr.com

http://www.syphir.com

http://getcloudapp.com

pandastream – cloud based video encoding

Anything can be a cloud service as long as it’s deployed in the same infrastructure – memcached, monogohq, etc

Tags: ,

RailsConf – Day 2 – What should we work on next?

June 8th, 2010 by Brian | No Comments | Filed in work

What should we work on next? – Brian Doll (New Relic)

My note: this is probably a sales pitch on RPM, but at least I know that gong in :)

  • Performance is value
  • Apdex – how your customers feel about the service they are getting – how satisfied they are
  • Awesome “Knuth is my homeboy” image with appropriate quote: “premature optimization is the root of all evil”
  • Nice charts to compare metrics vs 24 hours ago, a week ago, a month ago

My note: I was right, and now I am bored…but I am going to go read about solr

Tags:

RailsConf – Day 2 – Metrics Magic

June 8th, 2010 by Brian | No Comments | Filed in work

Metrics Magic - Aaron Bedra (Relevance, Inc.) – maintains rcov

How did we get here?
Technical Debt – but there is no bailout program! Good idea if you intend on paying back.

Metrics are a great way to facilitation conversation
It’s ok to ask others how/why the code was written

if its hard to write tests around your code, that’s a smell

output of metrics tools is just text – you can make these metrics tool fail the build !

There’s no substitute for peer review

rcov can fail the build by setting “–failure-threshold n”
- should increase the threshold as your code coverage goes up so that you know when it drops

reek – fail the build by capturing the output
result = %x{reek app lib}
exit 1 unless result.empty?

flog -
flog app  awk ‘NR==4′ | awk ‘{print $1}’
exit 1 if result.gsub(“:”,”").to_i >= 20

metric-fu
wraps tests in pretty pictures

Compare charts to previous sprints – generate conversation

Great presentation materials – cartoony, fun
Good speaker, useful demo

Tags: ,

RailsConf – Day 2 – Building an API with Rails panel

June 8th, 2010 by Brian | No Comments | Filed in work

Building an API with Rails Panel  – http://en.oreilly.com/rails2010/public/schedule/detail/14502

Panelists: Joe Ferris (thoughtbot, inc), Jeremy Kemper (37signals), Marcel Molina (Twitter), Rick Olson (GitHub), Derek Willis (The New York Times)

Authentication

  • OAuth 1.0 spec is difficult to implement – signature difficulties, etc
  • OAuth 2 uses ssl & tokens – much simpler to implement, has overhead of SSL

Input & Response Formats

  • Hoptoad now only supports XML – because they are write heavy and use streaming they were able to simplify their interface and make it faster by dropping support for other formats
  • NYTimes – XML & JSON, expanded formats based on user needs
  • Twitter – XML, JSON, RSS, Atom – probably going to move towards JSON only to scale up – XML is too verbose – lots of memcache full of XML fragments
  • 37signals – uses RJS

To Version or Not to Version

  • Twitter – hard problem – fork with multiple deploys? Inheritance? – lots of work. What do we need versioning for? Lotsa stuff we thought needed versioning actually didn’t. Looking for tips on how to do easily.
  • 37signals – is it really a problem?  If you think it needs a new versions, just make it a new resource
  • How do you support legacy – 37signals: Given enough lead time application developers can deal with it fairly quickly (1 month).
  • Hoptoad – no matter how many people you tell, they won’t upgrade. You won’t loose as may people as you think. People don’t upgrade until something is broken.
  • Twitter – explosion of resources could be a problem. Implement new option/param/header to allow people to get new functionality during transition period. Look at analytics & how much time has passed then take out conditional and drop previous. “It’s going to break if you don’t upgrade.”
  • NYTimes – “we’re shutting this off in 3 months”

Scaling

  • NYTimes uses mashery and varnish
  • 37signals – reverse proxy caching, usage patterns of API are usually very different than patterns of web traffic
  • Twitter – cache not only fragments, but fragments of fragments – so that the more volatile stuff can expire without losing the more static data. Consider a streaming API instead of having users continuously poll. (mentioned “Cache Money” which I had to google cuz it’s a sweet name: http://github.com/nkallen/cache-money/tree/master)
  • Github – take advantage of HTTP headers & caching

Code Separation

  • Should there be a separation between your web & api code?
  • Github – API code was in same code as controllers – became separate API controller – looking at moving to a Sinatra app
  • Twitter – used to be DRY and works great for most applications. web/mobile/api encapsulated in respond to’s. Different code for rate limits, etc, “became unruly”, merge conflicts when split across teams, etc. Now they duplicate, but it’s not that bad because of skinny controllers & fat models.
  • 37signals – just because twitter does it, doesn’t mean you have to. Much much easier to keep API in same code, should be exception to separate – this is why respond_to exists.

Security Concerns

  • Twitter – “You’re going to get screwed no matter how awesome you are. And it’s a really hard problem.”
  • Github: Don’t use cookies & sessions in your API requests
  • 37signals – don’t worry about authenticating (use oauth) worry about authorization

Developer Communications

  • Twitter – Tools & documentation – Page for “Is there a problem with the system?” – portal for developers
  • Hoptoad – make sure your documentation is correct & up to date!
  • 37signals – Don’t just put up a mailing list.
  • NYTimes – use your own API – build samples & actually use/run them
  • Github – documentation is actually stored in git
  • 37signals – dogfooding

Tags: ,

RailsConf – Day 1 – Mobile App Development with iPhone and Rails

June 7th, 2010 by Brian | No Comments | Filed in work

Mike Clark http://en.oreilly.com/rails2010/public/schedule/detail/14136

This is going to be mostly an iPhone application development session, not Rails.
Demo app is performs CRUD operations on a Rails 3 site from an iPhone app

http://github.com/clarkware/iphone-rails-tutorial

Basic Railsy JSON controller methods

Standard iPhone callback methods: applicationWillTerminate, didFinishLaunchingWithOptions

in .h file – create instance variables in the @interface and add:
@property(nonatomic, retain) NSMutableArray *goals;

in .m use: @synthesize goals (initializes instance variable), also release in dealloc()

viewDidLoad – called when the view is loaded
reference “goals” with “self.goals” to access variable through property

“Do not fear the square brackets”

cellForRowAtIndexPath – don’t delete what’s there (that’s what makes scrolling through large list fast), just add your own logic to the end of the method, before “return cell”;

commitEditingStyle – delete from our array – allows deletion in app. Restart app to get data back (since it’s in memory)

StringWithContentsOfURL – fetch URL synchronously (blocks main UI thread)
json-framework is a strict JSON parser and generator
return NSDictionary or NSArray of NSDictionaries

refreshButton – “action:@selector(refresh)” — is like using “send” in ruby. target:self” means that self.refresh will be called on click

networkActivityIndicatorVisible – network spinner

NSURLRequest, NSURLConnection, sendSynchronousRequest

Shift – Apple – R brings up debug console in Xcode

After break – Asynchronous Networking, Authentication, Error handling ….

Async Networking – done with the Delegate pattern – http://en.wikipedia.org/wiki/Delegation_pattern

Use an OperationQueue to background work – NSOperationQueue, NSInvocationOperation – don’t use NSThread
Always update the UI on the main thread – performSelectorMainThread

HTTPRiot is a simple REST library that makes it easy to interact with RESTful resources (inspired by httparty) – responses converted to NSDictionary and NSArray objects.

http://allseeing-i.com/ASIHTTPRequest/ – flexible, low-level library with tons of features – File uploads, post form-encoded data, basic authentication, progress indictors, etc. Not REST specific, doesn’t handle json/xml by default, but very useful for low-level stuff

ObjectiveResource is an Objective-C port of ActiveResource – Automatically serializes/deserializes objects (to/from JSON or XML) – Assumes Rails RESTful conventions – adds methods to NSObject

didFinishLaunchWithOptions – only gets called once – when app starts up

ObjectiveResource needs the following to give json a default root object:
ActiveRecord::Base.include_root_in_json = true

Tags: ,

RailsConf – Day 1 – Git Immersion

June 7th, 2010 by Brian | No Comments | Filed in work

Jim Weirich – @jimweirich

If for some crazy reason you don’t already have git installed, go download it from here – http://git-scm.com/download

Source Control Made Easy – Pragmatic Bookshelf Screen Cast

git config –global user.name “Brian Olore”
git config –global user.email “brian@olore.net”
git config –global core.autocrlf input

git init – creates a new, empty repository

Git is about changes, not files.

Always additive – Information is never destroyed – makes it really really hard to screw up your repository

SHA1 used for preventing duplication – all files referenced using their hash
- Is there additional meta-data that has things like executable flag, etc ??

Tags point to snapshots & never move

Branches point to snapshots and move with commits
Can branch after committing changes
Cheap, local branches

git clone <url> – make an exact copy of remote working copy
git pull <url> – receive changes from remote url into your working copy

Shared remote archive – allows sharing between many users – like svn, but if remote goes away, can still push/pull between users without the centralized repository

git log –pretty=oneline
5e870f0441fb9a30ad2711e186cb46a1cafd9e30 pulling from command line
63537c6c788c4893cf928509339f84cb9f243c6b First commit

git log –pretty=oneline –abbrev-commit
5e870f0 pulling from command line
63537c6 First commit

git add – adds the changes to be committed, not the file. Can have multiple adds

git diff – compare un-staged (things not yet “add”ed)
git diff –cached – compare staged area (things “add”ed) to “commit”ted

Both gitx (for Macs) and gitk (any platform) are useful in exploring log history.

git reset – changes a branch pointer

git reset –hard – changes the branch pointer and checks out into your working directory.

git rebase master – replays branch changes (rewrites commits) as if they happened on master

DO NOT rebase shared branches – only reset/rebase on local repositories

http:/nvie.com/git-model – “A successful Git branching model”

Tags: ,