Skip to content

Instantly share code, notes, and snippets.

View JonTheNiceGuy's full-sized avatar

Jon "The Nice Guy" Spriggs JonTheNiceGuy

View GitHub Profile
@JonTheNiceGuy
JonTheNiceGuy / Redirect.php
Created March 21, 2014 21:54
This script is deployed on jon.sprig.gs/redirect.php and those are linked to from /var/www/t -> /var/www/redirect.php etc.
<?php
switch($_SERVER['REQUEST_URI']) {
case '/t/':
case '/@/':
case '/twitter/':
redirect("https://twitter.com/JonTheNiceGuy");
break;
case '/fb/':
case '/facebook/':
redirect("https://www.facebook.com/JonTheNiceGuy");

Keybase proof

I hereby claim:

  • I am JonTheNiceGuy on github.
  • I am jontheniceguy (https://keybase.io/jontheniceguy) on keybase.
  • I have a public key whose fingerprint is 165D CE43 94BA 1D2B 5C40 77D8 46C7 BB36 7C28 E565

To claim this, I am signing this object:

@JonTheNiceGuy
JonTheNiceGuy / compare.sh
Created December 23, 2014 13:37
Migrate audio files to OGG format
#!/bin/sh
if [ -z "$2" ]; then
dpath=/media/usb0/Multimedia/Audio/
else
dpath="$2"
fi
if [ -z "$3" ]; then
spath="`pwd`"
else
spath="$3"
@JonTheNiceGuy
JonTheNiceGuy / Links
Last active August 29, 2015 14:13
I am who I am...
@JonTheNiceGuy
JonTheNiceGuy / Vagrantfile
Created August 12, 2015 13:57
Make your Vagrantfile pull from a common puppetserver rather than using local modules
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "demo.lan"
config.vm.network "public_network", ip: "192.0.2.1", bridge: "eth0", :use_dhcp_assigned_default_route => true
@JonTheNiceGuy
JonTheNiceGuy / findgit.sh
Created October 20, 2015 21:27
Find a commit which references a piece of text (I use this in https://github.com/garethr/vagrantboxes-heroku)
#!/bin/bash
git log -S"$1" -- www/index.html | grep commit
@JonTheNiceGuy
JonTheNiceGuy / alt-tab.ahk
Created November 20, 2015 08:17
Need something to rotate around windows on your Windows Desktop or RDP screen? This will do it! :) Requires AutoHotKey
InputBox, Sleep_Period, Alt-Tab-Script, How long do you want to wait between alt-tab - default 1 minute, , , , , , , , 1
InputBox, Number_Windows, Alt-Tab-Script, How many windows (max 6), , , , , , , , 3
SleepTime := ((Sleep_Period * 60) * 1000)
MsgBox, Sleeping %SleepTime%
Loop {
sleep, %SleepTime%
if Number_Windows = 2
{
Send, {alt down}{tab}{alt up}
}
@JonTheNiceGuy
JonTheNiceGuy / init.pp
Created December 12, 2015 21:57
Want to set a username and password in Puppet? Keep getting "You reset the password for a user 8m times" in your logs? This may be the gist for you! Only really works if you've got a consistent user salt across all your boxes :)
define createuser (
$username = $title,
$password = 'defaultpw',
$groups = ['users'],
$home = "/home/${username}"
$shell = '/bin/bash') {
user { $username:
ensure => present,
password => generate(
spriggsj@Minilith:~/HTIW/one$ ~/showoff/bin/showoff serve
WARN: pdf generation disabled - install pdfkit
-------------------------
Your ShowOff presentation is now starting up.
To view it plainly, visit [ http://localhost:9090 ]
To run it from presenter view, go to: [ http://localhost:9090/presenter ]
@JonTheNiceGuy
JonTheNiceGuy / x_sudo.sh
Created December 30, 2015 15:37
Need to use X as a user on a box after Sudo? Try this. Both files need putting somewhere in the path, and need chmod 755 owned by root.
#! /bin/bash
if [ -n "$DISPLAY" ]; then
CURRENTDISPLAY="`echo $DISPLAY | cut -d ':' -f 2 | cut -d '.' -f 1 | sed -e s/^/:/`"
DPYNAME="`xauth list | grep "$CURRENTDISPLAY" | cut -d ' ' -f 1`"
PROTONAME="`xauth list | grep "$CURRENTDISPLAY" | cut -d ' ' -f 3`"
HEXKEY="`xauth list | grep "$CURRENTDISPLAY" | cut -d ' ' -f 5`"
fi
if [ -z "$1" ] && [ `id -u root` == '0' ]; then
SU_TO="root"