Skip to content

Instantly share code, notes, and snippets.


Hartog C. de Mik coffeeaddict

View GitHub Profile
View gist:11213880
#!/usr/bin/env ruby
require 'open3'
stdout, status = Open3.capture2("git status -uno --porcelain")
rescue Errno::ENOENT
abort "Cannot run `git status -uno --porcelain`."
View battery.rb
#!/usr/bin/env ruby
# Read battery event file and return some numbers
require 'json'
stats = {}"/sys/class/power_supply/BAT1/uevent", File::RDONLY) do |f|
while(line = f.gets)
(key, value) = line.chomp.split('=')
View unicorns.cap
namespace :unicorns do
def unicorn_command
fetch(:unicorn_command, File.join(shared_path, "bin/unicorn_rails"))
def unicorn_pid_file
fetch(:unicorn_pid_file, "/path/to/")
def unicorn_config_file
coffeeaddict / json_lint.rb
Created Dec 5, 2013
Pretty print (and validate) json
View json_lint.rb
#!/usr/bin/env ruby
# Pretty print (and validate) json
# usage: curl http://localhost/api/unreadable.json | json_lint
# author: Hartog C. de Mik <>
require 'json'
View pizza.txt
In de schotel van je roerijzer
300gr meel
met 312ml water
en 1/4 blokje hefe
door roeren tot klontjesvrij en 20 minuten laten staan
meer als 5 en minder als 10 gram zout toevoegen
3-4 minuten roeren/kneden
beetje bij beetje 200gr meel toevoegen
en maar kneden
View i3status.config
general {
colors = true
interval = 5
order += "ipv6"
order += "disk /"
order += "run_watch DHCP"
order += "run_watch VPN"
order += "wireless eth2"
coffeeaddict / example.rb
Created Jun 27, 2013
Some toolbox methods for a ruote developer
View example.rb
>> pdef = <<EOPDEF
define comms_and_hackers
sequence flank: true
cursor rewind_unless: '${f:conversation_done}'
cursor rewind_unless: '${f:cipher_broken_or_conversation_done}'
coffeeaddict / html2markdown.rb
Created Mar 8, 2013
HTML 2 Markdown using a SAX Parser. (WIP)
View html2markdown.rb
# html2markdown.rb
require 'nokogiri'
module Html2Markdown
class HtmlDocument < Nokogiri::XML::SAX::Document
MAP = { "b" => "strong", "i" => "em" }
def initialize()
@list = nil
View Gemfile
# A sample Gemfile
source ""
gem "nokogiri"
coffeeaddict /
Last active Dec 11, 2015
Testing ruote participants with rspec

Testing participants


Testing a participant is gory-detail-stuff. You must know a lot about the internals of Ruote. Because; In order to 'test' a participant, we have to mimic the environment the participant lives and is executed in.


Since we are isolating the participant in our experiment^W... tests we have to prevent the participant from communicating with Ruote. In order to do so we have replace the #reply function with an own singleton.