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!
- Artists!
- Idealists - Fab labs in India
- Hackers - Cockroach driven robot. Cockroach runs, spins ball, drives robot
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

- Program via USB
- power via 9v
- 14 digital i/o pins
- AVR microcontroller
- 6 analog i/o pins
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
- Play midi via Reason
- Playing same midi through arduino, a motor, a drumstick and a snare 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
- Simpler XMPP
- Make XMPP4R easier
- Requires libxml-ruby and EventMachine
- simple DSL -Handlers for ready, error, message, presence, iq
- Guards route stanzas
- Guards can be symbols, hashes with string, hashes with regexs, lambdas or arrays
- PubSub is in the works and coming next
Tim Connor - Rack Middleware build, init call cycle
- based on the sinatra flash plugin
- Wanted to remove sinatra from it
- Found that every time you say "use" you are creating a lambda which will create an app reference
- You can check out his Rack::Flash
Wolfram Arnold - What's Cool about cache money?
- Nick Kallen wrote the original Cache Money
- Backed by Memcached
- Abstracts away the caching between the code and the database so you don't have to worry about it.
- Can just do User.find instead of User.get_cache
- named scope, has_many, etc will all work transparently
- Can almost use it as a drop in to add caching
- Cache Money doesn't support joins but check out acts_as_most_popular
Yehuda Katz - Moneta
- Moneta is allows you to create objects that behave like hashes backed by any format you want
- Behaves just like a ruby hash
- Has adapters for BerkeleyDB, Datamapper, Memcached, S3, xattr, rufus and more
- Easy to write new adapters
Andy Delcambre - Datamapper Adapters
- Making it easier to write datamapper adapters
- Wrote an adapter for github repos today
- Demonstrating pulling down Github repos and searching with datamapper syntax
Brief interlude trying to figure out why the projector was not working
Erik Michaels-Ober - Merb Admin App
- like active scaffold for rails, this is for merb
- modeled after Django site admin uses their css and js python manage.py runserver
- introspects your model to display form elements intelligently
- adds a generator for adding new admin
- not up on github yet try sferik on twitter
Mislav Marohnić - RSPACTOR for continuous tests on OSX (& more!)
- "make it green then make it clean"
- autotest
- Problems
- one big file
- awkward growl integration
- pitfalls when using rspec-rails plugin
- polling - uses 25% of cpu when idling :(
- Problems
- Original RSpactor written by Andreas Wolff
- OS X only because it uses filesystem events
- made for Rspec + Growl integration
- Console tool
- but abandonded :(
- Mislav-RSpactor
- cleaner, more modular, default mappings for usual directory structure
- better mappings if its a rails project
- tested!
- so modular you can reuse the Listener if you want to listen for mac file system events
- uses a lot less CPU
Possibilities
- running related tests while you TDD
- compile Haml/Sass for static sites
- trigger javascript sprockets build
- render RDoc output while you edit comments
- it can be run for all projects in your filesyste, you just opt each project in
Bryan Helmkamp - Rack::Bug
- Rack middleware
- inspired by Django debug toolbar
- Modular, can be used for any rack app
- Panels
- rails env
- rails response time (cpu time)
- request vars (session cookies, rack env)
- keeps track of SQL queries - shows backtrace on queries, explain for queries
- count of ActiveRecord instantiations on the page using Oink
- can look in Memcache cache
- template traces (times for rendering)
- aggregates all Rails log entries
- KB delta for process size of Ruby during a single request
- runs on production environments, password protected
- instruments using alias_method_chain hacks
- Working with Yehuda Katz on Orchestra to someday soon simplify it
Pat Nakajima - No more Keynote with Slidedown
- Speaks at NYCrb meetup, and didn't want to use Keynote
- Wanted to use Markdown but also wanted syntax highlighting
- Generates an HTML page that you can use to run your presentation
- The Maker's Mark library was extracted to do easy syntax highlighting in Markdown
Chris Lee - Floxee - OS Twitter Dir
- open source twitter dirctory application
- tweet congress
- directory of tweets from members of congress
- Floxee on Github
Max - PaMP: Privacy-aware Marketplace
- From IBM Almaden Research Labs
- privacy-aware market place
- Goals
- to develop a platform that allows users to manage their privacy settings across social network -reducing the cognitive burden on a user; leveraging the wisdom of his crowd
- Maps to opensocial, etc
Andrew Cantino - SelectorGadget
- No time :(
- "SelectorGadget is an open source bookmarklet that makes CSS selector generation and discovery on complicated sites a breeze."
Kyle Maxwell - Parsley
- No time :(
- "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:
- bit.ly/wbrt-ggrc
- Twitter: @brynary #webrat
- brynary.com
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:
- "visit" method - the equivalent typing in a URL to the browser.
- "click_link" - like clicking a link (duh)
- "fill_in" - fills in a field
- "assert_contain" - perform assertions
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
- visit
- click_link
- fill_in
- check and uncheck
- choose
- select
- attach_file
- click_button
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.
- Automatically makes sure you don't get 500 HTTP server errors.
- Also ensures that fields exist
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
- Rails
- Merb
- Sinatra
- Selenium
- Mechanize (can use to scrape other websites i.e. google)
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
- Q: How do you deal with links with the same names?
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?
- A: Webrat has that in Selenium mode now.
CouchDB + Ruby: Perform Like a Pr0n Star - Matt Aimonetti
Intro
Matt Aimonetti is part of the Merb team.
Size matters
- memory usage
- amount of servers
- infrastructure
You need reliability
Fault tolerant
- downtime
Multiple Partners
- Nice public interfaces
- no discrimination
Scalability
- reaction underload
- handle concurrent connections
- numbert of requests persecond
- latency
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?
- most/all fields become options, schema changes and it becomes hard to deal with
- joins hurts performance (add indices/tables)
- replication is difficult when using multiple masters
- auto-incremental ids
What other kinds of approaches can we use?
Hypertable
Distributed Hash Table
- fault tolerant
- used by p2p and IM
- memached is another example
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.
- full Acid compliance
- https rest interface
- caching (couchdb uses etags) - this makes caching with existing HTTP caching technology (nginx+memcache, varnish, etc) really easy.
- built-in conflict management using MVCC (multiversion concurrency control)
- Every single record gets saved as a different revision
- document attachments are attached as document stubs, that also get replicated to different nodes and don't use a lot of memory
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?
- When you need to scale you database and availibility is more important than consistency.
- When your data is decentralized (you have more than one master
- When you need to compute data
Use cases:
- Analytics - combined with traditional rdbms system to get statistics using couchdb
- Personal finance - Bank accounts in different countries - download all accounts, and can process in one place - attach PDF files, desktop app, etc.
- Medical Record System - Many patients with visits, history, records, etc.
- distributed e-commerce sites (1 main website working with multiple partners, the data can be replicated easily) In this case, CouchDB is much faster than RDBMS, because of drugs, compounds, and complex structures.
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:
- Github: baobabhealth
- Twitter: baobabhealth
- IRC: irc://irc.freenode.net/baobab
- Website: http://baobabhealth.org/
- Blog: http://www.baobabhealth.org/feed/
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
- 6.7 million
- 33 million 2 millions AIDS related deaths last year
- 1.5 million AIDS related deaths last year
- 1.9 mill new HIV infections last year
- 5% of adults
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:
- Lowered life expectancy
- Children orphaned
- Economic impacts
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.
- population 14 million
- 84000 deaths per year
- 250 new inffections daily
- 8 people die per hour from AIDS, leaving 1.5 million children orphaned.
- 280 doctors only
- 3500 HIV patients per doctor!
- long lines
- people leave
- complex registration form
- incorrect or missing data
- incorrect treatment
What can be done?
- more verifiable data
- accssible data (faster/shared)
Solution: Digitize important data:
- portable hardware
- touch screen laptops
- software: easy to use, validation, treatment protocols
- network connectivity: between clinics & the internet
- power: power outages happen often (several times per day), some places have generators/batteries
- collaboration: between clinics and organizations
- authority: your solution must be recognized, trusted, and respected
Baobab's Solution
- save lives by improving patient treatment
- computerized data entry + retrieval
- portable work stations
- system based treatment protocols
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
- Ubuntu Linux servers
- Ruby On Rails
- MySQL
- Custom systems monitoring library
BART: Baobab Anti-Retroviral Treatment
- Data model: OpenMRS (Medical Research System)
- Templating using ERB
- Applcation calls via AJAX
- Testing with Rspec
- Reporting
The data model was complex.
The system as a whole accomplishes the following goals:
- Patient registration
- Encounters
- Observations
- Perscriptions
Registration
- enter a new patient data
- generate national id bar code
- scan an existing bar code
Encounters
- interactions with patients
- forms
Observations
- diagnoses
- disease progression
- vital stats
- patience compliance
- regimen progress
Perscriptions
- Drugs
- Drug ingredients
- Dosage and formulas
- Inventory
- Orders
When you are making $2 per day, you cannot afford a pill that costs $100.
Cool, so we're done, right?
- working on refactoring for reliability
- Lots of tests in Rspec, but they are fighting on many fronts.
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:
- No public repository (SVN)
- No reliable internet access
- Patient data security
- Feature & Infrastructure development schedule
What did they do?
- Github - baobabhealth
- IRC - irc://irc.freenode.net/baobab
- Twitter - baobabhealth
- Employee Blogs - http://www.baobabhealth.org/feed/
- Website - http://baobabhealth.org/
Benefits of using
- More people see doctors
- Application contraints
- validation
- workflow guidance
- Easy to use interface: More people can help
- Gem the Janitor even learned to register patients (system is so easy to learn)
- Data collection enables extensive reporting
- International agencies can make decisions stategically based on this data
- Comparative Oberservations
Results
- experiment was a success
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 technology
Impact locally:
- creates a local development community
- inspire kids to program
- training in associated technologies
Ruby Community
- community consensus on best practices
- actively contribute to OSS
- accessible info on full stack
- superb interactive tutorials (like peepcode)
Why ruby?
- Elegant & readable
- Easier to learn offline
- Self contained documentation
- ActiveRecord: complex data models easier
- Execute SQL directory for more complex queries
Innovation
- urgent need for solutions
- old-school patient admin doesn't work amidst an epidemic
- no existing infrastructure
- getting basic tools often requires thinking ouside the box
- alternative: death & disorder
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 Shoes website - To get and learn about Shoes
- 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:
- Ruby one click installer
- RubyGems
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
- One installer
- draw and animate
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:




































