Skip to content

Instantly share code, notes, and snippets.

@skateinmars
skateinmars / gist:5422
Created Aug 14, 2008
rake task for project creation in redmine
View gist:5422
# 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
View horrible.rb
class String
def new_compare(obj)
send(:'old_=~', Regexp.new(obj))
end
alias_method :'old_=~', :'=~'
alias_method :'=~', :'new_compare'
end
puts ("blah" =~ "blah") == 0
View weird_fizzbuzz.rb
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 } }
@skateinmars
skateinmars / Dockerfile
Created Mar 21, 2018
Example dockerfile with simplest possible python server
View Dockerfile
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 / statsd.rb
Created Jul 8, 2019
Fake Statsd ruby server
View statsd.rb
#!/usr/bin/env ruby
#
# vim: set ft=ruby
#
require 'rubygems'
require 'socket'
$stdout.sync = true