Skip to content

Instantly share code, notes, and snippets.

View thomasfl's full-sized avatar
🏠
Working from home

Thomas Flemming thomasfl

🏠
Working from home
View GitHub Profile
require 'rubygems'
require 'filewatcher'
filenames = ["/Users/thomasf/ruby/roman_numerals_test.rb"]
FileWatcher.new(filenames).watch(0.5) do |filename|
print "\e[2J\e[f"
puts "Reloading #{filename}"
load(filename)
MiniTest::Unit.new.run_tests
end
require 'rubygems'
require 'minitest/autorun'
class RomanNumerals
def conv(str)
1
end
end
class RomanNumeralsTest < MiniTest::Unit::TestCase
require 'rubygems'
require 'minitest/autorun'
class RomanNumerals
def conv(str)
1
end
end
class RomanNumeralsTest < MiniTest::Unit::TestCase
@thomasfl
thomasfl / minitest_autorun.rb
Created July 21, 2012 15:15
Autorun minitests fast
require 'rubygems'
require 'filewatcher'
# Autorun minitests when one of these files is updated:
files = ["my_minitest_tests.rb","code_under_test.rb"]
puts "Update one of these files to start tests: " + files.join(", ")
FileWatcher.new(files).watch do |filename|
puts "Updated " + filename
load filename
#!/usr/bin/perl -w # camel code
use strict;
$_='ev
al("seek\040D
ATA,0, 0;");foreach(1..3)
{<DATA>;}my @camel1hump;my$camel;
my$Camel ;while( <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary 1=split(//);if(defined($
_=<DATA>)){@camel1hum p=split(//);}while(@dromeda
require 'rubygems'
require 'open-uri-and-write'
file = open("https://www-dav.usit.uio.no/takk_for_meg.html","w")
file.puts { "resourcetype" => "structured-article",
"properties" => { "title" => "Takk for meg!",
"introduction" => "Det har vært 10 fine år."
"content" => "Hilsen Thomas Flemming",
}.to_json
file.proppatch('<v:publish-date xmlns:v="vrtx">' + Time.now.httpdate.to_s + '</v:publish-date>')
@thomasfl
thomasfl / hello_world_in_vortex_osx.rb
Created January 10, 2012 15:11
Hello World in Vortex on OSX
require 'rubygems'
require 'net/dav'
require 'json'
require 'highline/import'
require 'osx_keychain'
dav = Net::DAV.new('https://vortex-systest-dav.uio.no')
keychain = OSXKeychain.new
username = ENV['USER']
password = keychain['vortex-systest-dav.uio.no', username ]
@thomasfl
thomasfl / hello_world_in_vortex_utils.rb
Created January 10, 2012 14:48
Vortex Utils Hello World script
require 'rubygems'
require 'net/dav'
require 'json'
require 'vortex_utils'
dav = Net::DAV.new('https://vortex-systest-dav.uio.no/test/', :osx_keychain => true)
article = {
"resourcetype" => "structured-article",
"properties" => {
"title" => "Hello world!",
@thomasfl
thomasfl / hello_world_in_vortex.rb
Created January 10, 2012 14:43
Vortex Hello World script
require 'rubygems'
require 'net/dav'
require 'json'
require 'highline/import'
webdav_url = 'https://vortex-systest-dav.uio.no'
dav = Net::DAV.new(webdav_url)
username = ask("Username: ")
password = ask("Password: ") {|q| q.echo = "*"}
dav.credentials(username, password)
@thomasfl
thomasfl / a_b_split_test.html
Created December 20, 2011 14:06
Simple A/B split testing template.
<html>
<head>
<script language="javascript">
var regex = /uio_a_b_test=([^\;]+)/;
var match = regex.exec(document.cookie);
if(match === null){
var randomnumber = Math.floor(Math.random()*100);
var days=14;
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));