Home     RSSRSS

Upgrading to Phonegap 2.0

July 23, 2012 by Brian | 3 Comments | Filed in play

I recently upgraded my ios app to Phonegap 2.0 and found the upgrade instructions a little daunting. In an attempt to make them more approachable & consumable, I’ve annotated many of them below.
Please let me know if I missed anything.
  1. Install Cordova 2.0.0
    1. Download from http://phonegap.com/download
    2. Unzip the file into ~/pg2.0
    3. Double click on the ~/pg2.0/Cordova-2.0.0.pkg to begin the installation
  2. Create a new project from the command-line tools – you will have to grab the assets from this new project
    1. TEMP_PROJ=~/temp_project2.0
      ~/pg2.0/lib/ios/bin/create $TEMP_PROJ com.temp_project2.0 TempProject
  3. Copy the www/cordova-2.0.0.js file from the new project into your www folder, and delete your www/cordova-1.9.0.js file
    1. $EXISTING_1_9_PROJ=~/dev/iphone/myapp/  #Set this to the path of the folder that contains your app’s www folder
      cp $TEMP_PROJ/www/cordova-2.0.0.js $EXISTING_1_9_PROJ/www
  4. Update the Cordova script reference in your www/index.html file (and any other files that contain the script reference) to point to the new cordova-2.0.0.js file
  5. Copy the “cordova” folder from the new project into your project’s root folder (if you want the project command-line tools)
    1. cp -r $TEMP_PROJ/cordova/ $EXISTING_1_9_PROJ/www
  6. Add a new entry under Plugins in your Cordova.plist file (under the Supporting Files group) – the key is Device and the value is CDVDevice
    1. Edit Cordova.plist, to include Device/CDVDevice like so, (or edit the file in Xcode)
      <key>Plugins</key>
      <dict>
      <key>Device</key>
      <string>CDVDevice</string>
      <key>Logger</key>
  7. Remove Cordova.framework
    1. Select Cordova.framework in Xcode then Edit -> Delete, then select Remove Reference
  8. Remove verify.sh from the Supporting Files group
    1. Select verify.sh in Xcode Select in Cordova.framework in Xcode
  9. Select the project icon in the Project Navigator, select your project Target, then select the “Build Settings” tab
  10. Search for “Preprocessor Macros”, then remove all “CORDOVA_FRAMEWORK=1″ values
  11. Locate the CordovaLib folder that was installed in your hard-drive under your home folder’s Documents sub-folder.
  12. Locate the CordovaLib.xcodeproj file in the CordovaLib folder, then drag and drop the file into your project – it should appear as a sub-project.
    1. Drop CordovaLib.xcodeprojon top of your project to include to it in as a sub-project
  13. Build your project, you should get some errors relating to #import directives
  14. For the #import errors, change any quote-based imports in this style:
    #import "CDV.h" 

    to this brackets-based style:

    #import <Cordova/CDV.h> 

    and remove any #ifdef wrappers around any Cordova imports, they are not needed anymore (the imports are unified now)

  15. Build your project again, and it should not have any #import errors.
    1. You will still have build errors, they will get cleaned up shortly
  16. Select the project icon in the Project Navigator, select your project Target, then select the “Build Phases” tab
  17. Expand the “Target Dependencies” phase, then select the “+” button
  18. Select the “CordovaLib” target, then select the “Add” button
  19. Expand the first “Link Binary with Libraries” phase (it should already contain a bunch of frameworks), then select the“+” button
  20. Select the libCordova.a static library, then select the “Add” button
    1. Select libCordova.a from the dialog
    2. When these steps are complete, it should look like the following
  21. Delete the “Run Script” phase.
    1. Click the X to the right of the Run Script section title and confirm deletion
  22. Select the project icon in the Project Navigator, select your project Target, then select the “Build Settings” tab
  23. Search for “Other Linker Flags”, and add the values -all_load and -Obj-C
    1. Modify the flags by clicking the + at the bottom and adding both flags separately
  24. Expand the “CordovaLib” sub-project
  25. Locate the “VERSION” file, drag it into your main project (we want to create a link to it, not a copy)
  26. Select the “Create groups for any added folders” radiobutton, then select the “Finish” button
  27. Select the “VERSION” file that you just dragged in a previous step
  28. Press the key combination Option-Command-1 to show the File Inspector (or menuitem View -> Utilities -> Show FileInspector)
  29. Choose “Relative to CORDOVALIB” in the File Inspector for the drop-down menu for Location
  30. Build your project, it should compile and link with no issues.
  31. Select your project from the Scheme drop-down, and then select “iPhone 5.1 Simulator”
  32. Select the Run button

