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
#!/usr/bin/env ruby | |
# | |
# vim: set ft=ruby | |
# | |
require 'rubygems' | |
require 'socket' | |
$stdout.sync = true |
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
FROM gliderlabs/alpine:3.4 | |
ENV PORT 80 | |
RUN apk-install python | |
ADD . /app | |
WORKDIR /app | |
CMD python /app/server.py | |
EXPOSE 80 |
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
NUMS = 1..100 | |
DISPLAYERS = NUMS.inject({}) {|acc, i| acc[i] = []; acc } | |
DISPLAYERS[101] = [lambda { |i| raise("finished") }] | |
NUMS.select {|i| i % 3 == 0 }.each {|i| DISPLAYERS[i] << lambda { |i| "Fizz" } } | |
NUMS.select {|i| i % 5 == 0 }.each {|i| DISPLAYERS[i] << lambda { |i| "Buzz" } } | |
NUMS.select {|i| (i % 3 != 0 && i % 5 != 0) }.each {|i| DISPLAYERS[i] << lambda { |i| i.to_s } } |
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 String | |
def new_compare(obj) | |
send(:'old_=~', Regexp.new(obj)) | |
end | |
alias_method :'old_=~', :'=~' | |
alias_method :'=~', :'new_compare' | |
end | |
puts ("blah" =~ "blah") == 0 |
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
# Use with rake : | |
# rake redmine:project:create PROJECT=myproject SVNURL="scheme://myurl" SVNLOGIN="user" SVNPASSWD="xxx" USERS="john bob" | |
namespace :redmine do | |
namespace :project do | |
desc 'Create a project from ENV variables' | |
task :create => :environment do | |
if ENV['PROJECT'].blank? | |
print "Enter project name : " | |
identifier = STDIN.gets.chomp! | |
else |