Skip to content

Instantly share code, notes, and snippets.

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
}
sudo a2enmod rewrite
in public/.htaccess
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{DOCUMENT_ROOT}/cache/$1.html -f
RewriteRule ^(.*)$ /cache/$1.html
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
@bernardeli
bernardeli / benchmark.rb
Created April 23, 2011 17:12
benchmark for named queues
require 'spec/spec_helper'
require 'logger'
require 'benchmark'
# Delayed::Worker.logger = Logger.new('/dev/null')
Benchmark.bm(10) do |x|
Delayed::Job.delete_all
n = 3000*3
n.times { "foo".delay.length }
@bernardeli
bernardeli / callback.rb
Created August 17, 2011 02:59
facebook + devise
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
# You need to implement the method below in your model
@user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
sign_in_and_redirect @user, :event => :authentication
else
session["devise.facebook_data"] = env["omniauth.auth"]