Skip to content

Instantly share code, notes, and snippets.

View mattfoster's full-sized avatar

Matt Foster mattfoster

View GitHub Profile
# Quickly hacked together my Michael Ivey
# Based on mt.rb by Nick Gerakines, open source and publically
# available under the MIT license. Use this module at your own risk.
require 'rubygems'
require 'sequel'
require 'fastercsv'
require 'fileutils'
require File.join(File.dirname(__FILE__),"csv.rb")
---
rooturi: http://hackerific.net
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://hackerific.net/</loc>
<lastmod>{{ site.time | date: '%Y-%m-%d' }}</lastmod>
<changefreq>weekly</changefreq>
<priority>1</priority>
#! /usr/bin/env ruby
# Read current cost info. Output in a form suitble for cacti.
# On ubuntu, place in the following sudoers to allow running from cacti:
# www-data ALL=NOPASSWD: /usr/share/cacti/site/scripts/currentcost.rb
# To create device specific names, create:
# /etc/udev/rules.d/70-persistent-currentcost.rules containing:
# KERNEL=="ttyUSB*", SUBSYSTEM=="tty", ATTRS{manufacturer}=="Prolific Technology Inc.", SYMLINK+="currentcost%n"
# conky configuration
# edited by [email protected]
# edited by [email protected]
# set to yes if you want Conky to be forked in the background
background yes
# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
@mattfoster
mattfoster / current_cost.rb
Created February 27, 2012 16:07
CurrentCost Collectd Script
#! /usr/bin/env ruby
require 'rubygems'
require 'daemons'
require 'collectd'
require 'rexml/document'
require 'serialport'
# Names and values to output
$data = {
; CurrentCost Analogue Dev Board Firmware
; PIC16F689 Configuration Bit Settings
CONFIG FOSC = INTRCIO ; Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
CONFIG WDTE = OFF ; Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
CONFIG PWRTE = ON ; Power-up Timer Enable bit (PWRT enabled)
CONFIG MCLRE = ON ; MCLR Pin Function Select bit (MCLR pin function is MCLR)
CONFIG CP = OFF ; Code Protection bit (Program memory code protection is disabled)
CONFIG CPD = OFF ; Data Code Protection bit (Data memory code protection is disabled)
CONFIG BOREN = OFF ; Brown-out Reset Selection bits (BOR disabled)
@mattfoster
mattfoster / lcd_icon.pl
Created July 7, 2012 20:38
A simple script to convert (16x16) PNGs for display on small LCDs
#! /usr/bin/env perl
# Convert PNG file to hex array, for use in the Adafruit Arduino LCD library
use warnings;
use strict;
use Getopt::Long;
use Imager;
use List::MoreUtils qw(natatime);
use Pod::Usage;
@mattfoster
mattfoster / random_client_name.pl
Created July 17, 2014 09:49
A quick script to generate random client names
#! /usr/bin/env perl
# Generate random client names
use warnings;
use strict;
use Carp qw( croak );
use Readonly;
Readonly my @COMPANY_TYPES => qw( Ltd PLC B.V. S.p.a. LLC LLP Incorporated );
@mattfoster
mattfoster / keybase.md
Created August 27, 2014 10:45
keybase verification

Keybase proof

I hereby claim:

  • I am mattfoster on github.
  • I am mpf (https://keybase.io/mpf) on keybase.
  • I have a public key whose fingerprint is 33D8 FD91 0B0E 4C06 A611 EEF9 CE25 7045 CFEC 91DF

To claim this, I am signing this object:

#! /usr/bin/env ruby
# Set iTerm 2 tab colours.
#
# Author: Matt Foster <[email protected]>
require 'color/css'
colour = ARGV.shift
if colour.nil?