Despite my working history in infrastructure, I have always been interested in the development side of computing. I was introduced to programming during school with Visual Basic 6. After school, when I had made the decision to work in IT, I studied at the Computer Power Institute of Technology in various modules including C programming which I excelled at with an A average. See transcript.
PowerShell Hyper-V Backup Script
At Gameloft Australia, we needed a free solution to backup some non-mission critical VMs running on a Hyper-V server. I wrote this Powershell script as a solution to the problem. The scheduled script will pause, export and resume each VM one at a time and send an e-mail log to the addresses specified in the script. Since I first wrote this script I’ve added features like robust error checking, secondary (USB) backup location and automatic backup removal/retention.
These days I would first look at Veeam’s free endpoint backup products.
X86 Assembler Disco Bootsector
X86 ASM, BIOS
I was reading a book about computer history and it inspired me to work with a computer a very low level. I decided to write something fun with X86 assembler. The end result of that was…. Morgan’s Disco Bootsector!
This is a bootable program on any IBM compatible PC that does the following:
- Sets the display to VGA graphics mode (320x200x256)
- Plays ‘Hot Cross Buns’ through the PC speaker (often routed through the sound card on modern PCs)
- Every time the song’s verse ends, fill the screen pixels with random colours.
- Repeat indefinitely!
Video of it is here:
This was a great learning exercise. Here are some of the things I learned about over the course of the exercise:
- PC bootloaders & the magic bytes at 510-512.
- 16-bit ‘Read-mode’ X86 segmented memory model.
- int 10h BIOS interrupts to set screen modes (e.g. character & graphics modes) & writing to the video buffer at 0x0a0000.
- Configuring your PC’s programmable timers (PIT) for timing in your application as well as for the PC speaker.
- Random number generation (linear congruential PRNG)
- Debugging low level code in bochs.
Files (source and binary) are here on GitHub:
Install / testing:
1) You can boot it with QEMU:
qemu-system-i386 c:\asm\bootme.img -soundhw pcspk
2) You can create a bootable USB flash drive by writing the sector with ‘USB image tool’ (Windows).
I based by PC speaker routines off this article so credit to him:
CUDA Poker simulator
C++, CUDA, GPGPU
A work colleague (Simon Eschbach) issued a challenge to write a faster Texas Hold ‘Em poker statistics simulator than he had written and provided source code for his simulator. His only stipulation was that the simulation had to be executed on the work PCs so emphasis was placed on the code.
In the simulation, virtual players are dealt their hand along with the community cards. The player’s hands are evaluated and statistics on the winning player and hand are recorded and accumulated. This happens hundreds of thousands of times on modern CPUs.
After looking at his clean code I didn’t think I could re-write the logic to significantly faster so I took a different approach and decided to try to port his code over to CUDA, nVidia’s GPGPU platform. It was a challenge but I eventually ported his simulation code over to CUDA after re-writing significnat sections to the code to run better on GPGPUS.
In 2015, the result of this work was a simulator that executed 524,288 poker games per second on the 960GTX GPU ($260 device) compared to 453,266 games per second on the i7 CPU ($400 AUD device).
In 2017, the result of this work was a simulator that executed over a million poker games per second on the 1060GTX GPU ($400 device) compared to just over 500,000 games per second on the i7 CPU ($400 AUD device).
The simulation source and diff is provided below. If you want to run the binary, note that you’ll need a maxwell class nVidia card (700 series and up).
- Link to results of CPU simulation
- Link to results of GPU simulation
- Link to CPU simulator source code
- Link to GPU simulator source code (github)
- Link to patch/diff
Confluence Page Management Project:
Cycling performance management pages in Atlassian Confluence
C#, XML-RPC, Confluence, CMS, API
This project was to do with the development and maintenance of a script related to Performance Management at SEGA. Nothing on the market was perfectly suited to us out of the box and as opposed to customising off the shelf solutions and having all employees learn it we decided to add functionality to an existing system staff were already familiar with. This was a CMS by the name of Atlassian Confluence. It featured a good layout engine, easy editing, page security permissions and more. However, it did not have the ability to perform any page management functions in bulk with any sort of intelligence. It did have an API available to make this possible though.
The following program was written in C#/VS Express and connects to Confluence instances via it’s XML-RPC API. The script was executed bi-annually, when employees had their performance appraisals done. Per employee, the script archives the existing performance management pages (PDP, Objectives & Bonuses) and creates new ones from templates (with appropriate permissions). The script would also create a copy only for the employee’s lead that has a special set of permissions. The program had the ability to exclude certain wildcards / names of people where the standard performance management process did not apply and it also gave the executor a final confirmation of the performance management profiles the script would process so as to prevent mistakes. The script was always tested on a test instance before being executed on the live server.
The program had a robust UI & reporting even though I was the only one that was executing it in the event someone may take over the duty if I ever left. As the performance management process was new, the script would be updated every 6 months to suit HR needs.
Here are two screenshots showing it’s interface & evolution:
Here is the binary (.net 4.0 required):
confluence page cycler 2013 Binary.zip
Here is a quick link to view some of the more pertinent code (Functions for moving the employee’s performance pages):
Here is the VS solution to review my code in detail:
confluence page cycler 2013 code VS solution.zip
Archiving disconnected mailboxes on Exchange 2010 to PST
PowerShell, Exchange 2010
We were coming up to our maximum retention time for a lot of disconnected mailboxes in our Exchange instance before they were automatically deleted from the mailbox. We decided for a few reasons we’d like to keep PST copies of these mailboxes. In Exchange 2010 however, the mailboxes need to be connected to an active account for PSTs to be exported. I found a few people online were also looking for something similar but no one had put the work in to automate it, so I did.
The script gets a list of all disconnected mailboxes for a specified server and stores their display names in a variable. It then connects the disconnected mailboxes (one a time) to an enabled AD user (e.g. mailbox archiver), queues the export request and waits for the export to complete before disconnecting the mailbox and continuing to the next user. The display name is used for the file name & the name of the export request.
Recording data in database via XML-RPC of web app
C#, XML-RPC, VeMail API
A recurring request from clients for a web application I was supporting (VeMail/Vision6) was the ability to ‘scrub’ their database. The database contained lists of contacts that received marketing e-mails. As clients were charged on the number of contacts in their database (& subsequently the number of e-mails they send) and the system recorded who opened the e-mails, clients wanted to remove the contacts who weren’t opening them. The existing solution was very manual and only allowed clients to view if contacts opened one of the last 3 e-mails.
I decided to create a script/program that would automate this very manual process and also allow clients to see if their contacts opened any previous e-mails as opposed to just the last 3.
This program was made in C#, leveraging an XML-RPC.NET library to connect to the clients database via the VeMail API.
Here is a screenshot:
Here is the binary:
Here is the code:
Bulk reports & e-mail message downloader
HTML/CSS, VBS, XML-RPC, VeMail API
A client asked if we can provide a downloadable copy of the data existing in her account. Specifically, a copy of every message sent through the system (e-mail marketing) & amalgamated reports generated from the aforementioned e-mails. The development team was able to pull some of this from the backend but it did not include amalgamated reports, downloaded images or rewrite the html so the images would work locally and a few other things the client wanted. I decided to write a script to download the data in a more useful format. The client was happy to wait and it’d allow the development team to keep working on the product itself.
This application leverages an XML-RPC COM library to communicate with the API of the VeMail online marketing system. It then downloads the emails, images, changes the code so the images work locally, downloads the individual reports, compiles an overview report and saves it to Excel spread sheets.
This application has a nice, clean interface and is simple to use. You simply provide it your VeMail username, password and a destination folder. Once you hit GO, The application will provide reports as to what the application is doing.
Here are two screenshots:
Here is the binary:
Here is the source code: