Skip to content

Instantly share code, notes, and snippets.

View nebiros's full-sized avatar

Juan Alvarez nebiros

View GitHub Profile
@nebiros
nebiros / jquery.validator.js
Created December 5, 2011 15:13
First version of tiny validator that I made with Lopez :)
/**
* Valida campos usando un objeto, evalua expresiones regulares, si el campo
* es requerido o no, mensajes por cada campo, tambien crea un elemento <span>
* al lado del campo que tiene errores con el mensaje de error.
*
* // Ejemplo
* var reglas = {
* 'elementos': {
* 'formPlanillaenlinea:tiposIngresoTemp': {
* 'requerido': true, // Puede ser un boolean o un objeto si es necesario evaluar otro campo asociado a este: { 'el': '#formPlanillaenlinea\\:novedadVST', 'selector': ':checked' }
@nebiros
nebiros / define_class.js
Created December 7, 2011 19:28
JavaScript ALA OOP
/**
* defineClass( ) -- a utility function for defining JavaScript classes.
*
* This function expects a single object as its only argument. It defines
* a new JavaScript class based on the data in that object and returns the
* constructor function of the new class. This function handles the repetitive
* tasks of defining classes: setting up the prototype object for correct
* inheritance, copying methods from other types, and so on.
*
* The object passed as an argument should have some or all of the
@nebiros
nebiros / click_tab.js
Created February 8, 2012 23:09
click on tab workaround for titanium mobile
var newPetitionListener = function (e) {
newPetition(win, params);
}
, cameraView = Ti.UI.createView({
width: 95,
height: 50,
bottom: 0
});
cameraView.addEventListener("click", newPetitionListener);
@nebiros
nebiros / multi_replace.js
Created March 15, 2012 14:58
javascript multi-replace
var str = "/activity_sets/:activity_set_id/activity_set_annotations/:id/edit John Smith"
, repl = {
"11": ":activity_set_id",
"1": ":id",
"$2, $1": new RegExp("(John)\\s(Smith)", "gi")
};
function multi_replace(str, repl) {
if (!str) return str;
@nebiros
nebiros / fuse4x.rb
Created March 22, 2012 01:40
fuse4x formula fixed for AM_ICONV error
require 'formula'
class Fuse4x < Formula
homepage 'http://fuse4x.org/'
url 'https://github.com/fuse4x/fuse.git', :tag => "fuse4x_0_9_0"
version "0.9.0"
depends_on 'gettext'
depends_on 'fuse4x-kext'
depends_on "automake" => :build
@nebiros
nebiros / ubuntu_rbenv_install_how_to.txt
Created March 24, 2012 18:55
how to install ruby's rbenv in ubuntu
$ sudo aptitude update
$ sudo aptitude install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libncurses5-dev automake libtool bison subversion
$ cd
$ git clone git://github.com/sstephenson/rbenv.git .rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ git clone git://github.com/sstephenson/ruby-build.git
$ cd ruby-build
$ sudo ./install.sh
$ rbenv install 1.9.3-p125
@nebiros
nebiros / gist:2649031
Created May 9, 2012 21:27
gegl 0.2 compilation error
==> Installing gimp dependency: gegl
==> Downloading ftp://ftp.gimp.org/pub/gegl/0.2/gegl-0.2.0.tar.bz2
Already downloaded: /Users/nebiros/Library/Caches/Homebrew/gegl-0.2.0.tar.bz2
==> ./configure --disable-docs --disable-debug --prefix=/usr/local/Cellar/gegl/0.2.0
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
@nebiros
nebiros / .htaccess
Created May 23, 2012 14:17
osx localhost apache's config
# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
@nebiros
nebiros / Gemfile
Created May 23, 2012 15:58
rails + unicorn + rbenv + init.d daemon
group :production do
gem "unicorn"
end
@nebiros
nebiros / unicorn.rake
Created June 5, 2012 17:26
rails rake tasks for managing unicorn server instances + rbenv
ENV["RAILS_ENV"] ||= "production"
module UnicornServer
# http://unicorn.bogomips.org/Unicorn/Configurator.html
CONFIG_PATH = File.join(Rails.root, "config", "unicorn.rb")
PID_PATH = File.join(Rails.root, "tmp", "pids", "unicorn.pid")
RBENV = %x[which rbenv].strip
DAEMON = "bundle exec unicorn_rails"
DAEMON_OPTS = "-c #{CONFIG_PATH} -E #{ENV["RAILS_ENV"]} -D"