Skip to content

Instantly share code, notes, and snippets.

@joakimk
joakimk / example_output.txt
Created Mar 23, 2011
Example output for the vagrant_example.
View example_output.txt
Macbook:vagrant_example (master) $ time vagrant up
[default] Provisioning enabled with chef_solo...
[default] Box base was not found. Fetching box from specified URL...
[default] Downloading with Vagrant::Downloaders::HTTP...
[default] Downloading box: http://files.vagrantup.com/lucid32.box
[default] Extracting box...
[default] Verifying box...
[default] Cleaning up downloaded box...
[default] Importing base box 'base'...
[default] Matching MAC address for NAT networking...
@joakimk
joakimk / build_vagrant_gem.sh
Created Mar 23, 2011
How to get the vagrant dev-env running
View build_vagrant_gem.sh
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
# follow instructions
rvm install ree
rvm use ree
git clone https://github.com/mitchellh/vagrant.git
cd vagrant
gem install bundler
git checkout 77a1b9a6efe4f5cdc993
View fi_2_en
#!/usr/bin/env ruby
require 'rubygems'
require 'httparty'
require 'json'
# Get one at https://code.google.com/apis/console/b/0
GOOGLE_TRANSLATE_KEY = ""
def translate_to_en(text)
JSON.parse(HTTParty.get("https://www.googleapis.com/language/translate/v2?key=#{GOOGLE_TRANSLATE_KEY}&q=#{URI.encode(text)}%20d%C3%A5&source=fi&target=en", :format => 'text').to_s)["data"]["translations"][0]["translatedText"]
@joakimk
joakimk / .deploy_config.yml
Created Apr 11, 2011
Example of the deploy config for quickly testing changes to testbot (used by "rake deploy")
View .deploy_config.yml
upload_gem: scp pkg/GEM_FILE user@public_host:/var/www/testbot
update_server: ssh user@server 'wget -q http://public_host/testbot/GEM_FILE && gem install GEM_FILE --no-ri --no-rdoc && rm GEM_FILE'
restart_server: ssh user@server 'testbot --server stop; testbot --server start'
#### To use development versions the runners should be started like this: ####
testbot --runner --connect ... --auto_update --dev_gem_root http://public_host/testbot
View brightbox_debug.log
macbook:bb (master) $ time ../bin/testbot_cloud start
Starting 5 runners...
srv-hfme2 is being created...
srv-tigqo is being created...
srv-aap3y is being created...
srv-u61ix is being created...
srv-tigqo is up, installing testbot...
srv-u61ix is up, installing testbot...
srv-tigqo ssh connection failed, retrying...
srv-tigqo ssh connection failed, retrying...
@joakimk
joakimk / HipChatOptimized.user.css
Created Apr 21, 2011
Quick userscript to make HipChat more like irssi
View HipChatOptimized.user.css
div.input {
background-color: #555 !important;
border-top: 1px solid #aaa !important;
}
.topic_container {
background-color: #222 !important;
color: #aaa !important;
}
@joakimk
joakimk / bot.rb
Created Apr 29, 2011 — forked from jpr5/bot.rb
XMPP/Ruby Bot for HipChat with support for multiple rooms
View bot.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'xmpp4r'
require 'xmpp4r/muc/helper/simplemucclient'
# Most of this is borrowed from https://gist.github.com/941931
# Added support for multiple rooms and external handling of messages.
# We want the MUC functionality to just handle shit for us. Unfortunately we
# have to override/repeat the join method in order to add the directive that
@joakimk
joakimk / usage.rb
Created Jun 9, 2011
Example of how to setup a server in vmware that installs from a pxe install server
View usage.rb
# config = ..
datacenter = VmwareDataCenter.new(config)
datacenter.create_vm(:name => "ServerName", :cpus => 1, :memory => 512, :disk => 5000,
:datastore => "VolumeName", :install_identifier_mac => "some mac addr",
:install_pxe_network_name => "network to look for pxe server on")
# server cookbook https://github.com/joakimk/cookbooks/tree/master/pxe_install_server
@joakimk
joakimk / pivotalstatus.rb
Created Jun 23, 2011 — forked from aalin/pivotalstatus.rb
Pivotal tracker git status thing...
View pivotalstatus.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'pivotal-tracker'
class String
ANSI_COLORS = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]
def colorize(color)
num = ANSI_COLORS.index(color) or raise("Bad color #{ color }")
"\e[3#{ num }m" + self + "\e[0m"
@joakimk
joakimk / gist:1117167
Created Jul 31, 2011
Some simple ruby 1.9.3 benchmarks
View gist:1117167
The two rubies:
- 1.9.2 "ruby-1.9.2-p180-patched" (using https://raw.github.com/gist/1008945/7532898172cd9f03b4c0d0db145bc2440dcbb2f6/load.patch)
- 1.9.3 "ruby-1.9.3-preview1"
The app:
- Rails 3.1rc4 app with some scaffolds.
Results:
Ruby: Rails environment load time: Full spec suite: Unit tests: