We've moved JsUnit from SourceForge (where it's been hosted for over 8 years) to GitHub, under Pivotal's account:
http://github.com/pivotal/jsunit
The motivation is (1) to bring JsUnit development more officially in-house at Pivotal Labs, where it has a better chance of getting more attention than it has historically, and (2) to more easily allow the wider community to contribute.
Fork away!
At Pivotal Labs, one of the services we provide is bootstrapping startups, including helping them interview and hire. We currently have clients looking for skilled engineers to build their development teams. This is an excellent opportunity to learn Extreme Programming by working side-by-side with Pivotal's talented and experienced developers while at the same time getting in on the ground floor of a small and dynamic product team.
Pivotal Labs and our clients place a strong emphasis on Agile development and its many aspects: Pair Programming, Test-Driven Development, rapid iterations, and frequent refactoring. General technical requirements include serious web development experience, and a significant subset of Ruby, Rails, CSS, JavaScript, or MySQL.
Here are short descriptions of Togetherville and Honk, San Francisco-based clients of Pivotal Labs currently looking for developers. The full job postings follow.
Togetherville is an early-stage, funded startup at the crossroads of learning, technology and society. Starting with our highly-respected and successful Funders and Advisors, we are building a team that is excited about getting a ground-floor startup experience and is capable of consistently meeting and exceeding the high expectations of success we have set for ourselves. We are extremely passionate about what we’re doing and just as passionately looking for focused and fun people to join our team. We are not hung up how many years of experience you have. We’d rather start with your potential and what you can do and then go from there!
Honk.com is a new online automotive website that will make car shopping fun and social. We will enable consumers to experience a new way to explore new cars. We have partnered with a top social website to deliver this new way of car shopping and are funded by one of the largest media companies in the world. Our small team is made up of an experienced group of humble, efficient, and hyper-passionate individuals who are veterans of the automotive industry and social media space. We are proud of our ego-less culture, one that promotes team thinking, not individual accolades. If you're interested in helping prove that social media and car buying go hand in hand, social networks serve a bigger purpose than keeping up with one's day, and a small team can outdo the work of an army - then we may have a seat waiting for you.
If you are interested or for more information please contact the company directly. This is an exclusive service provided to our clients, no external companies or recruiters please.
Full job postings follow.
Ask for Help
"How do I get the cursor to appear in Firefox after resizing a textarea?"
After resizing a <textarea> using jQuery with an animation, you can type in the <textarea> but the cursor is gone.
Ideas to try include resizing the <textarea> without animation, and try triggering a blur or focus event.
"Is anyone using underscore.js to add enumerable support with jQuery?"
Nobody here has tried it officially yet, looks promising.
Interesting Things
- <iframe> and Safari
Seeing this in Safari only which has a more strict default setting to handle same origin policy. If you load a page from your own site with an <iframe> with a page from another site, that other site is not able to set cookies, and is is a problem on one project trying to use Facebook connect in an <iframe>. The solution was to redirect the entire page to Facebook connect, and then redirect back, which is not an ideal user experience.
Help
Is there a way to ensure at_exit will always be ran regardless of how the program exits without wrapping all code in an ensure block?
Ideas included:
Use a runner class to execute the program and wrap that in an ensure block.
trap("EXIT") { block } should get triggered no matter how the program terminates (sigint, exception, etc)
What are the likely causes of RangeError exceptions during test runs?
<RangeError: 0x23513ec is recycled object>
This is generally caused by C extensions.
Their appearance coincided with a Darwin ports update — perhaps you're running native gems against different versions of libraries than they were compiled against.
Are there any techniques out there to take a series of bytes and run some heuristics on them to determine the likely encoding of the string it represents?
Anybody out there have any ideas? Please let us know in the comments!
Interesting
Passing :multiple => false or nil to the select helpers causes unpredictable results — the helper still builds input element names assuming an array of items will be passed back. The helper checks only that the key is present in the options hash and not the value which means if you need to conditionally render a multiple, you'll have to make sure you don't specify the :multiple key at all.
Using $('textarea').val() causes unpredictable results as a textarea doesn't keep its data in a value attribute. Use text()) instead.
IE 7 and 8 (and more than likely 6) seem to have a problem with jQuery selectors that match links based upon the href attribute — changing the href of the matched elements does not get reflected in the document.
From a Blabs comment: Taps is a Sinatra web service from Heroku that's used to move data from one database to another. It transmits data as serialized arrays and loads them using ActiveRecord so it's DB agnostic.
Disabling a label via jQuery will not disable the input that it refers to in the for attribute as the label is not a container.
Happy Thanksgiving!
Responding to my last post, Josh pointed out what should probably be obvious: It's likely a bad idea to bundle bundler. There's a potential for version conflicts.
For our second attempt, we're
As a second attempt, we're now cribbing from the continuous integration setup from the Rails project. So far, so good:
Our RAILS_ROOT/cruise_config.rb...
require 'fileutils'
Project.configure do |project|
project.build_command = 'sudo gem update --system && ruby lib/cruise/build.rb'
end
And, the referenced lib/cruise/build.rb (the important parts)...
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
def root_dir
@root_dir ||= File.expand_path(File.dirname(__FILE__) + '/../..')
end
def rake(*tasks)
tasks.each { |task| return false unless system("#{root_dir}/bin/rake", task, 'RAILS_ENV=test')}
end
build_results = {}
cd root_dir do
build_results[:bundle] = system 'gem bundle' # bundling here, rather than in a task (not in Rails context)
build_results[:spec] = rake 'cruise:spec'
end
failures = build_results.select { |key, value| value == false }
if failures.empty?
exit(0)
else
exit(-1)
end
Thanks go to
- Josh Susser for help via email
- John Pignata for suggesting we look at the Rails project
- Rails team for the reference scripts
More comments and suggestions are encouraged.
Ask for Help
"How do I create a model without a backing store?"
One way to do this is to use the active-form plugin (or here), which lets you create model objects that support ActiveRecord Validations but are not backed by database table. Not to be confused with the other ActiveForm, which is a DSL for defining XHTML forms with validation.
TODO
"How do I turn an association into an array?"
You can access the underlying array by using .target or .proxy_target. If you want to cause the association to load all it's data pass any parameter, for example
blog = Blog.find(:first) posts = blog.posts(:force_load)
Interesting Things
- AWS gems log spew and SSL
Noticed that when using the RightScale Amazon Web Services gem that a lot of log output is going to STDOUT. To capture this output specify a logger wherever you create your AWS service object, for example:
development:
RightAws::S3.new(access_key, secret_key, :logger => Logger.new(File.join(File.dirname(__FILE__), '..', '..', 'aws_sqs.log'), 'daily'))
demo/production:
RightAws::S3.new(access_key, secret_key, :logger => Logger.new(File.join(File.dirname(__FILE__), '..', '..', 'aws_sqs.log'), 'monthly'))
To prevent even more warnings from appearing in your log output you can also set the @http.verify_mode as follows:
original:
@http.use_ssl = true
ca_file = get_param(:ca_file)
if ca_file
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@http.verify_callback = verifyCallbackProc
@http.ca_file = ca_file
end
patched:
@http.use_ssl = true
ca_file = get_param(:ca_file)
if ca_file
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@http.verify_callback = verifyCallbackProc
@http.ca_file = ca_file
else
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
Thanks to all who came out for the Startup Crawl last Friday night. It was a great crowd and by all accounts a great event all around. We had many challengers on the PivotPong table, but none could defeat Rob Mee. Despite his perfect 19-0 record, Rob has pledged $10 per victory for charity, so your duels were not in vain.
We truly enjoyed hosting the RubyConfers and everyone else who participated and we look forward to seeing you again as clients, partners, Pivots, and speakers at future events.
One of our projects had a pending chore in Tracker to move its backend to PostgreSQL from MySQL. This project has about a quarter of a million rows of production data and around a hundred tables in its schema which needed to be exactly migrated into PostgreSQL.
Forklifting the data proved more complicated than expected due to incompatibilities in the two DBMS' syntax such as in the way string escaping worked, how booleans were represented and a bunch of other small but painful differences. Despite MySQL's mysqldump utility including a command-line option to write statements in PostgeSQL format, it became clear that it wasn't going to be simple to create a repeatable procedure to do this work across our environments.
There's a bunch of information out there about how to approach this problem but none felt right. Most are multi-step manual procedures that require altering a dump file using sed or perl and others require the data to be loaded into an intermediary database and massaged prior to import. After testing some of these approaches, Todd and I decided to timebox ourselves to an hour to test the viability of a Ruby script using the DBI gem to move the data. We came up with:
require 'dbi'
require 'dbd/mysql'
require 'dbd/pg'
begin
mysql = DBI.connect("DBI:Mysql:source:localhost", "username", "password")
postgres = DBI.connect("DBI:Pg:destination:localhost", "username", "password")
mysql.select_all("SHOW TABLES") do |table|
next if ['schema_migrations', 'sessions'].include?(table.to_s)
select = mysql.execute("SELECT * FROM #{table}")
columns = select.column_names.map { |key| "\"#{key}\"" }.join(', ')
placeholders = (['?'] * select.column_names.size).join(', ')
insert = postgres.prepare("INSERT INTO #{table} (#{columns}) VALUES(#{placeholders})")
select.each { |row| insert.execute(*row) }
insert.finish
end
rescue DBI::DatabaseError => e
puts "Error #{e.err}: #{e.errstr}"
ensure
mysql.disconnect if mysql
postgres.disconnect if postgres
end
Our antiquely Perl-like script worked better than we expected — our application started right up with all of its data intact.
Has anybody out there encountered this need before? What kinds of solutions did you come up with?
Ask for Help
'How do I get growl output using ruby-growl in irb?'
Seen at a RubyConf lightning talk, ruby-growl (aka "g") is a library that provides a global "g" method that you can use to inspect objects much like Kernel#p. Instead of printing the output to console the output goes to Growl, a popular OS X global notifications tool.
require 'ruby-growl'
g = Growl.new "localhost", "ruby-growl",
["ruby-growl Notification"]
g.notify "ruby-growl Notification", "It Came From Ruby-Growl",
"Greetings!"
Trying this out we are seeing the following error message:
Errno::ECONNREFUSED: Connection refused - send(2)
Tried these instructions to enable incoming notifications but still doesn't work. Anyone?
'Keycastr' not working
KeyCastr is a Mac OS X application that displays your keystrokes in a small floating window much like growl - useful for overhead projection, and we use it around here for everyday pair programming to answer the question "What key did you just press?"
If you are having troubles getting this to work, try enabling the checkbox in System Preferences -> Universal Access in the "Seeing" tab called "Enable access for assistive devices"