NOTE 1:
If your project is not working as expected in the Simulator, please take a note of any errors in the console log in Xcode for clues.

NOTE 2:
For the unified #import headers to work, the build products should build into the same build directory. You may need to set the preference “Xcode Preferences -> Locations -> Derived Data -> Advanced…” to “Unique”


Tags: , ,

Installing Postgresql on Mac – again

November 22, 2011 by Brian | No Comments | Filed in work

PostgreSQL

About a year ago I posted about installing Postgres 9.0 on my Mac. We’ll since then I lost a hard drive and am just re-installing Postgres now. This time 9.1. Here’s what I did:

1.  Download postgres for Mac

  • Don’t sign up for enterprise db crap, the download will start in a sec

2. Install postgres

  • This may require reboot to set some syscontrol settings (it did for me)
  • I created the “postgres” user with “postgres” as the password (so I could remember it)

3. Start postgres to create the defaults in the data directory

$ sudo su – postgres
$ . ./pg_env.sh
$ pg_ctl restart

4. Modify Postgres to use “trust” authentication, so we don’t need to supply a password when connecting to the database.

$ vi /Library/PostgreSQL/9.1/data/pg_hba.conf

4.1 For each entry, change METHOD “md5″ to “trust” (this should only be done on your developer machine!)

5. Restart postgres to pick up the conf changes

$ sudo su – postgres
$ . ./pg_env.sh
$ pg_ctl restart

6. Beer time!

 

This setup requires you to su – postgres whenever you want to restart the database, but for now it’ll work.

Tags: , ,

Refinery on Dreamhost

October 4, 2011 by Brian | No Comments | Filed in work

refinery logoLooking around for a Rails based CMS because I am sick of working in PHP (Drupal). RefineryCMS looks like the best of the bunch.

Here are some notes from my installation of it on my Dreamhost account:

1) ssh to your host

2) a simple ‘gem install refinerycms’ just hung & I didn’t feel like waiting around so a quick Google search came up with this answer:

In your tmp directory, create a temporary Gemfile with the following contents:

source ‘http://rubygems.org’
gem ‘refinerycms’

then run ‘bundle’

The bundle command failed for me, even though ‘gem list’ showed it was installed. So I ran ‘gem install bundle –no-rdoc –no-ri’ which installed a newer version & also setup the binary so I could successfully execute ‘bundle’.

3) Next thing to do is delete the temporary Gemfile and cd to your home directory.

4) From your home directory, execute the following (using your desired [sub]domain name):

refinerycms cms.olore.net

5) Then, create a new subdomain in Dreamhost via http://panel.dreamhost.com (same as above, I called mine cms.olore.net), click the checkbox for ‘Passenger (Ruby/Python apps only):’ and let it add ‘public’ to the end of your web directory – this will point to the public directory of the rails app that you just created.

Give Dreamhost a minute or two, then hit your site with a browser. You should see the initial screen for RefineryCMS asking you to create a new user.

Possible problems … with solutions!

a) When first accessing your site, you may get a Passenger error about rack versions. You may need to modify Gemfile.lock to use rack 1.2.1. If you make this change, simply ‘touch tmp/restart.txt’ to tell Passenger to restart, then hit the URL in the browser again.

b) When first accessing your home page you may get a 500 error. I resolved this by running ‘RAILS_ENV=production rake db:migrate’ followed by ‘touch tmp/restart.txt’

 

Good luck!

Tags: , , ,

First iPad app

March 22, 2011 by Brian | 2 Comments | Filed in play

Wrote my first iPad application tonight. Took me longer to redo the signer cert and provisioning profiles than to write the code… but it was worth it.

I used Titanium Mobile which I’ve played with in the past.

The goal of this app is to teach my kids the positions on the baseball field.

Here it is in all it’s glory

var win1 = Titanium.UI.createWindow({
  top: 0,
  left: 0,
  backgroundColor:‘#fff’
});

