This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== Development Approaches | |
Asshole Driven development (ADD) - Any team where the biggest jerk makes all the big decisions is asshole driven development. All wisdom, logic or process goes out the window when Mr. Asshole is in the room, doing whatever idiotic, selfish thing he thinks is best. There may rules and processes, but Mr. A breaks them and people follow anyway. | |
Cognitive Dissonance development (CDD) - In any organization where there are two or more divergent beliefs on how software should be made. The tension between those beliefs, as it's fought out in various meetings and individual decisions by players on both sides, defines the project more than any individual belief itself. | |
Cover Your Ass Engineering (CYAE) - The driving force behind most individual efforts is to make sure than when the shit hits the fan, they are not to blame. | |
Development By Denial (DBD) - Everybody pretends there is a method for what's being done, and that things are going ok, when in reality, things are a mess and th |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IO | |
TIOCGWINSZ = 0x5413 | |
TIOCSWINSZ = 0x5414 | |
Winsize = Struct.new(:rows, :columns, :horizontal_pixels, :vertical_pixels) | |
def winsize | |
ioctl(TIOCGWINSZ, size=""); Winsize.new(*size.unpack("SSSS")) | |
end | |
def winsize=(winsize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module B | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
def foo | |
p 'from instance' | |
end | |
module ClassMethods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Options < Hash | |
def self.new(&a) | |
a = lambda{|h,k| h[k] = new(&a) } unless a | |
super(&a) | |
end | |
def method_missing(m, *a) | |
if m[-1] == "=" | |
key = keys.find{|k| k.to_s == m[0...-1].to_s } || m[0...-1].to_sym | |
self[key] = a.first | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
serv = TCPServer.new("127.0.0.1", 110) | |
s = serv.accept | |
s.puts "+OK POP3 server ready" | |
while line = s.gets.strip | |
case line | |
when "CAPA" | |
s.puts("SASL PLAIN\n.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'securerandom' | |
N = 100_000 | |
A = %w(a b c) | |
Score = Hash.new { |h, k| h[k] = 0 } | |
N.times do | |
sorted = A.sort_by{ SecureRandom.random_bytes(4).unpack("I")[0] } | |
Score[sorted.join(" ")] += 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h = Hash.new{|h,k| h[k] = 0 }; ObjectSpace.each_object{|o| h[o.class] += 1 }; p h.sort_by{|k,v| -v} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri'; require 'json' | |
username = ARGV[0] | |
JSON.parse(open("http://gist.github.com/api/v1/json/gists/#{username}").read)['gists'].each{|i| system "git clone git://gist.github.com/#{i['repo']} gist-#{i['repo']}" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'eventmachine' | |
children = [] | |
Signal.trap('INT') do | |
puts "Killing #{children.size} children ..." | |
children.each do |pid| | |
Process.kill('SIGUSR1', pid) rescue nil | |
end | |
EM.stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ResistorCalculator | |
# http://www.dannyg.com/examples/res2/resistor.htm | |
attr_reader :tolerance, :multiplier, :ones, :tens, :ohms | |
Tens = %w[Black Brown Red Orange Yellow Green Blue Violet Gray White] | |
Ones = %w[Black Brown Red Orange Yellow Green Blue Violet Gray White] | |
Multiplier = %w[Black Brown Red Orange Yellow Green Blue Violet Gray White Gold Silver] | |
Tolerance = %w[Gold Silver None] |
NewerOlder