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 / AAA VBA Snippets Readme.md
Last active June 3, 2022 14:25
VBA Snippets for Sharepoint Sync, Base64(sha1(AES(MESSAGE))), HTTP requests and other misc functions :)

This code is largely derived from sources found online. As such, I didn't think it was unreasonable to compile it into a series of extracts to use in your own projects.

In here we have code to perform an off-line sync with sharepoint lists, to perform an HTTP request, to check whether tables exist, and drop them if they do, and to produce Base64 encoded SHA1 signed AES ecrypted (with multiple rounds) text.

Function names:

  • ResyncWithSharepoint(URL)
  • SyncTable(TableName) (Note this depends on the tables having a Sharepoint Link already established with the prefix sp)
  • HttpOK(URL)
  • Sleep(microseconds)
  • ifTableExists(tableName, DatabaseFileName)
@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"
@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(
@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 / 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 / wait_for_network.sh
Last active May 17, 2023 10:06
Wait for the NIC to be assigned an IP address, then wait for google's DNS to respond, and then sleep for rand(30,600), used like this `wait_for_network.sh && do_something`
#! /bin/bash
# This script checks that the interface is up, and that an internet connection is available
# It is based on code from http://askubuntu.com/questions/3299/how-to-run-cron-job-when-network-is-up
#
# Then it sleeps for a random number of seconds between 30 and 600.
# This is based on code from http://tldp.org/LDP/abs/html/randomvar.html
#
# Collated by @JonTheNiceGuy on 2015-10-15
# Fix from @p1r473 on 2023-05-17 with thanks!
@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 / Regex To Match Interface Details
Last active March 24, 2020 15:21
Regex to match Interface details
IPSO Trunked Non-VRRP (run ifconfig -a)
lname\s+([^>]+)\s+flags[^>]+>\s+vlan-id\s+(\d+)\s+inet mtu \d+\s+(inet ([\d+\.\d+\.\d+\.\d+]+)|([\d+\.\d+\.\d+\.\d+]+))\/(\d+)\s+broadcast\s+\S+[^>]+>\s+ether\s+(\S+)
ifname 1
vlan 2
ip 4 or 5
subnet 6
mac 7
IPSO Trunked VRRP (run ifconfig -a)
@JonTheNiceGuy
JonTheNiceGuy / COMBINED TESTING
Created July 8, 2015 09:46
MS Access VBA to perform AES encryption, Base 64 encoding and create SHA1 hashes
Sub test()
Dim SourceString As String
Dim InterimString As String
Dim DestinationString As String
SourceString = ""
InterimString = ""
DestinationString = ""
Do Until Len(SourceString) > 220
@JonTheNiceGuy
JonTheNiceGuy / ddns-update-multi-source
Last active May 1, 2019 00:28
This is a DDNS updater for the freedns.afraid.org service. It updates the DNS entries for two separate connected IP networks (for example, if you have work and personal ADSL) by amending the routing on the box. Note, you'll still need proper routing once it's inside your network!
#! /bin/sh
# Authored by Jon Spriggs ([email protected]) on 2015-03-10
# Based on the DDNS script at afraid.org
#!/bin/bash
# ALTERNATE ROUTE
# This is the path for the second DDNS update to take
NEW_ROUTE=192.168.1.1
# TUNNELBROKER.NET CONFIGURATION