var webview = Titanium.UI.createWebView({
  top: 20,
  left: 0,
  height: ’75%’,
  url:‘./baseball_diamond.jpg’
});

var label = Titanium.UI.createLabel({
    text:‘Where is Right Field?’,
    bottom: ’50px’,
    height:‘auto’,
    width:‘auto’,
    shadowColor:‘#aaa’,
    shadowOffset:{x:5,y:5},
    color:‘#900′,
    font:{fontSize:48},
    textAlign:‘center’
});

webview.addEventListener(‘singletap’, function(e) {
  point = e.globalPoint;
  if (point.x > 480 && point.x < 766 && point.y > 382 && point.y < 624) {
    label.text = "Right!";
  } else {
    label.text = "WRONG!";
  }
});

win1.add(webview);
win1.add(label);
win1.open();
 

Tags: , ,

H&R Block 2011 won’t install

February 23, 2011 by Brian | 3 Comments | Filed in work

If you tried to install H&R Block 2011 (formerly TaxCut) on your windows machine you may have been greeted by a useless error message that says the install failed.

To get around this problem, in windows explorer, click on the D: (or wherever your CD/DVD is) and then right click on the .exe file and select “Run as administrator”

This solution was next to impossible to find on the Google, so I am hoping this helps someone!

Installing PostgreSQL on my Mac

November 30, 2010 by Brian | 1 Comment | Filed in work

PostgreSQL

1.  Download postgres for Mac

  • Don’t sign up for enterprise db crap, the download will start in a sec

2. Install postgres

  • This may require reboot to set some syscontrol settings (it did for me)
  • I created the “postgres” user with “postgres” as the password (so I could remember it)

3. Add stuff to your ~/.bash_profile

export PATH=$PATH:/Library/PostgreSQL/9.0/bin
export PGDATA=/Library/PostgreSQL/9.0/data

4. Execute the profile

$ . ~/.bashrc

5. Modify Postgres to use “trust” authentication, so we don’t need to supply a password when connecting to the database.

$ sudo vi /Library/PostgreSQL/9.0/data/pg_hba.conf

5.1 For each entry, change METHOD “md5″ to “trust” (this should only be done on your developer machine!)

6. Restart postgres to pick up the conf changes

$ sudo su – postgres
$ . ./pg_env.sh
$ pg_ctl restart

7. Beer time!

All of the above was done solely so I could run some ActiveRecord tests, so here’s how we do that:

$gem install pg
$ git clone git://github.com/rails/rails.git
$ cd rails/activerecord
$ rake postgresql:build_databases
$ rake test_postgresql TEST=test/cases/base_test.rb
(in /Users/brian/dev/ruby/rails/activerecord)

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -w -I"lib:test:test/connections/native_postgresql" "/Users/brian/.gem/ruby/1.8/gems/rake0.8.7/lib/rake/rake_test_loader.rb" "test/cases/base_test.rb"
Using native PostgreSQL
Loaded suite /Users/brian/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
…………………………………………………………………………………………………………………..
Finished in 3.321415 seconds.
131 tests, 336 assertions, 0 failures, 0 errors

SUCCESS!

Tags: , ,

Using Twitter Tools to integrate tweets into WordPress

August 15, 2010 by Brian | No Comments | Filed in play

I realized the other day that I wanted blog more. At the same time I realized that I post a lot to Twitter and set out to find a way to integrate my tweets in-line with my blog posts. I also figured that as I get close to the 3200 tweet history limit it’d be nice to have some of that history in my own hands. That’s when I discovered Twitter Tools.

Twitter Tools allowed me to modify my theme in such a way that I can get my tweets either as they happen, daily or a weekly summary… pretty slick. I wanted the “as they happen” option and I wanted them to show up differently, as quick blurbs (inspired by Gina Trapani’s Smarterware.org (where I think she is using QuickPost)) right in line with my blog posts.

After some monkeying around, I learned I could switch the theme based on which tags were used in the post. So I set up Twitter Tools to use the tag “tweet”. With that in mind I used the following code in index.php:

<?php while (have_posts()) : the_post(); ?>
    <?php
        $posttags = get_the_tags();
        $tweet = false;
        if ($posttags) {
            foreach ($posttags as $tag) {
                if (‘tweets’ == $tag->name) {
                    $tweet = true;
                    break;
                }
            }
        }

        if ($tweet){
            include "post_tweet.php";
        } else {
            include "post_normal.php";
        }

    ?>
