Skip to content

Instantly share code, notes, and snippets.

View dwaynemac's full-sized avatar

Dwayne Macgowan dwaynemac

View GitHub Profile
validates_uniqueness_of :dni, :allow_nil => true, :allow_blank=>true, :message=>I18n.t('persona.dni_already_exists')
validates_uniqueness_of :dni, :scope=>[:nombres, :apellidos], :allow_nil => true, :message=>I18n.t('persona.person_already_exists')
# Para pasar la salida de recordmydesktop a avi
mencoder $1 -o $2 -nosound -ovc lavc
# app/models/person.rb
class Person < ActiveResource::Base
self.site = "http://api.oauth_protected_site.com"
end
# controller
@people = Person.find(:all)
@dwaynemac
dwaynemac / environment.rb
Created August 31, 2010 13:42
Achieven nested tags
config.gem "acts-as-taggable-on", :source => "http://gemcutter.org", :version => '2.0.0.rc1'
#
# == Arguments
# object: object to evaluate
# status: true if updates successfully false if failed
def jeditable_result(object, status,options = {})
param = options[:param] || params[:wants]
tokens = param.split('.')
result = object
if status
tokens.each do |t|
@dwaynemac
dwaynemac / tunnel_mysql.sh
Created December 16, 2010 18:47
Make ssh tunnel from mysql server to local machine on port 3007
ssh -L 3307:127.0.0.1:3306 USERNAME@SERVER
@dwaynemac
dwaynemac / app_template.rb
Created February 15, 2011 21:33
generate application (NEEDS UPDATE)
git :init
git :add => "."
git :commit => "-a -m 'fresh rails app'"
# Authentication
gem 'devise', '1.1.5'
gem 'devise_cas_authenticable', '1.0.0.alpha4'
gem 'cancan'
gem 'will_paginate'
@dwaynemac
dwaynemac / hash.rb
Created March 15, 2011 21:55
opcion 2
{
:codigo_unico => “AR BEL 1 2010 123 - 4”,
:first_name => “Dwayne”,
:last_name => “Macgowan”,
:global_status => “student”,
:school_id => 1,
:local_status => “former-student”,
:contact_info => [
{:type => “email”, :value => “dwaynemac@gmail.com”, :lable => “home”},
{:type => “email”, :value => “dwayne.macgowan@mdr”, :lable => “work”},
@dwaynemac
dwaynemac / .bashrc
Created April 21, 2011 17:16
Bootstrap Ubuntu 10.10 Live-USB for Ruby development
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
if [[ -n "$PS1" ]]; then
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@dwaynemac
dwaynemac / git_cheatsheet.rdoc
Created August 9, 2011 22:34
RDoc explicando el workflow

Git CheatSheet

  • Corregir mi último commit:

    git commit –amend

  • Cambiar de branch:

    git checkout branch_name