Skip to content

Instantly share code, notes, and snippets.

View saulius's full-sized avatar
:octocat:
java.lang.OutOfMemoryError

Saulius Grigaliunas saulius

:octocat:
java.lang.OutOfMemoryError
View GitHub Profile
We couldn’t find that file to show.
{
"npanxx": {
"map": "function(doc) { emit(doc.npanxx, doc) }"
},
"all": {
"map": "function(doc) { emit(null, doc) }"
}
}
@saulius
saulius / dasd
Created February 13, 2009 16:25
sdadasdsadxfsdf
@saulius
saulius / dasd
Created February 13, 2009 16:25
sdadasdsadxfsdf
@saulius
saulius / dasd
Created February 13, 2009 16:25
sdadasdsadxfsdf
@saulius
saulius / dasd
Created February 13, 2009 16:25
sdadasdsadxfsdf
@saulius
saulius / gist:217627
Created October 24, 2009 17:06 — forked from dhh/gist:45076
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain

Parallelize Your RSpec Suite

We all have multi-core machine these days, but most rspec suites still run in one sequential stream. Let's parallelize it!

The big hurdle here is managing multiple test databases. When multiple specs are running simultaneously, they each need to have exclusive access to the database, so that one spec's setup doesn't clobber the records of another spec's setup. We could create and manage multiple test database within our RDBMS. But I'd prefer something a little more ... ephemeral, that won't hang around after we're done, or require any manual management.

Enter SQLite's in-memory database, which is a full SQLite instance, created entirely within the invoking process's own memory footprint.

(Note #1: the gist for this blog is at http://gist.github.com/108780)

module ApplicationHelper
def javascript_parameters
params = { :csrf_token => form_authenticity_token }
if defined? collection
params.update(:resource => { :new => new_resource_url, :collection => collection_url })
else
if defined? resource
if resource.new_record?
def valid?(*gws)
res = true
gws.flatten.each { |g|
check = g.valid?
res = res && check
}
return res
end