Skip to content

Instantly share code, notes, and snippets.

View hernan's full-sized avatar

Hernan Fernandez hernan

  • Argentina
View GitHub Profile
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@hernan
hernan / jqplugin.js
Created April 30, 2011 15:09
jQuery plugin boilerplate
// jQuery Plugin Boilerplate
// A boilerplate for jumpstarting jQuery plugins development
// version 1.1, May 14th, 2011
// by Stefan Gabos
// http://stefangabos.ro/jquery/jquery-plugin-boilerplate-revisited/#requirements
// remember to change every instance of "pluginName" to the name of your plugin!
(function($) {
// here we go!
@hernan
hernan / basic session expire
Created August 13, 2010 23:59
check activity time
before_filter :session_expiry, :except => [:login, :logout]
before_filter :update_activity_time, :except => [:login, :logout]
def session_expiry
@time_left = (session[:expires_at] - Time.now).to_i
unless @time_left > 0
reset_session
flash[:error] = 'Sua sessão expirou. Favor entrar novamente.'
redirect_to :controller => 'login', :action => 'login'
end
@hernan
hernan / base64.js
Created June 30, 2010 23:37 — forked from timcharper/base64.js
Base 64 encode/decode
// adapted from here: http://ostermiller.org/calc/encode.html
var base64 = {};
(function () {
var END_OF_INPUT = -1,
base64Chars = new Array(
'A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X',
'Y','Z','a','b','c','d','e','f',
@hernan
hernan / application.js
Created August 27, 2009 02:53 — forked from nicalpi/application.js
Easy Ajax replacement for remote_functions
/*
Jquery and Rails powered default application.js
Easy Ajax replacement for remote_functions and ajax_form based on class name
All actions will reply to the .js format
Unostrusive, will only works if Javascript enabled, if not, respond to an HTML as a normal link
respond_to do |format|
format.html
format.js {render :layout => false}
end
*/