Skip to content

Instantly share code, notes, and snippets.

View warmans's full-sized avatar

SW warmans

  • Nottingham
View GitHub Profile
#!/bin/env python
import time
import RTk.GPIO as GPIO
import openvr
import sys
import atexit
def shutdown():
@warmans
warmans / ntcolour.py
Created February 13, 2014 20:27
Add colouring to Cassandra nodetool status output
#! /usr/bin/python
import sys, re
# To use run
#
# $ nodetool status | ./ntcolour.py
#
# or to refresh forever use:
#
@warmans
warmans / gist:03e8ebd178b5e94fd7c7
Created January 27, 2015 20:49
Centos jstatd init script
#!/bin/sh
# jstatd - runs the jstat daemon
#
# chkconfig: - 85 15
# description: Jstatd JVM monitoring
# processname: jstatd
# pidfile: /var/run/jstatd.pid
# Source function library.
. /etc/rc.d/init.d/functions
@warmans
warmans / CsvMapper.php
Created June 29, 2012 19:04
Crap-ish CSV Parser
<?php
/**
* Map CSV columns to fields
*
* somefile.csv content = "some guy, 5 Road Street, Town, Postcode"
*
* $mapper = new CsvMapper('/tmp/somefile.csv');
* $mapper->mapField('A', 'name')->filter('name', function($value){ return ucwords($value); });
* $mapper->mapAggregateField(array('B', C', D'), 'address', ', ');
* $mapper->mapLiteral('source', 'unknown');
@warmans
warmans / build.xml
Created March 17, 2012 19:16 — forked from hectorsanjuan/build.xml
Phing build.xml for Symfony2 projects
<?xml version="1.0" encoding="UTF-8"?>
<project name="${projectName}" basedir="." default="build:main">
<!-- Properties -->
<property name="dir.app" value="${project.basedir}/app" />
<property name="dir.src" value="${project.basedir}/src" />
<property name="dir.build" value="${project.basedir}/app/build" />
<property name="dir.docs" value="${dir.build}/docs" />
<property name="dir.docs.phpdoc" value="${dir.docs}/phpdoc" />
<property name="dir.docs.docblox" value="${dir.docs}/docblox" />
<property name="dir.reports" value="${dir.build}/logs" />
@warmans
warmans / gist:1607837
Created January 13, 2012 18:10
Modified Version of anagram-finder that reduces duplicate string operations
<?php
public function lineByLineImproved($anagramSeed) {
$fileinfo = new \SplFileInfo(RESOURCE.'wordlist.txt');
$file = $fileinfo->openFile('r');
$matchedWords = array();
$anagramSeedLength = strlen($anagramSeed); //do this once
@warmans
warmans / gist:1608008
Created January 13, 2012 18:45
Modified Version of anagram-finder that reduces duplicate string operations, this time using pre-loaded array.
<?php
public function preloadArray($anagramSeed) {
$fileinfo = new \SplFileInfo(RESOURCE.'wordlist.txt');
$file = $fileinfo->openFile('r');
$anagramSeedLength = strlen($anagramSeed);
$anagramSeedAsArray = str_split($anagramSeed);
@warmans
warmans / gist:8247a71d06ee33e6fc20
Created May 16, 2015 07:55
Ubuntu 15.04 Macbook Pro 2015 Fixes

Fonts missing after suspend

Create a new file in /usr/share/X11/xorg.conf.d called 52-suspend-fix.conf

Section "Device"
        Identifier "intel"
        Driver "intel"
        Option "AccelMethod" "none"
EndSection
@warmans
warmans / gist:8c31948fdb2b23127e08
Last active August 29, 2015 14:20
Decode cassandra thrift message with PHP and tcpdump
  1. Capture some data using tcpdump:

    tcpdump -enx -w cassandra-dump port 9160

  2. Open the file with wireshark and find a packet where the data looks related to casandra e.g. it has multiget_slice or similar commands near the start of the data.

  3. In wireshark select the data part of the packet and right click -> copy -> bytes -> hex stream

  4. Now you need a thrift library to decode the data. thobbs/phpcassa should work.

while true; do inotifywait -qr --format '%w' *.go | while read FILE; do echo $FILE; gofmt -w $FILE; done; done;