Relational Modeling Framework - Nathan Sobo
Intro
Video of interaction model that drove thinking
Grockit - it is all common - pushing events collaboratively. This is harder than asynchronous model.
Client needs to respond to to the server in an asynchrounous manner.
All rendering occurs in the browser modifying the DOM as needed.
How do you model this? With a relational model. They build a relational model in the browser.
It is good because you don't need pointers, you just use foreign keys and scalar values. Really flat, really easy to serialize and move across the wire.
However, it is difficult to work with. Things are indexed by id, etc.
Demo
Lots of live coding. See the video (up soon) at GoGaRuCo.com
New project is "June" - based on Unison, but Unison is being deprecated.
The most primitive object in June is the set
System for working things in the browser.
It behaves as you would expect any relational model. Support add/remove etc. Example has User, Pet, and Species. Updating Tuples. Testing with Screwunit
Can have events on sets (i.e. on_insert, on_remove, on_update )
Events have other stateful information passed through a hash in changed attributes for each event.
on_update(function(model, changed_attributes) {
if (changed_attributes.name) {
print(changed_attributes.name.old_value + " was renamed to " + changed_attibutes.name.new_vaue );
}
});
Also has join model:
var stephs_species = stephs_pets.join(Species).on(Pet.species_id.eq(Species.id)).project(Species);
Also has has_many, and others will be implemented too.
Nathan can live code very well. He is writing a lot of really cool code and talking about it at the same time. Like this:
relates_to_many("pet_species", function() {
return this.pets_relation
.join(Species).on(Pet.species_id.eq(Species.id))
.project(Species);
});
Can also remotely access the entire server-side database (don't worry, there will be a security model):
var remote = June.remote("/domain");
However, you can't pull the whole database down to the browser. So, you can get a subset of the data that the client requests.
Security: Only give the browser access to things the user is authorized to see. Every Tuple acts as it's own database.
Objects that have specific permissions only receive tuples and events that pertain to them.
Arduino is Rails for hardware hacking - Greg Borenstein
Intro
Obligatory safety talk
Electrical engineering is for experts!
Physical computing is for everyone!
Physical computing is programming for stuff read inputs from your surroundings and modify them based on logic
[Arduino](http://www.arduino.cc/)
Open source hardware and software project that makes physical computing really easy

Most of the API is for sensing and controlling the physical world.
HELLO WORLD - make an LED blink on and off
class HelloWorld < ArduinoSketch
output_pin 13, :as => led
def loop
led.blink(500)
end
end
RAD is Ruby Arduino Development
In a hardware demo, everyone is required to go "Oooooooooooh" (even if it doesn't work)
rad command generates a project directories
You can buy an Arduino board for ~$30 from Make or a Dorkboard for ~$6
Bell rings as a post commit-hook for git
.git/hooks/post-commit require 'bell.rb' Bell.ring exit 0
Demo Reason + Archeopteryx playing a drum
Archeopteryx: code describes patterns with channels, and randomness.
Reason sends midi to Tascam midi device, Tascam sends to Arduino, which turns solenoid attached to drumstick.
Physical computing is for everyone, if you've ever wanted to make your code interact with the world, now you can.
Q: Can you use this to play rockband?
A: Yes. You can use a photoresistor to detect notes coming across the line.
Q: Are there latency problems with midi playback?
A: The clockspeed of the arduino is fast enough to keep up with the playback.
Lightning Talks
Bosco is introducing the speakers. Come to the ruby meetup!
Jeff Smick - Blather
Tim Connor - Rack Middleware build, init call cycle
Wolfram Arnold - What's Cool about cache money?
Yehuda Katz - Moneta
Andy Delcambre - Datamapper Adapters
Brief interlude trying to figure out why the projector was not working
Erik Michaels-Ober - Merb Admin App
Mislav Marohnić - RSPACTOR for continuous tests on OSX (& more!)
Bryan Helmkamp - Rack::Bug
Pat Nakajima - No more Keynote with Slidedown
Chris Lee - Floxee - OS Twitter Dir
Max - PaMP: Privacy-aware Marketplace
Andrew Cantino - SelectorGadget
"SelectorGadget is an open source bookmarklet that makes CSS selector generation and discovery on complicated sites a breeze."
Kyle Maxwell - Parsley
"Parsley is a simple to use and elegant language for creating HTML and XML parsers" "Parsley can be used from Ruby, Python, C/C++, and the *nix command-line."
Webrat: Rails Acceptance Testing Evolved - Bryan Helmkamp
Intro
Bryan Helmkamp ( more about him ). He works at WePlay. He is the co-author of "The RSpec Book"
Links:
Audience Poll: How many people know and use webrat (50%+ using, 25% using)
Webrat is an awesome tool everyone should use, but it doesn't run on the iPhone, not written in Scala, and there is no Pr0n.
Beer Disclaimer
If you have questions that aren't answered, find him for a beer after the conference
API
Writing a rails integration test how we test websites, traditional methods are brittle and tedious.
Webrat code is more readable than traditionally written integration tests
It behaves like a browser:
Uses nokogiri to parse the response HTML and run assertions on it.
How to use it?
#config/environment.rb
config.gem "webrat", :version => ">= 0.4.4"
#test/test_helper.rb
Webrat.configure do |config|
config.mode = :rails
end
Webrat's Core API
Webrat works with RSpec, Shoulda and Cucumber Webrat and cucumber do not have to be used together. You can use Webrat with whatever testing framework you want to use. Webrat also works with Rails, Sinatra and Merb.
Webrat can do input matching to labels. Webrat encourages you to put good labels on your form fields.
Webrat verifies HTTP Status codes for you behind the scenes.
Verify HTML content
response.should contain("Hello, world!")
response.should have_selector("li", :class => "new", :count => 2)
response.should_not have_xpath(".//meta[@name='robots']")
response.should have_selector("#album li:nth-child(3)") do |li|
li.should have_selector("img", :src => photo_path(@photo))
li.should contain("Vacation Photo")
end
When things go wrong Webrat uses '''save_and_open_page''' and writes out the current response body and brings up the page.
Webrat Adapters
Evil plot is to write adapters so he can test everything at once.
Selenium
Webrat started as an alternative to selenium, but it now includes a selenium adapter. Bryan suggests not using selenium whenever possible. You should start with the traditional webrat mode and not the selenium mode. Unfortunately, it's the only way to test a real browser, such as javascript.
# selenium doesn't support transactional fixtures
class ActiveSupport::TestCase
#...
self.use_transactional_fixtures = false
#...
end
setup do |session|
session_host "localhost:3000"
end
Webrat.configure do |config|
config.mode = :selenium
end
Webrat talks to the selenium client gem to talk to the Selenium RC server which then drives a browser (IE, safari, and/or firefox).
Sometimes you'll need to an action differently when a browser is actually present. These commands let you write code for a specific context: webrat.simulate - traditional webrat simulation mode webrate.automate - drive a real browser
# is not run in normal webrat mode
webrat.automate do
end
# is not run in selenium webrat mode
webrat.simulate do
...
end
The 'selenium' object is exposed from the selenium client gem. You can use it directly within your tests.
Automating a real web browser is SLOW
One more thing...
rack::test - gives you a quick way to generate requests to any rack enabled application Makes it easy to test complicated routing of requests through rack apps. For example, a rails metal that routes to a sinatra app.
Rack::Test API
get post, put, delete head request ...
Questions
A: Webrat has a method called "within" which allows you to scope your selectors to be inside an HTML tag.
Q: Does it have support for checking HTML validity?
A: No, that is outside of the scope of core webrat. However, we have talked about the ability to capture
Q: Where does the output of save_and_open_page go?
A: Into Rails' tmp directory
Q: Selenium client has some interesting screen grab is that being exposed?
CouchDB + Ruby: Perform Like a Pr0n Star - Matt Aimonetti
Intro
Matt Aimonetti is part of the Merb team.
Size matters
You need reliability
Fault tolerant
Multiple Partners
Scalability
Approaches
Every p0rn star needs a trick
Enter CouchDB
Why aren't you a porn star now? Because of RDBMS
What does RDBMS have problems?
What other kinds of approaches can we use?
Hypertable
Distributed Hash Table
Some other projects: Project Voldemort, Tokyo Cabinet, Redis
What is CouchDB?
It is a project written in Erlang by Apache. It uses spider monkey.
Can be used as a key/value store. Can also put data in a schema-less store, format your data as a JSON object and dump the whole thing into the db
CouchDB comes with a nice web interface called Futon that lets you inspect your database and its contents.
CouchDB is de-centralized. You can do replication between multiple masters.
map/reduce is built in to compute data. Maps and reduces can be written in Javascript.
Optimized for the web, more reads than writes.
How does this relate to Ruby?
Using CouchRest Everything is a JSON object.
You can define properties so you get an attribute reader/writer, and do document.attr
There is no SQL in CouchDB, you do queries like Card.first, Card.all, Card.get('matt_aiomonetti')
The problem is trying to map documents into Object-Oriented languages, but it doesn't always work. If you have dependent objects (such as Card and Address), then you tell CouchDB to cast it as something.
property :questions, :cast_as > ['Question']
Callbacks:
save_callback :before, :generate_slug_from_title
Relationships can be done, but you have to decide how to do it, and there are a lot of ways.
When to use couch?
Use cases:
Questions
Q: Can you use couchdb with objects that have attributes that change often?
A: Yes you can use it.
Q: There are many ways to do relationships. Can you give an example?
A: Blog has an article with many comments. You can make one doc that is an article, and you can add comments. Problem is you need to send the whole document that increases risk of conflicts. So you create a new object that is the comment object that just refers to the article. Then, in the view you define the Article as aggregating all comments. Alternately, you can make a query to retrieve all comments for the article.
Using ruby to fight AIDS - Jacqui Maher
Links:
Baobab Health
Malawi based non-profit organization founded in 2000.
Baobab is a tree found throughout Africa and Australia. Local legend says the hyena that was given the baobab tree during the creation time planted it upside-down.
Baobab presented at RailsConf Europe in 2007. They knew of her interest in epidemiology, programming, Africa. She subsequently flew to africa, and visited the Kamuzu central hospital in Malawi.
She got to know the guys working there and what they do. Jeff Rafter was the main contact.
The main focus of Baobab is AIDS
AIDS in Africa
What does that mean? Africa post-colonial was on the upswing, but the AIDS epidemic took a giant toll, lowering the life expectancy from about 60 to almost 40 years old!
AIDS Impact:
Malawi is a land-locked country in sub-Saharan Africa, with the 2nd fastest growing economy in Africa.
In 2002 a major famine, a major contributing factor to the deaths was AIDS.
What can be done?
Solution: Digitize important data:
Baobab's Solution
Hardware (known as the I-Opener) is portable tablets with 56k modem. It bombed in US and Europe, but they got a bunch, and have hacked them to have Ethernet, Power-over-ethernet, Touchscreen, and a Bar code scanner.
Government has instituted a national health id as a barcode to help facilitate treatement. If you plug in a bar code scanner, you can read their data without even typing their name.
Bought I-Openers off of Ebay from the USA, the owner of which eventually donated 2000 units. Set up a wireless mesh network, which is ad-hoc node-base routing. It's also self healing - if one of the nodes is down, you just skip right over it (very good for frequent and sporadic power outages). Power was provided by rechargeable batteries which can be used when the power goes out.
Software
BART: Baobab Anti-Retroviral Treatment
The data model was complex.
The system as a whole accomplishes the following goals:
Registration
Encounters
Observations
Perscriptions
When you are making $2 per day, you cannot afford a pill that costs $100.
Cool, so we're done, right?
Barries to contribution
Presented at RailsConf in berlin, but there was not response, because they were not set up for people around the world to contribute:
What did they do?
Benefits of using
Results
electronic patient administration is possible even in the developing world
and it's better than the typical first world paper records
and you can accomplish it using new state-of-the-art technologyImpact locally:
Ruby Community
Why ruby?
Innovation
If you have no existing infrastructure, you might as well start with the latest and greatest thing!
Questions
Q: Is the mesh network the same as the OLPC mesh network?
A: As far as I know, no. It is local to Malawi. It is an infrastructure mesh, not laptop to laptop.
Q: How widely is it deployed? Of the 280 doctors?
A: About 265 of them, so almost all. It has plans to go outside Malawi.
Q: How is Baobab involved with education and prevention of AIDS?
A: Baobab's main focus is to deal with doctors and patients, not directly involved in prevention and education which is done by other groups.
Q: How are the african engineers learning about ruby and rails? A: Some of them had no programming experience whatsoever, others knew .NET or PHP. They learned everything from scratch with peepcode and other tutorials. One of the best contributions we can make is to publish information on these best practices.
Using Shoes to Have Fun - Tim Elliott
Intro
He rode his bicycle from Chico. He works at Trevidia, and is a Rails developer
Links:
The Shoe Box - A collection of user apps written in Shoes
Nobody Knows Shoes (comic book)
Shoes
The highlight is the fun that he has found by programming in Shoes. This was originally a talk about iPhone, but he wanted to put more fun into it.
why the lucky stiff wrote a comic about Shoes. In 2003, why wrote a blog post called "The Little Coder's Predicament". It is a call to arms for all programmers, beginning and expert, to have more fun.
Such as the old Commodore 64 program, written in BASIC: 10 PRINT "TIM RULES" 20 GOTO 10
You could do really fun things really easily, even if you didn't own a C64!
However, Ruby is harder for kids (especially on windows) to get started with:
Sqlite
rails cat_app script/generate etc...
That lets you "make a cat", but not too exciting for kids. Involves too many other languages (HTML, CSS, Javascript). They want cats to jump around the screen and do cool stuff.
Shoes
Shoes is not a Gem
Couldn't use a standard ruby distro, had to install a new one, but this is because shoes is not geared towards developers, but people who are installing for the first time.
Shoes is a GUI toolkit that embeds Ruby. It includes a packager and a few gems.
Very flexible but understandable layout engine.
Example of Shoes: Shoes.app do stack do para 'wanna click a button?' button('sure') { alert 'woot' } end end
"Stacks" and "Flows". You can do simple or complex layouts using these two principles.
Flows act like left floated html elements.
Everything is wrapped in a Shoes.app block, and does a class eval.
You can put your own classes outside the app block and use them inside, but there's a gotcha. Once you use classes from outside the app block, the class eval doesn't work, but there is a workaround.
Shoes keeps an array in the form of an in-memory stack that remembers everything. So when you start putting controls in, Shoes knows where to put them. it is always tracking which container you are in, so you can get an idea of where everything shows up.
Also watch out for long-running tasks at the OS level, this can kill the app performance (due to green threads).
Demo of Shoes:
Drawing some ovals
Shoes itself comes with online documentation when you install it, which has a nice search tool and examples.
Shoes is also good for rapid prototyping, such as desktop apps or iPhone apps. The advantage is that you get to do it all in Ruby.
Sharing with friends
It is easy to share. If you are running shoes, you can use a packager that comes with it to create an executable installer which runs on Windows, Linux, or OSX.
It will be small, a few meg, and still under ten even if you use video.
You can use ruby-debug to interactively debug.
`Shoes.setup do gem 'ruby-debug' end
require 'ruby-debug'
Shoes.app do debugger end ` Shoes has a gem installer gui and will install gems includes in the Shoes setup block, this gets included in the package.
It includes native HTTP download libraries for all platforms, because ruby http lib is slow and for other issues.
In the git distro, it includes "bloopsiphone" which lets you create Atari-like sounds and noises, and it also has an easy API.
Be creative and have fun, make robot apps, make the robots eat each other. This is a great way to connect your passion with non-programmers, because everyone likes robots eating other robots.
Q: You mentioned development for the iPhone can you go into more detail? A: You can't run ruby on the iPhone yet but its still useful for prototyping.
CloudKit: Hacking the Open Stack with Ruby and Rack - Jon Crosby
Intro
Thanks for the votes, his talk is here because of GoGaRuCo attendee votes.
He works for Engineyard, and they are hiring.
This talk will be "lightning-talk" style, so that means it will be very fast (and also means this live-blog will be pretty sparse)
Cloudkit
Cloud Kit is an Open Web JSON Appliance Can quickly and easily spin up an API for RESTful Collections of JSON Documents
Similiar to CouchDB and Perservere Implemented in Ruby (unlike CouchDB)...
Now Frameworks are basically another MVC framework
So why wouldn't you want to do a new MVC architecture?
gem install cloudkit
Radar
"If your RESTFUL API cannot be accessed with curl, you lose"
Resource Composition in the Browser
If you have two widgets in the browser doing different tasks, you can point them at different resources. Example: 280Slides Example: SproutCore
Mobile apps can benefit from this style of restful architecture as well.
ESI caching layers - like Old Skool SSI, except that they are cache includes.
Cloudkit is built on Rack. Rack is awesome.
HTTP Intermediaries - such as Rack Middleware. Rack Is The Web The spec for rack middleware is runnable and readable
Build an App! create config.ru require 'cloudkit' expose :todos, :profiles
Cloudkit bootstraps so you can query it You can ask it for it's Options and it'll tell you what you can do with it
Hypermedia as the Engine of Application State
Cloudkit is read-optimized
No SQL, no ORM, uses Tokyo Cabinet Tables instead
Schema Free, HTTP and JSON are the schema
Can do a PUT to place a new record at a specific location
Can do POST to update. By supplying the version etag the server can solve the "lost update" problem
Auto-versioning, any time you update a resource, the previous version is archived. That's reflected in the url - :collection/:version. This is solves the last-update problem when 2 users update the same document at once. If you try to update a resource without providing the version, it will return 400 bad request. If two clients try to update the same version, the seconds get 412 precondition mismatch response.
Cloudkit also solves the batch GET problem, where you can access the resource with id "_resolved" to get multiple documents at once (and their complete contents).
Finally, with DELETE, you can't delete things that out of date, similar to update. The 410 Gone response will get returned in this case.
"Rewrite in Scala... or solve the problem"
What's missing? The ability to ask questions Pagination Querying - solved with JSONQuery. (/todos[0:10][?priority=3])
jQuery plugin for Cloudkit
All code is up at Jon's Github
Because it's OpenWeb, you can easily add OAuth, OpenID, etc. A desktop application might use OAuth, whereas a web application could use OpenID for authentication.
Q: Isn't querying slow? A: Yeah, it can be slow. There's indexing work that needs to be done on write to optimize read. Tokyo Cabinet might come to the rescue here about searching data with regular expressions.
Q: Are there real world apps using cloudkit? A: Not that I know of. One company might be trying it.
Q: What kind of apps are good for cloudkit? A: I'm personally using it for Actiontastic, a synchronizing web service that provides a REST interface.
Q: Are there plans to abstract away the key/value storage system so other systems can be used? A: Yehuda has a library called Moneta that's an abstraction for Key/value stores that I'd like to move to.
Q: How does CouchDB map/reduce company to cloudkit's JSONQuery? A: It first started as a Sinatra app that sat between couchDB, but I found JSONQuery to be better suited.
For the second day of GoGaRuCo, my fellow Pivots David Stevenson, Zach Brock, and Ryan Dy are helping out with the live-blogging duties (Tom Sawyer says live blogging is SOO FUN!).
We are ALL writing the blog posts collaboratively, using the Coda editor which is based on the SubEthaEngine:





























