Skip to content

Instantly share code, notes, and snippets.

View jbarber's full-sized avatar

Jonathan Barber jbarber

View GitHub Profile
@jbarber
jbarber / Debian.md
Created September 30, 2016 09:07
Notes on debian

Add a GPG key for a repo to the apt keyring

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7F438280EF8D349F

@jbarber
jbarber / gist:088f19cf1b6178adb3cb12fd52919d29
Last active September 29, 2016 14:48
Instructions for modifying existing debian packages
cat <<EOF > /etc/apt/sources.list.d/rainforest-ppa-trusty.list
deb http://ppa.launchpad.net/rainforest/ppa/ubuntu trusty main
deb-src http://ppa.launchpad.net/rainforest/ppa/ubuntu trusty main
EOF
apt-get update
mkdir debs; cd debs
apt-get source qemu
cd qemu-2.1.1
@jbarber
jbarber / libvirt.rb
Created August 3, 2016 00:55
Example of adding/removing libvirt DHCP host entriy with ruby-libvirt
# Example of ruby-libvirt bindings to add a DHCP entry for a particular host
# This updates the dnsmasq config
# Requires ruby-libvirt 0.6.0
require 'libvirt'
conn = Libvirt::open()
network = conn.lookup_network_by_name('default')
xml = %q(<host mac='52:54:00:00:00:01' name='bob' ip='192.168.122.45'/>)
# Add the lease

Keybase proof

I hereby claim:

  • I am jbarber on github.
  • I am jbarber (https://keybase.io/jbarber) on keybase.
  • I have a public key whose fingerprint is E70E 7401 E22F 15C7 266E 3EE5 357D E7D3 DBEB A5BE

To claim this, I am signing this object:

@jbarber
jbarber / deprecated_heroku_stack.sh
Created February 19, 2016 08:47
Find heroku applications on ceder-10
#!/bin/sh
heroku apps | sed -n '/^=== Collaborated Apps/,$ p' | awk '!/^===/ && !/^$/ {print $1}' | while read i; do
(heroku info $i | grep -q ceder-10) && echo $i
done
@jbarber
jbarber / get_all_envvars.sh
Created February 18, 2016 10:50
Get all Circle-CI env vars
TOKEN=9dfca6a9b51a2a8e50b8abb35728690381f8e9b1
for i in *; do
URL=https://circleci.com/api/v1/project/rainforestapp/$i/envvar?circle-token=$TOKEN
curl -s -H "Accept: application/json" $URI | grep d7d6 && echo $i
done
@jbarber
jbarber / list_github_repos.rb
Last active February 18, 2016 10:30
List all repos for an organisation
require 'octokit'
# ~/.netrc contains:
# machine api.github.com
# login jonathan.barber@gmail.com
# password $GITHUBAPIKEY
Octokit.auto_paginate = true
client = Octokit::Client.new(:netrc => true)
client.org_repos('rainforestapp', {:type => 'all'}).collect(&:ssh_url).join(' ')
@jbarber
jbarber / ovs-db.py
Created June 3, 2015 16:53
Get information from openvswitch ovsdb
#!/usr/bin/env python
import ovs.db.idl
import ovs.poller
ovs.vlog.Vlog.set_levels_from_string("console:dbg")
ovs.vlog.Vlog.init()
remote = 'unix:/var/run/openvswitch/db.sock'
# If not present, will read from default path
@jbarber
jbarber / sip-hangup.pl
Created April 2, 2015 14:49
Example of Net::SIP and AnyEvent with hanging up caller
#!/usr/bin/env perl
# Make call when program receives SIGHUP, hangup when call is answered
use strict;
use warnings;
use 5.10.0;
use Net::SIP 0.687;
#use Net::SIP::Debug 1;
@jbarber
jbarber / dbus.pl
Created April 2, 2015 14:36
Example perl DBUS service with AnyEvent::DBUS
#!/usr/bin/env perl
# Simple (!) Net::DBus service example using AnyEvent::DBus to run the event
# loop. You can examine the service with the following command:
# gdbus introspect --session --dest=pt.up.fe.door -o /pt/up/fe/door
#
# And invoke the unlock method as follows:
# dbus-send --session --dest=pt.up.fe.door /pt/up/fe/door pt.up.fe.door.unlock
#
# Once the unlock method is invoked, the program terminates.