Skip to content

Instantly share code, notes, and snippets.

View pdf's full-sized avatar

Peter Fern pdf

  • Melbourne, Australia
View GitHub Profile
@pdf
pdf / libvirt-xmlsimple.rb
Created March 24, 2011 03:00
Convert hash into libvirt domain XML
require 'rubygems'
# xml-simple has a bug that needs to be fixed before this works, see:
# https://github.com/pdf/xml-simple/commit/b4da34165c88fe912b45af614b326ed512a666c7
require 'xmlsimple'
# domain1 omits the __value__ key except where required
domain1 = {
"@type"=>"kvm",
"name"=>"demo1",
"uuid"=>"4dea24b3-1d52-d8f3-2516-782e98a23fa1",
@pdf
pdf / gist:6419454
Created September 3, 2013 03:31
mailq parse example
msgs = {}
state = nil
id = nil
mqstdout.each_line do |line|
line.strip!
case
when state.nil? && /^(?<msgid>[0-9A-F]+)\s+(?<size>[0-9]+)\s+(?<date>.+[^\s])\s+(?<sender>[^\s]+)$/ =~ line
id = msgid
msgs[id] = {
size: size.to_i,
#!/bin/bash
set -e
# Usage:
# rsync_parallel.sh [--parallel=N] [rsync args...]
#
# Options:
# --parallel=N Use N parallel processes for transfer. Defaults to 10.
#
# Notes:
@pdf
pdf / host_colour_powerline
Last active August 29, 2015 14:01
Generate unique terminal colours for hosts based on hashed hostname, for PS1 or PowerLine
#!/bin/sh -e
# Maximum acceptable decimal colour representation
hostcolour_max_dec=16777215
# Requires the `rand` command, this doesn't seem to be packaged on some distros in the standard repositories
# If anyone knows of an alternative that will take a seed, a max, and is more widely available, let me know.
# Generate decimal colour
hostcolour_bg_dec="$(rand -M ${hostcolour_max_dec} -s $(printf "%.0f" "$(echo -n $(hostname -f) | md5sum | sed 's#^\([^[:space:]]*\).*$#0x\1#g')" 2>/dev/null | sed -e 's#^.*\([0-9]\{18\}\)$#\1#g'))"
# Convert to hex
hostcolour_bg_hex="$(printf "%06x" ${hostcolour_bg_dec})"
@pdf
pdf / davdroid.logcat
Created March 3, 2015 01:21
DAVdroid -> Open-Xchange error
I/davdroid.DavSyncAdapter( 5048): Performing sync for authority com.android.calendar
D/davdroid.DavSyncAdapter( 5048): Creating new DavHttpClient
V/davdroid.TlsSniSocketFactory( 5048): Setting allowed TLS protocols: TLSv1, TLSv1.1, TLSv1.2
I/davdroid.DavHttpClient( 5048): Wire logging active, disabling HTTP compression
D/davdroid.DavSyncAdapter( 5048): Server supports VCard version 3.0
V/davdroid.URIUtils( 5048): Normalized URL https://dav.example.com/caldav/199/ -> https://dav.example.com/caldav/199/
D/davdroid.WebDavResource( 5048): Using preemptive authentication (not compatible with Digest auth)
I/davdroid.SyncManager( 5048): Remotely removing 0 deleted resource(s) (if not changed)
I/davdroid.SyncManager( 5048): Uploading 1 new resource(s) (if not existing)
V/davdroid.URIUtils( 5048): Normalized URL 20150303T004851Z-5048_4579225c66f01453.ics -> 20150303T004851Z-5048_4579225c66f01453.ics
@pdf
pdf / network-recurse.json
Created April 4, 2015 11:11
network interfaces consul recurse
[
{
"CreateIndex":553,
"ModifyIndex":553,
"LockIndex":0,
"Key":"network/eth0/inet/dhcp/",
"Flags":0,
"Value":null
},
{
@pdf
pdf / influxdb.log
Last active August 29, 2015 14:24
influxdb write timeouts
Jul 02 09:33:05 hostname influxd[21546]: 2015/07/02 09:33:05 TSDB listener accept &{0xc208932020 0xc2094a0060}
Jul 02 09:34:08 hostname influxd[21546]: 2015/07/02 09:34:08 TSDB listener accept &{0xc2093eeba0 0xc208a7c180}
Jul 02 09:37:59 hostname influxd[21546]: 2015/07/02 09:37:59 TSDB listener accept &{0xc20868c020 0xc208df21e0}
Jul 02 09:38:05 hostname influxd[21546]: 2015/07/02 09:38:05 TSDB listener accept &{0xc2091fa370 0xc208df20c0}
Jul 02 09:38:40 hostname influxd[21546]: [shard] 2015/07/02 09:38:40 flush 7964 points in 0.069s
Jul 02 09:38:40 hostname influxd[21546]: [shard] 2015/07/02 09:38:40 flush 7776 points in 0.081s
Jul 02 09:38:40 hostname influxd[21546]: [shard] 2015/07/02 09:38:40 flush 8610 points in 0.086s
Jul 02 09:38:41 hostname influxd[21546]: [shard] 2015/07/02 09:38:41 flush 8928 points in 0.089s
Jul 02 09:38:41 hostname influxd[21546]: [shard] 2015/07/02 09:38:41 flush 7968 points in 0.085s
Jul 02 09:38:41 hostname influxd[21546]: [shard] 2015/07/02 09:38:41 flush 8050 points in 0
@pdf
pdf / example.jsx
Last active December 9, 2017 02:06
Trivial implementation of a responsive grid system using Flexbox and redux-responsive
import { Flex, Box } from './flexbox.jsx';
// A basic example. Note that the number of grid columns is not fixed,
// instead you simply specify sizes as fractions (or decimals between
// 0.0 and 1.0), and the items will be sized appropriately. For example,
// the outer <Flex/> is full size at the `xs` breakpoint, 2/3 of full size
// at the `md` breakpoint, and 1/2 at `lg` or higher.
export const Basic (props) => (
<Flex xs={1} md={2 / 3} lg={1 / 2} auto >
<Box auto />
@pdf
pdf / main.go
Last active February 1, 2019 18:27
Trivial nested vecty router
package main
import (
"github.com/gopherjs/vecty"
"github.com/gopherjs/vecty/elem"
"github.com/gopherjs/vecty/event"
"github.com/pdf/vectyx/router"
)
type App struct {
@pdf
pdf / main.go
Created March 1, 2018 20:28 — forked from egonelbre/main.go
Size visual changing
package main
import (
"encoding/hex"
"fmt"
"math/rand"
"github.com/gopherjs/vecty"
"github.com/gopherjs/vecty/elem"
"github.com/gopherjs/vecty/event"