Skip to content

Instantly share code, notes, and snippets.

RSpec.configure do |config|
config.before(:suite) do
ActiveRecord::Base.observers.disable :all
end
end
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
var webpage = require('webpage'),
q = require('sdk/core/promise');
var page = webpage.create();
var render = function(){
page.render("~/google-image.png");
};
var modify = function(){
@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];
@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>"
function encrypt(text){
var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq')
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq')
var dec = decipher.update(text,'hex','utf8')
@bernardeli
bernardeli / poodle.md
Last active August 29, 2015 14:07
SSLv3 POODLE nginx update

Test if your domain is vulnerable

openssl s_client -connect scouterecruitstaging.com:443 -ssl3

If you see a long response whereby the server certificate is shown, you do need to action.

If you see something like the next line, your server is fine:

58003:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
function git () {
case "$PWD"; in
/path/to/work/repos/*)
command git -c user.email=you@work.com "$@"
;;
*)
command git "$@"
;;
esac
}
class Foo
end
Foo.class_eval do
def bar
"Bar from class eval"
end
end
Foo.instance_eval do
#!/usr/bin/env ruby
# pingpongninja_expected_results -- simulate a series of games on pingpongninja
#
# algorithm extracted from
# https://github.com/jdennes/pingpongapp/blob/master/pingpong/rankings.py
def new_ranks(rank1, rank2, points1, points2)
decay_factor = 10
game_ranking_points = (rank1 + rank2) / 2
ranking_change1 = game_ranking_points + (points1 - points2) * 100 / [points1, points2].max
ranking_change2 = game_ranking_points + (points2 - points1) * 100 / [points1, points2].max