Skip to content

Instantly share code, notes, and snippets.

source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@stevenwilkin
stevenwilkin / delete_gemsets.sh
Created October 2, 2014 13:26
Delete all gemsets for all rubies managed by RVM
#!/bin/bash -l
for RUBY in `rvm list strings`
do
rvm use $RUBY
for GEMSET in `rvm gemset list | grep -E '^ ' | grep -v '*'`
do
rvm --force gemset delete $GEMSET
done
done
Date: Tue, 30 Sep 2014 16:49:43 +0000
From: Louis Goff-Beardsley <louis@infinitiumglobal.com>
To: London Ruby Users Group <chat@lists.lrug.org>
Subject: [LRUG] [JOBS] Contracts Galore
Message-ID: <48267692359843abb6ad091ab5441d3d@SEHSTE15D2BE3.hs20.net>
Content-Type: text/plain; charset="iso-8859-1"
Hi LRUG,
Just a quick note, the yearly "Just got back from holiday, oh God we need more development done" contracts rush has come and we've been inundated with requests for upper-Mid level & Senior Ruby and/or Javascript contractors.
@stevenwilkin
stevenwilkin / config.ru
Last active August 29, 2015 14:17
Rack redirector
app = lambda do |env|
[301, {'Location' => 'https://www.pensionwise.gov.uk/'}, []]
end
run app
@stevenwilkin
stevenwilkin / Gemfile
Created April 22, 2015 16:13
Smoke test output document generator
source 'https://rubygems.org'
ruby '2.2.2'
gem 'mechanize'
# build go static binary from root of project
gostatic(){
local dir=$1
if [[ -z $dir ]]; then
dir=$(pwd)
fi
local name=$(basename "$dir")
(
cd $dir
echo "Building static binary for $name in $dir"
#!/usr/bin/env ruby
# random_password.rb
# generate a random string of 12 alphanumeric characters
# Steven Wilkin @stevebiscuit
chars = ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a
12.times {print chars[rand(chars.length)]}
puts
I have a strange problem with a Sinatra app.
When I request http://MYAPP.heroku.com/http://google.com
This is in the log:
$ heroku logs
82.24.100.136, 10.250.31.111 - - [27/Oct/2009 13:18:41] "GET /http:/google.com HTTP/1.1" 200 17 0.0005
The '//' in my GET request is being converted to '/'
#!/usr/bin/env python
for x in range(1, 101):
if not(x % 3 or x % 5):
print 'FizzBuzz'
elif not x % 3:
print 'Fizz'
elif not x % 5:
print 'Buzz'
else:
#!/usr/bin/env python
# sort this list of random numbers using bubble sort algorithm
nums = [35, 59, 30, 95, 97, 45, 44, 41, 80, 78, 14, 58, 2, 41, 6, 68, 18, 13, 69, 12]
# test if the list is sorted
def sorted(arr):
prev = arr[0]
for x in arr:
if x < prev: