Skip to content

Instantly share code, notes, and snippets.

@hsiboy
hsiboy / create_rrd_multi_temp.sh
Created March 4, 2014 18:04
Create rrd database
#!/bin/bash
rrdtool create multirPItemp.rrd --step 300 \
DS:in_temp:GAUGE:600:-30:50 \
DS:out_temp:GAUGE:600:-30:50 \
RRA:AVERAGE:0.5:1:12 \
RRA:AVERAGE:0.5:1:288 \
RRA:AVERAGE:0.5:12:168 \
RRA:AVERAGE:0.5:12:720 \
RRA:AVERAGE:0.5:288:365</pre>
The graphs are generated every five minutes from a cron job with with this script
@hsiboy
hsiboy / perlStat.pl
Last active September 5, 2015 10:55
Perl Thermostat - DS18B20 Raspberry Pi
#!/usr/bin/perl
use strict;
use warnings;
use Device::BCM2835;
# must be run as root, in order to access the BCM 2835 GPIO address space!
# call set_debug(1) to do a non-destructive test on non-Raspberry Pi hardware
#Device::BCM2835::set_debug(1);
Device::BCM2835::init() || die "Could not init library";
@hsiboy
hsiboy / blinky.c
Created March 6, 2014 16:59
Raspberry Pi - BCM2835 - Getting to blinky
// blinky.c
//
// gcc -o blinky blinky.c -l bcm2835
// must be run as root
// sudo ./blinky
#include <bcm2835.h>
// Blinks on RPi Plug P1 pin 13 (which is GPIO pin 21)
#define PIN RPI_GPIO_P1_13
@hsiboy
hsiboy / button.c
Created March 6, 2014 17:09
Raspberry Pi - detect button press
// button.c
// gcc -o button button.c -l bcm2835
// run as root
// sudo ./button
#include <bcm2835.h>
#include <stdio.h>
// Input on RPi pin GPIO 15
#define PIN RPI_GPIO_P1_15
@hsiboy
hsiboy / blinky.pl
Last active August 29, 2015 13:57
Raspberry Pi - BCM2835 - Getting to blinky - Perl
#!/usr/bin/env perl
# need to run as root.
# flashes an led connected to GPIO 11 aka PIN 17
use strict;
use warnings;
use Device::BCM2835;
Device::BCM2835::init() || die "Could not init library";
@hsiboy
hsiboy / xfdbot.pl
Created March 6, 2014 22:36
connects to thoughtworks cruise/GO and announces to irc channel current build status.
#!/usr/bin/perl
$|++;
use warnings;
use strict;
#no warnings qw( syntax deprecated);
use String::IRC;
@hsiboy
hsiboy / import.cmd
Created March 6, 2014 22:51
import data into mysql
@echo off
IF EXIST load.sql echo. > load.sql
for /f %%a IN ('dir /b *_iewpg.txt') do (
echo %%a
echo load data LOCAL infile '%%a' into table iewpg fields terminated by '\t' lines terminated by '\n'; >>load.sql
)
use Time::HiRes qw(time);
use LWP::UserAgent;
$ua = new LWP::UserAgent; #create a new instance
$ua->proxy(http => 'http://194.73.75.22:80'); # set the proxy server
$ua->agent("Search-Report/0.1 " . $ua->agent);
print "The user agent is: " . $ua->agent . "\n\n";
# REQUEST RADIUS FOR SEARCH, DEFAULT TO NATIONAL
print "Enter distance to search, in miles (or press ENTER for national).\n";
@hsiboy
hsiboy / wiegand.c
Created March 17, 2014 12:59
Wiegand API for Raspberry Pi
/*
* Wiegand API Raspberry Pi
* By Kyle Mallory All rights reserved.
* 12/01/2013
* Based on previous code by Daniel Smith (www.pagemac.com) and Ben Kent (www.pidoorman.com)
* Depends on the wiringPi library by Gordon Henterson: https://projects.drogon.net/raspberry-pi/wiringpi/
*
* This is linked with -lpthread -lwiringPi -lrt
*
* The Wiegand interface has two data lines, DATA0 and DATA1. These lines are normall held
@hsiboy
hsiboy / renamelogs.cmd
Created May 2, 2014 12:54
Rename IIS logs
for %a in (u_ex??????.log) do ren %a TELWEBnnnP%a