Skip to content

Instantly share code, notes, and snippets.

View hernan's full-sized avatar

Hernan Fernandez hernan

  • Argentina
View GitHub Profile
@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
*/
@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 / 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 / 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!
#! /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 / code.rb
Created September 17, 2011 21:33 — forked from caius/code.rb
Useful Regular Expressions in Ruby's URI Library
require "uri"
(URI::REGEXP.constants - ["PATTERN"]).each do |rc|
puts "#{rc}: #{URI::REGEXP.const_get(rc)}"
end
URI::REGEXP::PATTERN.constants.each do |pc|
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}"
end
@hernan
hernan / mini_shoulda.rb
Created October 3, 2011 21:50
keep the same shoulda syntax with minitest
#
# https://github.com/padrino/padrino-framework/blob/master/padrino-core/test/mini_shoulda.rb
#
gem 'minitest'
require 'minitest/spec'
require 'minitest/autorun'
require 'mocha' # Load mocha after minitest
begin
@hernan
hernan / ba-backbone-module.js
Created October 10, 2011 19:13 — forked from cowboy/ba-backbone-module.js
Idea for a Backbone module system (allowing modules to be accessed across multiple files, possibly loaded out of order). Inspired by https://gist.github.com/1202511
/*!
* Backbone Module Manager - v0.1pre - 9/9/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function ModuleManager(fn) {
@hernan
hernan / LICENSE.txt
Created November 2, 2011 13:01 — forked from jed/LICENSE.txt
linkify @mentions and #hashtags in a tweet
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@hernan
hernan / LICENSE.txt
Created November 2, 2011 13:01 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE