Skip to content

Instantly share code, notes, and snippets.

@mmb
mmb / bosh2docker.rb
Created June 13, 2014 05:21
convert a bosh job into a Dockerfile that builds a container with all the job's packages installed
require 'yaml'
require 'fileutils'
job = ARGV[0]
job_spec = YAML.load_file(File.join('jobs', job, 'spec'))
packages = job_spec['packages']
work_dir = 'docker'
FileUtils.mkdir_p(work_dir)
@mmb
mmb / weechat_otr.py
Created April 16, 2014 06:58
weechat otr with irc parsing debugging
# -*- coding: utf-8 -*-
# otr - WeeChat script for Off-the-Record IRC messaging
#
# DISCLAIMER: To the best of my knowledge this script securely provides OTR
# messaging in WeeChat, but I offer no guarantee. Please report any security
# holes you find.
#
# Copyright (c) 2012-2014 Matthew M. Boedicker <matthewm@boedicker.org>
# Nils Görs <weechatter@arcor.de>
# Daniel "koolfy" Faucon <koolfy@koolfy.be>
@mmb
mmb / wunderlist_unfinished.sh
Created February 15, 2014 09:31
Using jq to extract lists from a Wunderlist json export
# All unfinished items from a list called "Buy"
cat ~/Downloads/wunderlist-20140214-23-56-27.json | \
jq -r '([.lists[] | {key: .id, value: .title}] | from_entries) as $lists |
.tasks |
map(select(.completed_at == null)) |
map({title, list: $lists[.list_id]}) |
map(select(.list == "Buy")) |
.[].title'
@mmb
mmb / gist:4230951
Created December 7, 2012 05:12
Find all urls in stdout and open them in a browser.
cat some_stdout | ruby -ruri -e "puts URI.extract(ARGF.read, 'http').join(' ')" | xargs open
find . -name *.gem -printf "%f\n" | sort | uniq | sed 's/\([0-9a-z_-]*\)-\([0-9.]*\)\.gem$/gem "\1", "= \2"/g'
@mmb
mmb / gist:3803338
Created September 29, 2012 06:11
Deploying Hubot IRC on Cloud Foundry
Deploying Hubot IRC on Cloud Foundry
git clone git://github.com/github/hubot.git
cd hubot
npm install
mkdir ~/hubot_deploy
@mmb
mmb / 1.9.2-p180
Created September 20, 2012 22:29
patched ruby 1.9.2-p180 rbenv package for recent Ubuntu
require_gcc
build_package_patch_sslv2() {
wget -q -O - https://raw.github.com/gist/3758689/6363d446805334c1815c18094f5892f0b37cbd30/remove_sslv2.patch | patch -p0
}
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_package "ruby-1.9.2-p180" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz" patch_sslv2 standard
install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz" ruby
@mmb
mmb / remove_sslv2.patch
Created September 20, 2012 22:17
patch to remove SSLv2 from ruby 1.9.2-p180
--- ext/openssl/ossl_ssl.c.back 2012-09-20 14:48:47.000000000 -0700
+++ ext/openssl/ossl_ssl.c 2012-09-20 14:48:53.000000000 -0700
@@ -107,9 +107,9 @@
OSSL_SSL_METHOD_ENTRY(TLSv1),
OSSL_SSL_METHOD_ENTRY(TLSv1_server),
OSSL_SSL_METHOD_ENTRY(TLSv1_client),
- OSSL_SSL_METHOD_ENTRY(SSLv2),
- OSSL_SSL_METHOD_ENTRY(SSLv2_server),
- OSSL_SSL_METHOD_ENTRY(SSLv2_client),
+ // OSSL_SSL_METHOD_ENTRY(SSLv2),
@mmb
mmb / gist:3704738
Created September 12, 2012 06:40
Scripting VM virtual consoles from the host.
# Writing to Linux virtual consoles to simulate user input:
s = "ls\n"
open('/dev/tty1','w') do |f|
s.each_char do { |c| f.ioctl(0x5412, c) }
end
# From the shell:
echo 7 | ruby -e "open('/dev/tty1', 'w') { |o| \$stdin.each_char { |c| o.ioctl(0x5412, c) } }"
@mmb
mmb / emacs_scratch_paste
Created August 9, 2012 21:47
paste contents of clipboard to emacs scratch buffer
# paste contents of clipboard to emacs scratch buffer
tell application "Emacs"
activate
tell application "System Events"
keystroke "x" using {control down}
keystroke "b*scratch*"
keystroke return
keystroke ">" using {option down}
keystroke return