Skip to content

Instantly share code, notes, and snippets.


Lucas Caton lucascaton

View GitHub Profile
View gist:124421b621d9a9bb6a89
Rails::Generator::Commands::Create.class_eval do
def template(relative_source, relative_destination, template_options = {})
file(relative_source, relative_destination, template_options) do |file|
# Evaluate any assignments in a temporary, throwaway binding.
vars = template_options[:assigns] || {}
b = template_options[:binding] || binding
# this no longer works, eval throws "undefined local variable or method `vars'"
# vars.each { |k, v| eval "#{k} = vars[:#{k}] || vars['#{k}']", b }
vars.each { |k, v| b.local_variable_set(:"#{k}", v) }
View gist:ed70a6950d53473cb573
$ rspec
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
😄 hi.
👾 Hi human, what's your name?
View text-expander_mysql-snippets.xml
<!-- Text Expander - MySQL snippets -->
<string>MySQL dump</string>
<string>mysqldump %fillpart:name=remote host%-h %fillpartend%-u %filltext:name=username:default=root% -p %filltext:name=database name:default=_development% &gt; %filltext:name=file name:default=dump.sql%</string>
lucascaton / facebook_archive_all_messages.js
Last active Aug 29, 2015
Facebook - Archive All Messages
View facebook_archive_all_messages.js
// Reference:
$("li._k- span.accessible_elem").each(function() {
View gist:190916
class CreateStuffs < ActiveRecord::Migration
def self.up
create_table :stuffs, :primary_key => :cod do |t|
t.integer :cod
t.integer :stuff_type_id
View Rails3.rb
class Posts < Application
provides :xml, :json
def index
@posts = Post.all
display @posts
#Este controller responde solicitações em html, xml, e json :)
lucascaton / XGH - PT-BR.txt
Last active Sep 10, 2015 — forked from banaslee/XGH - en.txt
eXtreme Go-Horse Process
View XGH - PT-BR.txt
1- Pensou, não é XGH.
XGH não pensa, faz a primeira coisa que vem à mente. Não existe
segunda opção, a única opção é a mais rápida.
2- Existem 3 formas de se resolver um problema, a correta, a errada e
a XGH, que é igual à errada, só que mais rápida.
View rubocop.txt
rubocop -D --only Style/ClassAndModuleChildren -a
git cam "[rubocop] Fixing 'Style/FirstParameterIndentation' cop"
View Class#attr_accessor alternative
class Class
def sets_gets(*args)
args.each do |arg|
define_method(arg) { eval "@#{arg}" }
define_method("#{arg}=".to_sym) { |param| eval "@#{arg}=param" }
class Person
lucascaton / iphone6.rb
Created Sep 23, 2015 — forked from alexeckermann/iphone6.rb
iPhone 6 Reservation Availability in Australia
View iphone6.rb
# iPhone 6 Reservation Availability in Australia
# !! Please use responsibly. Personal use only !!
# `ruby iphone6.rb` - list all available models in all stores
# `ruby iphone6.rb R405` - list available models for a specific store, Rundle Place in this example.
require 'open-uri'
require 'json'
"MG4A2X/A" => "iPhone 6 Space Grey 128GB",