Skip to content

Instantly share code, notes, and snippets.

@alindeman
alindeman / Gemfile
Created June 25, 2020 00:52 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@alindeman
alindeman / .Xresources
Created March 24, 2019 14:15 — forked from cocopon/dark.Xresources
.Xresources for Iceberg
! special
*.foreground: #d2d4de
*.background: #161821
*.cursorColor: #d2d4de
! black
*.color0: #161821
*.color8: #6b7089
! red
#!/usr/bin/sudo sh
## ruby_revealer.sh -- decrypt obfuscated GHE .rb files. 2.0.0 to 2.3.1+.
## From `strings ruby_concealer.so`:
##
## > This obfuscation is intended to discourage GitHub Enterprise customers
## > from making modifications to the VM.
##
## Well, good, as long as its not intended to discourage *me* from doing this!
@alindeman
alindeman / gist:5050851
Last active December 14, 2015 07:29 — forked from vanstee/gist:5050689
class Item
def does_something(publishing_house = PublishingHouse.new)
publishing_house.publish(@document)
end
end
it 'publishes the document' do
publishing_house = stub('PublishingHouse')
publishing_house.should_receive(:publish).with(document)
[47, 46, 45, ...].each do |i|
validates_numericality_of :"size_#{i}_quantity"
define_method :"size_#{i}_quantity" do
if self.variants.find_by_size(i)
self.variants.count_on_hand
else
0
end
end
require 'spec_helper'
describe AController do
describe 'GET index' do
it 'returns the full list' do
Model.should_receive(:find).with(:all)
get :index
response.code.should eq ("200")
def upcase(text):
return text.upper()
@upcase
def words(text):
return ' '.join(text)
class Animal
def initialize(legs)
@legs = legs
end
def legs_in_animal
@legs
end
end
@alindeman
alindeman / test.rb
Created January 21, 2011 17:08 — forked from caleywoods/test
def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil
nil.some_method_nil_doesnt_know_about
rescue Exception => ex
puts ex.class
end
test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil
@alindeman
alindeman / gist:761389
Created December 31, 2010 22:35 — forked from radar/gist:756790
def self.factory(plugin, &block)
candidates = self.plugin_paths.map do |path|
Dir["#{path}/#{plugin.to_s.downcase}.rb"][0]
end
candidate = candidates.detect(&:any?)
if candidate
require candidate
Plugin.const_get(plugin.to_s.capitalize.to_sym).new(&block)
else
raise YourSystem::PluginNotFound, "The #{plugin} plugin could not be loaded"