Skip to content

Instantly share code, notes, and snippets.

View ukd1's full-sized avatar

Russell Smith ukd1

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ukd1 on github.
  • I am russ (https://keybase.io/russ) on keybase.
  • I have a public key whose fingerprint is 0EE7 196E 0432 14B8 EDBB 56AA 0467 84C6 68E7 D405

To claim this, I am signing this object:

from __future__ import division
import urllib, json, string, datetime
from itertools import permutations
from math import log
def _bf(V, E, src):
# init
dist = dict(zip(V, [float('Inf') for v in V]))
pred = dict(zip(V, [None for v in V]))
sample_data = [0, 1, 100, 99, 0, 10, 90, 30, 55, 33, 55, 75, 51, 49, 50, 51, 49, 51]
sample_output = [[1,99], [0,100], [10,90], [51,49], [50,50]]
var results = [];
for (var i = 0; i < sample_data.length; i++) {
for (var j = i + 1; j < sample_data.length; j++) {
if (sample_data[i] + sample_data[j] == 100) {
var combo = sample_data[i]
if (results.indexOf(sample_data[i]) == -1 && results.indexOf(100 - sample_data[i]) == -1) {
results.push(combo);
#! /usr/bin/env bash
open -a iTunes http://store.ukd1.co.uk.s3.amazonaws.com/coin.wav || open http://store.ukd1.co.uk.s3.amazonaws.com/coin.wav
@ukd1
ukd1 / truncate.php
Created November 29, 2010 20:38
Allows deleting of all keys in a riak bucket using the streaming api
<?php
/**
* Delete all keys from a riak bucket using key streaming
*
* History:
*
* 29-Nov-10
* First version
*
* @author Russell Smith <russell.smith@ukd1.co.uk>
@ukd1
ukd1 / graylog2_mapreduce_report.php
Created April 28, 2011 16:33
Generate a simple report of attacks on your servers from Graylog2 data using MapReduce (now requires MongoDB driver >= 1.2)
<?php
/**
* A quick & dirty script that outputs a list of possible attacking IP address,
* per host with a total count.
*
* Tweak the "THE_QUERY" constant to suit your environment - we use Debian & Ubuntu
*
* @author Russell Smith <russell.smith@ukd1.co.uk>
* @copyright UKD1 Limited, 2011
* @license ISC license
@ukd1
ukd1 / php.rb
Created September 22, 2011 17:28
PHP Ext directory fact
Facter.add(:phpextdir) do
setcode do
if File.exist?('/usr/bin/php')
%x{/usr/bin/php -i 2> /dev/null | /usr/bin/awk '/extension_dir/ {print $3}'}.chomp
end
end
end
@ukd1
ukd1 / updateChromium.sh
Created November 17, 2011 14:14
Keep up to date with the latest Chromium builds on your mac
#!/bin/sh
rm -f chrome-mac.zip chrome-mac
export CHROME_VERSION=`curl http://commondatastorage.googleapis.com/chromium-browser-continuous/Mac/LAST_CHANGE`
wget http://commondatastorage.googleapis.com/chromium-browser-continuous/Mac/$CHROME_VERSION/chrome-mac.zip
unzip chrome-mac.zip
rm -rf /Applications/Chromium.app
mv chrome-mac/Chromium.app /Applications/Chromium.app
rm -rf chrome-mac chrome-mac.zip
x = [1,2,3,4,4]
y = x.uniq
puts x - y == [4]
sudo fs_usage -w -f filesys mdworker