-
Add a user to a group on OSX
Quick and easy adding of a user to a group on OSX sudo dscl localhost -append /Local/Default/Groups/thegroupname GroupMembership theusername
-
Speeding up MySQL queries using an index
If you’re doing a query on a very large db then always make sure you’ve got an index on fields that are being used to group (WHERE) data. In my case, I was doing a query on a table with 249M entries that was using a WHERE on a ‘symbol’ field. By adding an index…
-
View Users on OSX
From the commandline: – dscl . list /Users
-
C#: Clamping a datetime to an arbitrary TimeSpan
To clamp a datetime to an arbitrary TimeSpan: – delta = a_dateTime.Ticks % TimeSpan.FromHours(1).Ticks; a_dateTime = a_dateTime.AddTicks(-delta);
-
Unity: Transform has SetIsDispatchInterested present
If you’re getting the Unity assert: “Assertion failed: Transform has SetIsDispatchInterested present when destroying the hierarchy. Systems must deregister themselves in Deactivate.” This error is corrected in Unity 2017.3.1p3 (or above). This is happening whenever a collider is disabled on a GameObject which is not currently activeInHierarchy.
-
Unity: Run an action on all children of a gameobject
Handy piece of code that will run an action on all children of a gameobject. using System; using UnityEngine; public static class UnityExtensions { /// <summary> /// Run an action on all children of a gameobject /// </summary> public static void RunOnChildrenRecursive(this GameObject a_go, Action<GameObject> a_action) { foreach (var child in a_go.GetComponentsInChildren<Transform>(true)) a_action(child.gameObject); } }…
-
C# Stopwatch Extension
Nice little extension to the stopwatch to allow for easy testing of the speed of a given method. Found here public static class StopwatchExtensions { public static long Time(this Stopwatch sw, Action action, int iterations) { sw.Reset(); sw.Start(); for (int i = 0; i < iterations; ++i) { action(); } sw.Stop(); return sw.ElapsedMilliseconds; } } To…
-
Unity: Destroy all child GameObjects
This will destroy all child objects of a given GameObject (‘go’) : – // Remove all child objects foreach (Transform child in go.transform) Destroy(child.gameObject);
-
Javascript: Run code every ‘x’ seconds
Snippet of code to run code every second. Doesn’t trigger the next iteration until the first has finished. (function() { // Do something every second here setTimeout(arguments.callee, 1000); // 1000 is the time in milliseconds })();
-
Installing Node.js on Windows
Download the Windows installer from here Nothing complex. Just click the ‘Next’ until the installer finishes and then restart the PC. Once the PC has restarted, open a command line (or Bash Window) and type npm -v. If you get a version number then the install worked fine. To run js code, simply type node [file.js]…
