Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
echo -e "\x1B[0mCOLOR_NC (No color)"
echo -e "\x1B[1;37mCOLOR_WHITE\t\x1B[0;30mCOLOR_BLACK"
echo -e "\x1B[0;34mCOLOR_BLUE\t\x1B[1;34mCOLOR_LIGHT_BLUE"
echo -e "\x1B[0;32mCOLOR_GREEN\t\x1B[1;32mCOLOR_LIGHT_GREEN"
echo -e "\x1B[0;36mCOLOR_CYAN\t\x1B[1;36mCOLOR_LIGHT_CYAN"
echo -e "\x1B[0;31mCOLOR_RED\t\x1B[1;31mCOLOR_LIGHT_RED"
echo -e "\x1B[0;35mCOLOR_PURPLE\t\x1B[1;35mCOLOR_LIGHT_PURPLE"
echo -e "\x1B[0;33mCOLOR_YELLOW\t\x1B[1;33mCOLOR_LIGHT_YELLOW"
echo -e "\x1B[1;30mCOLOR_GRAY\t\x1B[0;37mCOLOR_LIGHT_GRAY"
class Brand < ActiveRecord::Base
validates_with BrandValidator
# ...
end
#!/bin/bash
files=`find . -name "_*.haml" -or -name "*_helper.rb" -or -name "_*.erb"`
count=`egrep -o @ $files | wc -l`
echo "$count kittens cried because of this code"
@urbanautomaton
urbanautomaton / ping.txt
Created April 24, 2012 11:20
routing info to github.com
--- github.com (207.97.227.239) ping statistics ---
100 packets transmitted, 68 packets received, 32.0% packet loss
round-trip min/avg/max/stddev = 88.800/123.325/383.601/52.514 ms
traceroute to github.com (207.97.227.239), 64 hops max, 52 byte packets
1 my.router (192.168.1.1) 2.774 ms 0.703 ms 0.691 ms
2 * * *
3 10.1.2.161 (10.1.2.161) 58.359 ms 15.083 ms 17.369 ms
4 linx1-lond-thn.virtual1.co.uk (195.66.224.109) 16.321 ms 13.685 ms *
5 79.98.160.100 (79.98.160.100) 34.895 ms
#!/bin/bash
set -e
project=$1
if [ -n "$2" ]; then
session_name=$2
else
session_name=$1
fi
directory="${HOME}/dev/${project}"
class A
attr_reader :fish
attr_writer :fish
private :fish=
def set_fish
fish = :carp
nil
end
end
@urbanautomaton
urbanautomaton / dci_benchmark.rb
Last active December 10, 2015 12:48
Attempt to separate out method call cost in DCI benchmark
require 'rubygems'
require 'delegate'
require 'benchmark'
include Benchmark
class ExampleClass
def foo; 42; end
end
require 'rspec'
class Thing; end
describe "change matcher" do
it "behaves counterintuitively with classes" do
thing = nil
expect {
thing = Thing
}.to change {
@urbanautomaton
urbanautomaton / extend_monkeypatch.rb
Last active December 10, 2015 20:08
Method cache? What method cache?
class Object
alias_method :orig_extend, :extend
def extend(mod, *args)
puts "Extending #{self.class} with #{mod}"
orig_extend(mod, *args)
end
end
#unverified.list obtained from https://gist.github.com/raw/865b05630be54544ca72/a1a0c114d5eab0e65efccc941ca013fd06e6f43c/unverified.list
File.readlines("unverified.list").map do |line|
gem_file = line.split.last.gsub("./", "")
m = gem_file.match(/(.*)-((?:\d+.)*\d+.*)\.gem/)
[m[1], m[2]]
end.sort.uniq.each do |gem, version|
in_gemfile_lock = system %Q{grep -q "#{gem} (#{version})" Gemfile.lock}
puts "Unsafe #{gem} (#{version})" if in_gemfile_lock
end