<?php endwhile; ?>

With that in place, tweets get rendered with post_tweet.php and everything else with post_normal.php. Yeah my post_tweet.php needs some love… I’m getting there….

But in the mean time – victory is mine!

Tags: , ,

Updated Twitter bots

August 10, 2010 by Brian | No Comments | Filed in play

Finally got around to re-enabling and updating my twitter bots – including new images!

Thanks to Google’s new image search option for “labeled for reuse”

@NYBadDrivers image courtesy of Leo Reynolds (via Flickr)
@CTBadDrivers image courtesy of Daniel Case (via Wikimedia)
@NJBadDrivers image courtesy Mr. Matté (via Wikipedia)

Each account is re-enabled now, checking for any @replies to their respective account.

Tags: , ,

Doing battle with metric_fu

August 8, 2010 by Brian | 2 Comments | Filed in work

Metric_fu is a set of rake tasks that make it easy to generate metrics reports. It uses Saikuro, Flog, Flay, Rcov, Reek, Roodi, Churn, RailsBestPractices, Subversion, Git, and Rails built-in stats task to create a series of reports. It’s designed to integrate easily with CruiseControl.rb by placing files in the Custom Build Artifacts folder.”

It’s really a pretty sweet tool. It generates all these reports and you can either ignore them or act on them. Not saying which of those we do… but that’s not important right now.

If you’ve used metric_fu you probably ran into the NaN error. Good ol’ “Not A Number”.
Generally the output looks something like this:

NaN
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/float/rounding.rb:19:in `round_without_precision’
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/float/rounding.rb:19:in `
round
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/base/generator.rb:135:in `round_to_tenths’

/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/generators/rcov.rb:85:in `to_h’
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/base/generator.rb:131:in `
generate_report
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/base/generator.rb:53:in `generate_report’

/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/base/report.rb:54:in `add’
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/../tasks/metric_fu.rake:6
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/../tasks/metric_fu.rake:6:in `
each
/usr/lib64/ruby/gems/1.8/gems/metric_fu-1.3.0/lib/../tasks/metric_fu.rake:6

This particular error has cropped up several times for us, each time we do the same google searches, look at the same metric_fu sources, and slowly dissect which tests are causing this problem. Hopefully this post will help expedite debugging this error for you and your friends.

Read the rest of this entry »

Tags: ,

Compleat Rubyist – Day 1

June 19, 2010 by Brian | No Comments | Filed in work

Day 1 of 2 of my notes for the Compleat Rubyist training course

Ruby Versions and Implementations  – David

http://ruby-versions.net/ – David’s home for ruby versions & implementations for learning & historical reference

Ruby version manager – http://rvm.beginrescueend.com – lets you install several ruby versions/implementations and easily switch between (including your own custom compiled version). Suggestion – don’t install as root, even though it is allowed.

Notes on a few of the existing options:

  • MacRuby – interacts with Cocoa
  • Rubinius – Ruby in Ruby
  • JRuby – Ruby on JVM
  • REE – optimized – created by Phusion Passenger team
  • MagLev – built in object persistence, repository instead of files, smalltalk-ish
  • IronRuby – Ruby on .NET
  • URABE – ?

rvm allows you to compare performance between versions/implementation:

rvm ruby-1.8.6,ruby1.9.2 benchmark filename.rb

Why does everyone use 1.8 instead of 1.9?

  • Same amount of people are using it as last year (like almost no one)
  • Rails considerations
  • 1.9 is not 100% backwards compatible
  • 1.8.7 backported many of the features of 1.9, so people feel safer

Ruby Enterprise Edition has major memory and speed improvements

Highlights of changes between 1.8 & 1.9

  • Enumerators
  • Method parameters
  • Block variable binding & scope
  • Syntax changes

Read the rest of this entry »

Tags: , ,

RailsConf – Day 3 – Lightning talks

June 9, 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

Read the rest of this entry »

Tags: ,

RailsConf – Day 3 – Persistence Smoothie

June 9, 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 9, 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 9, 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 9, 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 8, 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 8, 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 8, 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 8, 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 8, 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: ,