Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Simple Line Graph using SVG and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="all" />
@lucassus
lucassus / factory_girl_performance.rb
Created October 9, 2012 08:01
Find slow factories
if ENV['FACTORY_GIRL_PERFORMANCE']
slow_factories = {}
# Look for slow factories
# @see: https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#activesupport-instrumentation
ActiveSupport::Notifications.subscribe("factory_girl.run_factory") do |name, start, finish, id, payload|
execution_time_in_seconds = finish - start
key = :"#{payload[:strategy]} :#{payload[:name]}"
slow_factories[key] ||= []
@lucassus
lucassus / shared_context.rb
Created October 9, 2012 07:47
Smart fxitures for mongoid and factory_girl
Before
$ rspec spec/ --tag api
Run options: include {:api=>true}
..........................................
Finished in 3 minutes 59.73 seconds
After
@lucassus
lucassus / spec.rb
Created September 12, 2012 10:18
Testing indexes for mongoid
describe 'indexes' do
it { should have_index_for({ company: 1, advisor_company: 1 }).with_options(unique: true) }
describe 'unique index for :company and :advisor_company' do
let!(:first_advisor_company) { create(:company, :advisor) }
let!(:second_advisor_company) { create(:company, :advisor) }
let!(:company) { create(:company) }
before { Rails::Mongoid.create_indexes("app/models/company/**/*.rb") }
index 549b6e0..55d1c5c 100644
--- a/vendor/assets/javascripts/jquery.mockjax.js
+++ b/vendor/assets/javascripts/jquery.mockjax.js
@@ -328,8 +328,8 @@
@@ -328,8 +328,8 @@
}
// Successful response
/usr/local/lib/ruby/1.9.1/openssl/ssl-internal.rb:121:in `post_connection_check'
/usr/local/lib/ruby/1.9.1/net/http.rb:680:in `connect'
/usr/local/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
/usr/local/lib/ruby/1.9.1/net/http.rb:626:in `start'
/usr/local/lib/ruby/1.9.1/net/http.rb:1168:in `request'
/usr/local/lib/ruby/1.9.1/net/http.rb:978:in `post'
vendor/bundle/ruby/1.9.1/gems/hoptoad_notifier-2.4.11/lib/hoptoad_notifier/sender.rb:37:in `send_to_hoptoad'
vendor/bundle/ruby/1.9.1/gems/hoptoad_notifier-2.4.11/lib/hoptoad_notifier.rb:128:in `send_notice'
vendor/bundle/ruby/1.9.1/gems/hoptoad_notifier-2.4.11/lib/hoptoad_notifier.rb:104:in `notify_or_ignore'
vendor/bundle/ruby/1.9.1/gems/hoptoad_notifier-2.4.11/lib/hoptoad_notifier/rack.rb:29:in `rescue in call'
describe('built-in matchers', function() {
describe('toBeTruthy', function() {
it('passes if subject is true', function() {
expect(true).toBeTruthy();
expect(false).not.toBeTruthy();
});
});
describe('toBeFalsy', function() {
it('passes if subject is false', function() {
def shuffled_users
shuffled = users.sort_by { rand }
while shuffled == users
shuffled = users.sort_by { rand }
end
shuffled
end
describe('when the code does not exists in the collection', function() {
var $browser;
beforeEach(function() {
$browser = scope.$service('$browser');
});
describe('when validation fails', function() {
beforeEach(function() {
var validationResponse = 'validation fail';
ruby-1.9.2-p180$ cat xvfb
#!/bin/bash
XVFB=/usr/bin/Xvfb
XVFBARGS="$DISPLAY -ac -screen 0 1024x768x16"
PIDFILE=/tmp/xvfb_${DISPLAY}.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
/sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."