Skip to content

Instantly share code, notes, and snippets.

View stwalkerster's full-sized avatar

Simon Walker stwalkerster

View GitHub Profile
@stwalkerster
stwalkerster / create.sh
Created March 5, 2013 03:08
ACC stats graph
#!/bin/bash
STEP=300
HB=600
rrdtool create acc.rrd --start `date +%s` --step $STEP DS:open:GAUGE:$HB:0:U DS:admin:GAUGE:$HB:0:U DS:checkuser:GAUGE:$HB:0:U DS:hold:GAUGE:$HB:0:U RRA:AVERAGE:0.5:1:288 #RRA:AVERAGE:0.5:12:24 RRA:AVERAGE:0.5:288:31
#!/usr/bin/php
<?php
$statusfile = "/var/local/nagios-update-check";
$data = array();
$ret = 0;
$updates = exec("/usr/lib/update-notifier/apt-check 2>&1", $data, $ret);
$up = explode(";", $updates);
$maxupdates = 15;
#!/usr/bin/php
<?php
$cmd = "/usr/lib/update-notifier/update-motd-reboot-required";
$out = array();
$returnvar = 0;
$return = exec($cmd, $out, $returnvar);
@stwalkerster
stwalkerster / blockscript.php
Created March 12, 2013 04:12
block test script - takes an array of IPs and spits the lcally blocked ones back at you.
<?php
ini_set("user_agent", "stw-block-script/1.0 ( User:Stwalkerster )");
$iplist = array( "127.0.0.1" );
header("Content-Type: text/plain");
foreach($iplist as $ip){
$data = (unserialize(file_get_contents("http://en.wikipedia.org/w/api.php?action=query&list=blocks&format=php&bkusers=$ip")));
#!/usr/bin/php
<?php
$defs = "DEF:open=acc.rrd:open:AVERAGE DEF:admin=acc.rrd:admin:AVERAGE DEF:cu=acc.rrd:checkuser:AVERAGE DEF:hold=acc.rrd:hold:AVERAGE";
$times = array(
"day" => array(
"date" => "-1day",
"title" => "day",
),
[02:08:49][stwalkerster@blastoise:~]
bash $ dig riley.fastlizard4.org
; <<>> DiG 9.7.3 <<>> riley.fastlizard4.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 31404
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
@stwalkerster
stwalkerster / lcd.sh
Last active December 16, 2015 04:29
LCD code for RPi
#!/bin/bash
# mode: 0 = control
echo "1" > /sys/devices/virtual/gpio/gpio3/value
# 14 15 18 23 24 25 8 7
data=`echo $1 | xxd -b | cut -f 2 -d " "`
@stwalkerster
stwalkerster / update.sh
Last active December 16, 2015 05:39
RRD update for ACC graphs
#!/bin/bash
cd /home/stwalkerster/rrd/acc-new/
wget --no-check-certificate -O status.xml -o /dev/null https://toolserver.org/~acc/api.php?action=status
cat status.xml | sed "s/</\r\n</g" | grep status | sed "s/ /\n/g" | sed "s/\"\/>/\"/" | grep -v "<status" | head -n4 |sed "s/\"//g" > values
rm status.xml
chmod a+x values
. values
@stwalkerster
stwalkerster / gist:5390381
Created April 15, 2013 18:50
ACC link queries
select page_namespace, page_title, iwl_text from iwlinks inner join page on page_id = iwl_from where iwl_prefix = "tools" and iwl_title like "~acc/%";
select distinct page_namespace, page_title, el_to from externallinks inner join page on page_id = el_from where el_index LIKE "http://org.toolserver./~acc/%" or el_index LIKE "https://org.toolserver./~acc/%";

These are the commands for the command blocks needed for each stage of the ticket barrier system, in order. They do require some specific wiring, usually using comparators/repeaters etc (especially for buying tickets/railcards).

I plan on adding wiring diagrams to these at some later point. Question marks indicate values that need to be changed for every set of systems. Relative points for x/z coords are accepted - these are left out entirely.