Skip to content

Instantly share code, notes, and snippets.

View hilios's full-sized avatar
🛠️
Breaking stuff

Edson Hilios hilios

🛠️
Breaking stuff
View GitHub Profile
@hilios
hilios / pyenv.sh
Created May 21, 2013 19:43
Execute shell command getting aware of pythonbrew configuration
# http://joshuawherring.com/blog/?p=2361
source "/path/to/.pythonbrew/etc/bashrc"
VENV=$2
PY=$1
pythonbrew use ${PY}
echo "Using ${PY}"
pythonbrew venv use ${VENV}
echo "Venv ${VENV}"
shift 2
echo "Executing $@ in ${VENV}"
@hilios
hilios / rAF.js
Created April 22, 2013 23:34 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@hilios
hilios / README.md
Created November 29, 2012 14:12
Mouse compass

Mouse compass

Display the current mouse region inside a DOM element just like a compass. See in action!

@hilios
hilios / grant.sql
Created October 29, 2012 16:14
Create DB and User in MySQL
--
CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
-- Where % is the wildcard for any host
GRANT ALL PRIVILEGES ON dbname.* TO 'user'@'host' IDENTIFIED BY 'password' WITH GRANT OPTION;
-- Update users privileges access
FLUSH PRIVILEGES;
@hilios
hilios / authorization_request.rb
Created October 19, 2012 20:38
CanCan authorization Responder
require 'cancan/ability'
# A cleaner implementation of CanCan #load_and_authorize_resource method.
# Everytime you use the #respond_with method, send the given resources to check
# the authorizations.
module AuthorizationResponder
def initialize(controller, resources, options={})
super
@authorize_with = options.delete(:authorize_with)
@skip_authorization = options.delete(:skip_authorization)
end
@hilios
hilios / Rakefile
Created August 2, 2012 18:26 — forked from jeffreyiacono/Rakefile
rake task for precompiling assets using sprockets within a sinatra app + view helpers
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
@hilios
hilios / gist:2962111
Created June 20, 2012 20:46 — forked from travis/gist:1084767
testing facebook connect with capybara and rspec
require 'mogli'
module FacebookIntegrationHelpers
shared_context "with unconnected facebook user" do
let(:fb_user) { create_test_user(installed: false) }
after { fb_user.destroy }
end
def app_client
Mogli::AppClient.new(AppConfig.facebook.access_token, AppConfig.facebook.app_id)
@hilios
hilios / zone.sh
Created June 12, 2012 14:43
Connect to zone
#!/bin/bash
USER="username"
HOST=$1
BRIDGE=FALSE
while getopts "u:h:b": OPT; do
# echo "$OPT=$OPTARG"
case ${OPT} in
u) USER=${OPTARG};;
b) BRIDGE=TRUE;;
@hilios
hilios / .vimrc
Last active August 2, 2016 16:59
vimrc - Personalizado
set cursorline
set hlsearch
set number
set ruler
set shiftwidth=2
set tabstop=2
syntax on
@hilios
hilios / nested_form.js.coffee
Created May 9, 2012 21:28
Nested Form Helpers
$('[data-nested="add"]').live 'click', (e)->
e.preventDefault()
association = $(this).data('association')
fields = $(this).data('fields')
target = $("[data-association='#{association}_fields']")
regexp = new RegExp('new_' + association, 'g');
new_id = new Date().getTime();
fields = fields.replace(regexp, "new_" + new_id);