Menu Home

Generating lotto numbers

A client joked today about predicting lotto numbers. This post doesn’t claim to do that, obviously, but I realised that I can use my rand script to generate some random lotto numbers. Obviously the below adheres to the NZ Lotto format of 6 numbers under 40, a bonus ball under […]

Portably(ish) generating random integers

[160309/20:49][rawiri@minty ~]$ rand -h rand – generate random positive integers Optional Arguments: -c [count. Number of numbers (Default:1)] -d [debug. Tells you which processing method is used (Default:off)] -h [help] -m [minimum number (Default:1)] -M [maximum number (Default:9223372036854775807)] TL;DR: I made a script that should generate a random integer for […]

Beating the vendor by 3 weeks

So a client has a vendor supplied python script that routinely connects to said vendor’s servers and downloads files. I won’t go into too much detail, but it’s a pretty important file transfer with far reaching financial influence, and we’ll leave it exactly at that. So, as you can guess […]

Host your own shellcheck

For those of you who don’t know, shellcheck.net is a fantastic resource for improving your shell scripts.  When I came across it, I felt that I was a pretty good scripter.  How wrong I was.  Using shellcheck has probably been the single most influential factor on my scripting since the […]

Mass-diffing files

As part of my day to day tasks, I’m auditing configuration files and tidying them up. Slowly, we’re moving towards standardised files and configuration management. The first requirement of this is gathering the existing config files into one place. You could do this with any of a number of tools, […]

Time limited sudo rights using at

From time to time, a person may require sudo rights to a particular server for a limited time. If it’s a Linux host, we can use the at scheduler and a /etc/sudoers.d conf frag to automate this. Essentially, we use at to automatically remove the conf frag when the user’s […]