Skip to content

Instantly share code, notes, and snippets.

@bernardeli
bernardeli / clever-tab.vim
Created August 25, 2014 01:04
clever-tab.vim
function! CleverTab(type)
if a:type=='omni'
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
let g:stop_autocomplete=1
return "\<TAB>"
elseif !pumvisible() && !&omnifunc
return "\<C-X>\<C-O>\<C-P>"
endif
elseif a:type=='keyword' && !pumvisible() && !g:stop_autocomplete
return "\<C-X>\<C-N>\<C-P>"
@bernardeli
bernardeli / redirection.js
Created June 19, 2014 03:48
Redirection JS
'use strict';
var express = require('express'),
request = require('superagent'),
app = express(),
config = require('./config');
app.get('*', function(req, res){
var cloudfrontUrl = config[req.url];
var webpage = require('webpage'),
q = require('sdk/core/promise');
var page = webpage.create();
var render = function(){
page.render("~/google-image.png");
};
var modify = function(){
click_on "Add new person"
last_nested_fields = all('.fields').last
within(last_nested_fields) do
fill_in "Name", with: "Ricardo"
fill_in "Age", with: 27
end
RSpec.configure do |config|
config.before(:suite) do
ActiveRecord::Base.observers.disable :all
end
end
@bernardeli
bernardeli / gist:2295266
Created April 3, 2012 20:25
sed to replace FactoryGirl old style to the new one on OS X
sed -i.bkp s/Factory\(\:/FactoryGirl.create\(\:/g spec/**/*.rb
sed -i.bkp s/Factory\ \:/FactoryGirl.create\ \:/g spec/**/*.rb
sed -i.bkp s/Factory\.build\ \:/FactoryGirl.build\ \:/g spec/**/*.rb
sed -i.bkp s/Factory\.build\(\:/FactoryGirl.build\(\:/g spec/**/*.rb
sed -i.bkp s/Factory\.next/FactoryGirl\.generate/g spec/**/*.rb
rm -rf spec/**/*.bkp
@bernardeli
bernardeli / call_from_url_helpers.rb
Created March 22, 2012 01:22
include url_helpers
class Foo
def do_something
...
Rails.application.routes.url_helpers.my_awesome_routing_path
Rails.application.routes.url_helpers.my_awesome_routing_url(:host => 'http://your-domain.com')
...
end
end
@bernardeli
bernardeli / caller.js
Created March 19, 2012 01:36
konami code js
$(window).konami(function(){
$(".goku").show();
$(".goku").delay(2000).fadeOut();
});
@bernardeli
bernardeli / build.rb
Created February 16, 2012 03:28
rake build
desc "Run all tests"
task :build do
system "rm rerun.txt"
raise 'Error on rspec. Fix it, bro' unless system "bundle exec rspec spec"
raise 'Error on cucumber plain. Fix it, bro' unless system "bundle exec cucumber"
end
@bernardeli
bernardeli / .zshrc
Created October 20, 2011 17:03
highlighting code for keynote with highlight
first: brew install highlight
second: add to your .zshrc (or .bashrc)
function hlr {
filename=`echo $1 | cut -d . -f 1`
highlight --syntax ruby -k Menlo -K 20 -O rtf -s edit-xcode $1 > $filename.rtf
}
third: it will generate a .rtf file. just open and copy the highlighted code and add to your Keynote talk.