• Show array content in Javascript

    This will send an array to an alert. Handy for a quick debug: – alert(JSON.stringify(dict));    

  • Make a Mac sleep from the command line

    Nice and simple; pmset sleepnow        

  • Unity: Remove AR Support module

    If you’ve installed Vuforia and then decided that it’s a much smarter move to just use the ARKit plug-in instead then you can remove the AR-Support module by deleting it from your Unity install directory. Make sure you close Unity first C:\Program Files\[Unity2017.3.1]\Editor\Data\PlaybackEngines    

  • Unity: UnityEngine.Advertisements.dll could not be found

    If you’re seeing an error when building a Unity project with Jenkins on Windows, and it looks something like this… error CS0006: Metadata file ‘Unity/cache/packages/packages.unity.com/com.unity.ads@2.0.3/UnityEngine.Advertisements.dll’ could not be found …then it’s probably caused by Unity PackageManager (introduced in 2017.2) looking a file in the wrong place. Jenkins uses the SYSTEM account to access files, but…

  • Display local time in PHP

    Need to show the time in local time (Brisbane) instead of UTC: – $datetime = new DateTime; $otherTZ = new DateTimeZone(‘Australia/Brisbane’); $datetime->setTimezone($otherTZ); echo “Last Update” . $datetime->format(‘Y-m-d H:i:s’) . “<br /><br />”;        

  • C# Unix time from DateTime

    Single line to do this one: – Int32 unix = (Int32)(startTime.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; Takes the date and removes the number of seconds that have passed since 1/1/1970          

  • C# List Find and FindAll using Lambda

    Find a list of things that have a given member set to a given value: – List<Thing> foundThings = listOfThings.FindAll(x => x.member == searchParam); if(foundThings.Count == 0) return false; // Do something with the foundThings Find a single thing that matches a given criteria: – Thing thing = listOfThings.Find(x => x.member == searchParam); if (thing…

  • Clamping dates in PHP

    Needed to clamp a unix timestamp in PHP so I could use it for a database lookup. Quick source dump as follows: – $time = date_create()->getTimeStamp(); // Get the initial timestamp $mysqlDateTime = date(“Y-m-d H:i:s”, $time); echo “Before: ” . $mysqlDateTime . “<br />”; // Clamp to Minutes $time = floor($time / 60) * 60;…

  • Get a Mac to show hidden files

    If you’re using finder on the Mac and you can’t see files with a ‘.’ in front of them (.ssh etc) then use the following from a terminal: – defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder

  • Setup an OSX Slave for a Windows Jenkins Instance

    So, I’ve been working on an iOS project in Unity and wanted to build on a PC and just use a Mac for the signing step. This allows me to throw processing power at the build (the PC) and just use a low-end Mac Mini to handle the less labour intensive signing. Technically, a Mac…