Skip to content

Instantly share code, notes, and snippets.

# los requires no son necesarios dentro de rails, obviamente :p
require 'rubygems'
require 'active_support'
# format_event retorna un hash formateado a como querés, por lo cual al resultado le podés hacer .to_json
def format_event(event_hash)
# Si no hay imagenes retorna un hash con info "vacía"
return {:totalImages => '0', :images => {}} if (event_hash['images'].nil? || event_hash['images']['image'].nil?)
# por legibilidad está en varias líneas :p
{
# frnz's Ruby on Rails template
############## plugin commands #################
# RSpec is the original Behaviour Driven Development framework for Ruby.
plugin 'rspec',
:git => "git://github.com/dchelimsky/rspec.git"
# The world's greatest templating system
plugin 'haml',
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
#!/bin/bash
#
# Install rmagick without fink or macports
# Shameless copy from: http://www.agileanimal.com/2009/08/11/imagemagick-and-rmagick-on-leopard-and-other-large-white-cats
#
# Requirements: Mac OS X >= 10.5.4, XCode 3.1, X11
#Install freetype
curl -O http://mirror.csclub.uwaterloo.ca/nongnu/freetype/freetype-2.3.9.tar.gz
@frnz
frnz / ssh_key.sh
Created October 31, 2010 08:49 — forked from jpablobr/ssh_key.sh
#!/bin/bash
scp ~/.ssh/id_rsa.pub $1:~
ssh $1 "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod -R 600 ~/.ssh/* && cat ~/id_rsa.pub >> ~/.ssh/authorized_keys && rm ~/id_rsa.pub"
# I get the images from the autotest-growl gem, so I put this on my gemfile:
# (If you want to use another images you can find an example here: http://szeryf.wordpress.com/2007/07/30/way-beyond-cool-autotest-growl-doomguy/)
gem "rspec"
gem "rspec-rails", "~> 2.0.1"
gem "ZenTest"
gem "autotest"
gem "autotest-rails"
gem "autotest-growl" # <= here it is
gem "ruby-debug"
" Save as conceal.vim at ~/.vim/bundle/ruby-conceal/after/syntax/ruby if you
" use Pathogen or at ~/.vim/after/syntax/ruby otherwise
if !has('conceal')
finish
endif
syntax keyword rubyControl not conceal cchar=¬
syntax keyword rubyKeyword lambda conceal cchar=λ
set conceallevel=2
@frnz
frnz / diego_datamapper.rb
Created December 9, 2010 03:19
Diego's version:
class User
include DataMapper::Resource
has n, :projects
end
class Project
include DataMapper::Resource
belongs_to :user, :key => true
has n, :steps
@frnz
frnz / diego.rb
Created January 7, 2011 13:25
Diego
# Primero te recomiendo hacer un método 'encript' así:
def encript(hash)
# Devuelve el mismo hash, pero haciéndole digest al password
hash[:password] = Digest::MD5.hexdigest(hash[:password])
return hash
end
# De esa manera podés hacer esto:
post '/signup' do
@frnz
frnz / boludo.rb
Created January 7, 2011 16:21
Hash
{:password=>"39c8e9953fe8ea40ff1c59876e0e2f28", "username"=>"mitasdf", "password"=>"sdfsdfsdfsdf", "email"=>"[email protected]"}
Es que pensé que se usaba [:password] en params (como rails). Nada más usá "password" en lugar de :password:
def encript(hash)
# Devuelve el mismo hash, pero haciéndole digest al password
hash["password"] = Digest::MD5.hexdigest(hash["password"])
return hash
end