Skip to content

Instantly share code, notes, and snippets.

class Leaky
def wow
locations = [1,2,3]
locs = Hash.new(0)
locations.each do |x|
number = 10
p number
end
p number
end
class User < ActiveRecord::Base
attr_accessible :email, :first_name, :last_name, :username
before_validation :lol, :on => :create
before_validation :yay, :on => :create
before_validation :yay, :on => :update
def lol
puts "Running lol"
end
#!/usr/bin/env bash
apt-add-repository -y ppa:brightbox/ruby-ng
apt-get -y update
apt-get -y install build-essential
apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev
apt-get -y install ruby1.9.3 ruby-switch
ruby-switch --set ruby1.9.1
gem install chef ruby-shadow --no-ri --no-rdoc
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@gnufied
gnufied / after_commit_patch.rb
Created July 30, 2012 08:07
after_commit_patch.rb
#WARNING do not load this file in environments other than test
module AfterCommitPatch
def transaction(options = {})
rolled_back = false
return_value = nil
begin
return_value = super
rescue ActiveRecord::Rollback => e
puts e.message
puts e.backtrace
loop do
begin
puts "Whoa"
sleep(2)
rescue Exception => e
puts "wtf"
end
end
cloudips-create.rb
6: c.flag [:i, "count"]
9: c.flag [:n, :name]
12: c.flag [:t, :'port-translators']
cloudips-update.rb
6: c.flag [:r, "reverse-dns"]
12: c.flag [:n, :name]
15: c.flag [:t, :'port-translators']
@gnufied
gnufied / compile_rspec.el
Created December 6, 2012 09:14
compile_rspec.el
(require 'cl) ; If you don't have it already
(defun* get-closest-gemfile-root (&optional (file "Gemfile"))
"Determine the pathname of the first instance of FILE starting from the current directory towards root.
This may not do the correct thing in presence of links. If it does not find FILE, then it shall return the name
of FILE in the current directory, suitable for creation"
(let ((root (expand-file-name "/"))) ; the win32 builds should translate this correctly
(loop
for d = default-directory then (expand-file-name ".." d)
if (file-exists-p (expand-file-name file d))
#!/usr/bin/env ruby
require "fileutils"
require "set"
class GetShitDone
attr_accessor :hosts_file
def initialize
@hosts_file = "/etc/hosts"
@banned_sites_file = "#{ENV['HOME']}/.banned_sites"
require "readline"
require "pry"
require "fileutils"
class CompileObjectiveC
attr_accessor :code_lines
TMP_DIR = "/tmp"
def initialize