Interesting Things

- Using uneval in SpiderMonkey JavaScript shell
When you are doing development in JavaScript using js shell and you try to inspect an object, all you can see is [object Object]
js> x = {foo: 'bar', baz: 1}
[object Object]
A convenient if obscure way to see more detail is uneval()
js> x = {foo: 'bar', baz: 1}
js> uneval(x)
({foo:"bar", baz:1})
President Obama today announced the establishment of an annual National Lab Day, a nationwide initiative to foster scientific and mathematic experimentation and invention in young Americans through collaborations between volunteers, students and educators. He also announced the opening of the National Lab Day website, a site that we had the honor of building with Jack Hidary, chairman of the National Lab Day and the Jack D. Hidary Foundation. The site connects scientists and engineers with students and classrooms needing their mentorship, their enthusiasm for science, and their spark.
National Lab Day will take place every year in the first week of May.
We are pleased to be able to contribute to this effort, designed to foster the kind of inquiry that brought us all into the world of technology. We encourage scientists and technologists across the country to sign up to volunteer. In the words of President Obama, "I want us all to think about new and creative ways to engage young people in science and engineering, whether it's science festivals, robotics competitions, fairs that encourage young people to create and build and invent -- to be makers of things, not just consumers of things."
Recent coverage:
- Wired Magazine: Making Science Cool: Educate to Innovate
- The New York Times: White House Begins Campaign to Promote Science and Math Education
- The National Science Teachers' Association: President Obama Announces National Lab Day Initiative
- ReadWriteWeb: Obama, Kids, & All Tomorrow's Web Apps: President Focuses on Tech Education
- Or see all Google News coverage
We hope that this initiative plants the seeds of innovation in the next generation of young scientists and entrepreneurs.
