Skip to content

Instantly share code, notes, and snippets.

View rodrigopinto's full-sized avatar

Rodrigo Pinto rodrigopinto

  • Berlin, Germany
  • 09:26 (UTC +02:00)
View GitHub Profile
@patrickberkeley
patrickberkeley / pages_controller.rb
Created December 7, 2008 02:10
using Paperclip for multiple attachments and displaying them using the method described in Advanced Rails Recipe #13
class PagesController < ApplicationController
before_filter :login_required, :except => [ :show ]
# GET /pages
# GET /pages.xml
def index
@pages = Page.find(:all)
respond_to do |format|
format.html # index.html.erb
@rajib
rajib / generate slug
Created January 19, 2010 07:18
generate_slug.rb
class Post < ActiveRecord::Base
before_validation :generate_slug
def generate_slug
self.slug = self.title.dup if self.slug.blank?
self.slug.slugorize!
end
end
and in lib/core_extensions/string.rb
@rafaelp
rafaelp / empreenda-1.txt
Created September 7, 2010 14:11
Notas sobre empreendedorismo
Vasculhando a papelada em casa encontrei este rascunho.
Acho que foi escrito na palestra pública pré-Empretec.
Não me preocupei em corrigir concordância, quis registrar como foi escrito na ocasião.
***
"Ideia de Negócio" é diferente de "Oportunidade de Negócio"
Empreender
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@rodrigopinto
rodrigopinto / long_day_part_one.rb
Created November 24, 2011 12:18
A long journey of day at the office
### THIS IS PART OF A QUERY
def conditions_for_regioncode(region_ids)
regions = []
region_ids.each do |region|
regions << "reg.regioncode = '#{region}'"
end
"(#{regions.join(' OR ')})"
end
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet
@fnichol
fnichol / README.md
Created February 26, 2012 01:23
A Common .ruby-version File For Ruby Projects

A Common .ruby-version File For Ruby Projects

Background

I've been using this technique in most of my Ruby projects lately where Ruby versions are required:

  • Create .rbenv-version containing the target Ruby using a definition name defined in ruby-build (example below). These strings are a proper subset of RVM Ruby string names so far...
  • Create .rvmrc (with rvm --create --rvmrc "1.9.3@myapp") and edit the environment_id= line to fetch the Ruby version from .rbenv-version (example below).

Today I learned about another Ruby manager, rbfu, where the author is using a similar technique with .rbfu-version.

@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
sudo ifconfig en1 ether `openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`