Category Archives: Programming

Bulk Optimizing Images with ImageMagick

The article discusses bulk optimizing images using ImageMagick, a powerful open-source image manipulation tool. The author provides a step-by-step guide on installing and using the software to resize, compress and enhance multiple images simultaneously, reducing their size without compromising quality. The article also includes various command-line examples for different scenarios, such as batch resizing, compression, and format conversion. It is a valuable resource for optimising many images for their website or digital project.

2N® SIP Speaker Auto Provisioning

We’re rolling out a new public address system at work and have opted to install it ourselves because the cost of outsourcing it would have blown our budget. The upside was this enabled us to go for a full IP based system with the savings and still be well under budget. The system we selected… Read More »

Reset User Passwords and Add Missing Users to Active Directory via PowerShell from Google Accounts

MySQL SQL Code SELECT SUBSTRING_INDEX(Google.primaryEmail , ‘@’ , 1) AS ‘SamAccountName’ , AS ‘GivenName’ , AS ‘Surname’ , AS ‘DisplayName’ , CASE CONVERT(SUBSTRING_INDEX(SUBSTRING_INDEX(Google.orgUnitPath , ‘/’ , – 1), ‘ ‘, -1),UNSIGNED INTEGER) WHEN 6 THEN “OU=7,OU=Middle,OU=Students,OU=Users,OU=Thornlie Accounts,DC=tcc,DC=wa,DC=edu,DC=au” WHEN 7 THEN “OU=8,OU=Middle,OU=Students,OU=Users,OU=Thornlie Accounts,DC=tcc,DC=wa,DC=edu,DC=au” WHEN 8 THEN “OU=9,OU=Middle,OU=Students,OU=Users,OU=Thornlie Accounts,DC=tcc,DC=wa,DC=edu,DC=au” WHEN 9 THEN “OU=10,OU=Senior,OU=Students,OU=Users,OU=Thornlie Accounts,DC=tcc,DC=wa,DC=edu,DC=au”… Read More »

Delete Blank Pages from a PDF on Linux Command Line

OK, so I was looking for  a way to delete perceptually blank pages from PDF files in bulk. I found scripts that will remove truly blank pages, but that doesn’t help with pages that have been scanned because they can have just 1 pixel and now they’re not blank. The script below which is running… Read More »

ROT13 Encoder Source Code

The ROT13 encoder is a fun programming exercise that my students enjoyed recently. I have included my source code here in PHP and C. PHP <?php   function rot13($char)   {     $ascii = ord($char);     if (($ascii >= 65) && ($ascii <= 90))     {       $val = ($ascii – 51) % 26;       if ($val == 0)       {         $val = 26;       }       $val += 64;     }     else if (($ascii >= 97) && ($ascii <= 122))      {       $val = ($ascii – 83) % 26;       if ($val == 0)       {         $val = 26;       }       $val += 96;     }     else     {       $val = $ascii;     }     return (chr($val));   }   function main()   {… Read More »

Sanitising User Form Input Before Processing in PHP

Sanitising user form input before processing the data is an IMPORTANT security step to prevent malicious input wreaking havoc on your program or other unsuspecting users. The function below can take the $_POST array as input and return it sanitised for use. function cleanse($input) { // Clean the input before use to make sure we don’t… Read More »