-
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…
-
Constructor and Destructor in PHP
Example of constructor and destructor in PHP. Pretty simple syntax. Two preceding underscores. <?php class MyDestructableClass { function __construct() { print “In constructor\n”; $this->name = “MyDestructableClass”; } function __destruct() { print “Destroying ” . $this->name . “\n”; } } $obj = new MyDestructableClass(); ?>
-
Auto-Loading classes in PHP
Back to getting up to speed on PHP. This is a quick snippet of code that’ll probably come in handy: – <?php spl_autoload_register(function ($class_name) { include $class_name . ‘.php’; }); $obj = new MyClass1(); $obj2 = new MyClass2(); ?> This will auto-load a php file with the class name requested when the class is used. Assuming the naming standard is followed correctly this will be a…
-
Setup a mac to allow ssh login without a password (PC to Mac in this example)
We want to be able to login to a mac using ssh but don’t want to type a password every time. This is done by allowing Remote Login for a given user on the Mac and adding a public key to the Mac for the PC you’re logging in from. On the mac, make sure…
-
SVN Command line: Local Changes
To see the current list of local changes in an SVN repos: – svn status This will show anything that’s been changed locally that isn’t yet committed.
-
float[] to IntPtr
Create a pointer from a float[] to allow passing to openGL to create a texture. var floatPointer = GCHandle.Alloc(a_frame.left, GCHandleType.Pinned); gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_RGBA, Utility.GetNextPowerOfTwo(a_frame.width), Utility.GetNextPowerOfTwo(a_frame.height), 0, OpenGL.GL_RGBA, OpenGL.GL_FLOAT, floatPointer.AddrOfPinnedObject()); floatPointer.Free();
-
Playing with Parallel.For to optimise image conversion
Code snippet from an evening spent playing with Parallel.For to speed up image processing on an 8 core PC static long[] averageTicks = new long[100]; static int currentOffset = 0; byte[] byteArray; public byte[] GetOpenGLBuffer() { int powWidth = Utility.GetNextPowerOfTwo(width); int powHeight = Utility.GetNextPowerOfTwo(height); if(byteArray == null) byteArray = new byte[powWidth * 4 * powHeight];…
-
Sorting a list by a specific field
Use Linq. Not the fastest, but quick and easy… using System.Linq; List<NodePos> sortedNodes = nodes.OrderBy(o => o.distance).ToList();
-
C# Types
Value Types bool byte char decimal double enum float int long sbyte short struct uint ulong ushort Reference Types class delegate dynamic interface object string
