Skip to content

Instantly share code, notes, and snippets.

View jamesoff's full-sized avatar

James Seward jamesoff

View GitHub Profile
@jamesoff
jamesoff / index.php
Last active December 27, 2015 08:39
Test QuoteEngine index php file
<?php
// This is the web page for the QuoteEngine
//
// It goes with the QuoteEngine script for eggdrop by JamesOff
// http://jamesoff.net
//
// There are a couple of things to change in the settings file
// before this script can be used
require("settings.inc");
@jamesoff
jamesoff / gist:7682082
Created November 27, 2013 19:49
MongoDB training aggregation exercises
db.twitter.aggregate(
{ $group : {
"_id" : "$user.screen_name",
"tweets" : { $sum : 1 }
}
},
{ $sort : { "tweets" : -1 } },
{ $limit : 5 }
)
@jamesoff
jamesoff / gist:7771165
Created December 3, 2013 15:30
zsh function to hash a string Use it for hostname colouring in your prompt!
function string_hash() {
HASHSTR=$1
HASHSIZE=$2
HASHVAL=0
for i in {1..${#HASHSTR}}; do;
THISCHAR=$HASHSTR[$i]
HASHVAL=$(( $HASHVAL + $((#THISCHAR)) ))
done
@jamesoff
jamesoff / gist:8581559
Created January 23, 2014 16:21
Teach s3cmd to look in environment for location of its config
--- s3cmd.orig 2014-01-23 15:52:08.000000000 +0000
+++ s3cmd 2014-01-23 15:56:12.000000000 +0000
@@ -1692,7 +1692,9 @@
#optparser.disable_interspersed_args()
config_file = None
- if os.getenv("HOME"):
+ if os.getenv("S3CFG"):
+ config_file = os.getenv("S3CFG")
+ elif os.getenv("HOME"):
@jamesoff
jamesoff / autodns.py
Created February 6, 2014 11:49
Roll your own dynamic DNS with Route53
#!/usr/bin/python
"""
Uses reflect.php on sakaki to figure out external IP and then requests Amazon updates the record for home.jamesoff.net with that
JMS
20131019
"""
HOSTED_ZONE_ID = "Z1BQWQ5LVT6ZAX"
@jamesoff
jamesoff / .zshrc
Last active September 24, 2015 08:59
A couple of useful zsh functions
# Use ag and fzf to pick a result and open it in vim at the matching line,
# plus show the ag results in the quickfix window (needs Ag plugin in your vim)
function agvim () {
CHOICE=$(ag --color $* | fzf -0 -1 --ansi)
if [ ! -z "$CHOICE" ]; then
# Open vim at the selected file and line, but also run the Ag scan
# the ! on Ag! stops Ag jumping to the first match, and the wincmd gives the editor window focus
nvim $( echo "$CHOICE" | awk 'BEGIN { FS=":" } { printf "+%d %s\n", $2, $1 } ') +"Ag! '$*'" "+wincmd k"
fi
}
@jamesoff
jamesoff / 00150.0.txt
Last active December 1, 2015 19:16
TIS-100 saves
@0
MOV UP, DOWN
@1
MOV RIGHT, DOWN
@2
MOV UP, LEFT
@3
@jamesoff
jamesoff / compare-bucket.sh
Last active September 25, 2016 19:01
Script to compare local file checksums with those in S3.
#!/bin/bash
missing_s3md5() {
echo "Can't find/exec s3md5"
echo "Get it from https://github.com/antespi/s3md5 and put in PATH, or export S3MD5 to point at it."
exit 1
}
S3MD5=${S3MD5:-$( which s3md5 )}

Keybase proof

I hereby claim:

  • I am jamesoff on github.
  • I am jamesoff (https://keybase.io/jamesoff) on keybase.
  • I have a public key ASBSO3lGnQgxcM5X_Ze4NCcJMHoRwGx9GRzpsmj-jxJAXgo

To claim this, I am signing this object:

@jamesoff
jamesoff / simplemonitor.service
Created April 15, 2018 18:41
Sample simplemonitor systemd config
[Service]
Type=simple
ExecStart=/usr/bin/python monitor.py
WorkingDirectory=/home/james/src/simplemonitor
User=james
[Install]
WantedBy=multiuser.target