Skip to content

Instantly share code, notes, and snippets.

@skateinmars
skateinmars / statsd.rb
Created July 8, 2019 08:55
Fake Statsd ruby server
#!/usr/bin/env ruby
#
# vim: set ft=ruby
#
require 'rubygems'
require 'socket'
$stdout.sync = true
@skateinmars
skateinmars / Dockerfile
Created March 21, 2018 09:33
Example dockerfile with simplest possible python server
FROM gliderlabs/alpine:3.4
ENV PORT 80
RUN apk-install python
ADD . /app
WORKDIR /app
CMD python /app/server.py
EXPOSE 80
@skateinmars
skateinmars / weird_fizzbuzz.rb
Created August 13, 2014 09:05
Toying with FizzBuzz
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 } }
class String
def new_compare(obj)
send(:'old_=~', Regexp.new(obj))
end
alias_method :'old_=~', :'=~'
alias_method :'=~', :'new_compare'
end
puts ("blah" =~ "blah") == 0
@skateinmars
skateinmars / gist:5422
Created August 14, 2008 12:18
rake task for project creation in redmine
# 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