Skip to content

Instantly share code, notes, and snippets.

View oivoodoo's full-sized avatar
🏠
Working from home

A oivoodoo

🏠
Working from home
View GitHub Profile
class InvitationsController < ApplicationController
before_filter :user_required
before_filter :account_required, :only => [:new, :create]
def new
@invitation = Invitation.new
end
def create
@oivoodoo
oivoodoo / control_answer.js
Created December 16, 2011 14:03
macros for control answers
for (i = 0; i < 261; i++) { window.setTimeout(function() { $('input[id=control_answer_primary_answer_na]').attr('checked', 'checked'); $('form').trigger('submit'); }, 300); }
@oivoodoo
oivoodoo / gist:1513967
Created December 23, 2011 11:45
Rails 2 / Rack Offline
# config.ru
use Rails::Offline, {} do
public_path = Pathname.new(Rails.public_path)
Dir[public_path.join("javascripts/*.js")].each do |file|
cache Pathname.new(file).relative_path_from(public_path)
end
network "/"
end
@oivoodoo
oivoodoo / gist:1517523
Created December 24, 2011 15:08
html: backbone model binding
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Backbone examples for model data binding</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="scripts/underscore.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/backbone.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/backbone.modelbinding.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/application.js" type="text/javascript" charset="utf-8"></script>
@oivoodoo
oivoodoo / gist:1517525
Created December 24, 2011 15:08
js: backbone data binding
var Post = Backbone.Model.extend();
var Views = {
Posts: {}
};
var post = new Post({
select: 'image',
radio: 'video',
text: 'title',
@oivoodoo
oivoodoo / mutex.js
Created December 28, 2011 12:05
mutex
var Mutex = function() {
this.queues = [];
this.locked = false;
};
Mutex.prototype = {
push: function(callback) {
var self = this;
this.queues.push(callback);
if (!this.locked) {
@oivoodoo
oivoodoo / capybara_webkit.rb
Created February 10, 2012 09:48
How to enable localStorage for scenarios.
Capybara.default_host = "lvh.me"
Capybara.app_host = "http://lvh.me:3003"
Capybara.server_port = 3003
Before('@html5') do
if [:webkit, :webkit_debug].include? Capybara.current_driver
page.driver.browser.set_attribute("LocalStorageEnabled")
# Single localStorage per scenario by generating subdomain
part = (1000 * rand()).to_i.to_s
@oivoodoo
oivoodoo / localStorage.js
Created February 22, 2012 13:09
localStorage for support normal work parts of code that's using the localStorage.
(function(global) {
if (_.isUndefined(global.localStorage)) {
global.localStorage = {
data: {},
getItem: function(key) {
return this.data[key] || null;
},
setItem: function(key, value) {
@oivoodoo
oivoodoo / fix.sh
Created April 19, 2012 11:04
path too long for autocompletion
cd /usr/local/Cellar/macvim/7.3-64/MacVim.app/Contents/Resources/vim/runtime/ftplugin
mv ruby.vim ruby.vim.bac
wget https://raw.github.com/vim-ruby/vim-ruby/master/ftplugin/ruby.vim
@oivoodoo
oivoodoo / timer.js
Created April 30, 2012 11:41
timer.js
//
// Example 1:
// function getData(success) {
// $.get('/data', success);
// };
//
// var timer = new Timer(getData);
// timer.start();
//
// Example 2: