onsdag 9 oktober 2013

Compacting Virtual Box Drives

Too many times I've forgotten the exact commands on how to compact the virtual drives. Especially for windows, where the tool used, used to have a different name of the argument passed to it. Compacting the drive can save you lots of disc space (last time my drive went from 12GB to 5GB), and for a smaller lap top drive, that makes a big difference.

Windows Guest:
Download SDelete from SysInternals and then run

Linux Guest:
Here, we create a file that fills the entire empty space, and then deleting it:
Host:
Finally, you let VirtualBox compact the drive

That's it really! I hope I'll remember it a little better this time.

Further info:
Use “sdelete -z” when Shrinking a Windows Guest’s Virtual Hard Drive
How to Compact a VirtualBox Ubuntu Guest’s VDI file



lördag 8 juni 2013

Qt Plugin Cache

When upgrading an application to use a newer Qt version (4.8), I stumbled across a weird issue with the sql plugin not loading correctly. Even though I triple checked the paths, it didn't work.

This was surprising since if I used the previous Qt version (4.7), my app worked fine!

After much trouble shooting and testing and googling, it turns out that there is a thing called the "Qt Plugin Cache"!

måndag 28 januari 2013

git (msys) + merge + araxis

I struggled with setting up the git environment for my windows environment.
And since it's easy to forget these things, I'll just add the command lines for it here:


lördag 5 januari 2013

binpacking + fonts

Skyline-BL (Bottom Left) with
rects sorted on height. Rotation of
the rects were not enabled.
During the holidays, I've been working with my hobbyist project of generating bitmap fonts. One of the issues I hadn't looked into yet was the problem of wasted space between the glyphs and rows. And while I still wasn't actively looking to solve that problem just yet, I stumbled upon a good read by Jukka Jylänki - "A thousand ways to pack the bin - A practical approach to two-dimensional rectangle bin packing" from 2010.

It was a nice explanation of the most common bin packing algorithms and it also came with public domain source code (Thanks Jukka!)





torsdag 9 augusti 2012

Compile Time Hashes pt2

While waiting for Visual C++ to implement the C++11 features I wrote about in the previous entry, I wanted a solution that worked on windows. This time I needed to implement the hashlittle function found in lookup3.c.

I used template programming to get the size of the string at compile time and I also relied on the compilers to optimize the code into the final result.

You can download the final code here: hashlittle.zip
Update (2012-08-20): Fixed bug in function for edge cases where the string was a multiple of 12 (doh!)

torsdag 12 juli 2012

Compile time hashes

C++11

Recently I’ve seen more and more of the C++11 features in the code reviews I oversee, so I needed to read up on the details. Some of the features were already featured in the C++0X standard, which has been semi-supported for some time now.


The second link will give you a hint of what’s supported for various compilers. Unfortunately, no current compiler supports C++11 entirely. And as usual it’s that MSVS is the farthest behind the standard.

The resulting files have been zipped together for your convenience: mm3hash.zip

fredag 25 maj 2012

ctypes + 64 bit windows + libclang.dll

This post is mostly for my own reference for the future.

I ran into trouble when using clang with 64 bit ctypes on a windows machine. Apparently there's a bug reported on the issue.

On windows, the compiler will convert arguments larger than 8 bytes into references automatically, whereas ctypes just happily allocates memory for the stack, ignoring the this fact. That leads to crashes.

I tried recompiling the _ctypes.pyd file, but that only caused my Python to hang. So, until that bug is fixed, I have to use the POINTER construct in ctypes instead.

The guys implementing the Sublime autocompletion plugin has solved it this way: cindex.py