Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Walker stwalkerster

View GitHub Profile
View gist:5390381
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/%";
@stwalkerster
stwalkerster / update.sh
Last active Dec 16, 2015
RRD update for ACC graphs
View update.sh
#!/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 / lcd.sh
Last active Dec 16, 2015
LCD code for RPi
View lcd.sh
#!/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 " "`
View gist:5328566
[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:
View graph.php
#!/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",
),
@stwalkerster
stwalkerster / blockscript.php
Created Mar 12, 2013
block test script - takes an array of IPs and spits the lcally blocked ones back at you.
View blockscript.php
<?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")));
View check_updates.php
#!/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;
View gist:5139843
#!/usr/bin/php
<?php
$cmd = "/usr/lib/update-notifier/update-motd-reboot-required";
$out = array();
$returnvar = 0;
$return = exec($cmd, $out, $returnvar);
View create.sh
#!/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
View syslog
Jan 30 16:42:15 metapod slapd[20445]: @(#) $OpenLDAP: slapd (Oct 17 2012 19:48:49) $#012#011buildd@panlong:/build/buildd/openldap-2.4.28/debian/build/servers/slapd
Jan 30 16:42:15 metapod slapd[20445]: ldif_read_file: checksum error on "/etc/ldap/slapd.d/cn=config/olcDatabase={0}config.ldif"
Jan 30 16:42:15 metapod slapd[20445]: ldif_read_file: checksum error on "/etc/ldap/slapd.d/cn=config/olcDatabase={1}hdb.ldif"
Jan 30 16:42:15 metapod slapd[20446]: hdb_db_open: database "dc=stwalkerster,dc=net": unclean shutdown detected; attempting recovery.
Jan 30 16:42:15 metapod slapd[20446]: slapd starting
Jan 30 16:42:15 metapod puppet-agent[17716]: (/Stage[main]/Ldap::Server/Service[ldap]/ensure) ensure changed 'stopped' to 'running'
Jan 30 16:42:27 metapod puppet-agent[17716]: Finished catalog run in 21.07 seconds
Jan 30 16:42:49 metapod kernel: slapd[20448]: segfault at 70 ip b76c0e79 sp b5df9820 error 4 in slapd[b7640000+12f000]