[C++] Bit-flags

Introduction

Bit-flags are used in C and C++ to save memory by allowing you to pack multiple boolean variables into a single integer variable.

While they are very good at this, the syntax for using them isn’t exactly the easiest to read, so I thought I’d share a trick we use at work to deal with bit-flags.

Read more of this post

Introduction to premake4

Introduction

A while back I wrote a blog post based on my experiences using the CMake build system. The conclusion from this was that I found CMake to be a useful tool, but pretty painful to work with due to it using a custom scripting language and being quite lacking in the documentation and support departments. In short, it was something I tolerated rather than enjoyed using.

These issues meant I was open to alternatives, but I never looked for any until I read an AltDevBlogADay post on meta build systems which mentioned premake. Now premake was something I had looked at before when I was looking for a build system, however I discounted it at that time (I can’t remember why now) so I figured I’d take another look at it.

In trying it out, I found that I actually like it (far more than CMake). It’s nice and simple, uses Lua as it’s scripting language (so anything you can do in a standard Lua script, you can do in a premake script), and has excellent documentation and support.

Read more of this post

Tune drop

While we wait for my muse to kick in for some non-meta blog posts, here’s some tunes that I’ve found/been shown recently that are really worth sharing.

The first one is Portal 2 related (and probably spoilerish); there’s a song in the game called “Exile Vilify” and someone took that, mixed it with some rain, and put it all on a website. The result is quite impressive, as I’ve found myself listening to this for hours while working and not even realised it’s looped. You can find it on the appropriately named website Chell in the Rain.

The second two tunes were sent around by a colleague at work. I have a bit of a soft spot for chip tunes, and these two are made by Maniacs of Noise (one of which is 23 minutes long and makes excellent background music while working).

Finally, if you like those two tracks above then I’d also recommend checking out the Super Meat Boy OST.

It’s been a while…

Okay, so it’s been ages since I last made a blog post. It’s not that I don’t have things to talk about, I have several things I want to talk about in fact, it’s just I never seem to get off my arse and write about them (to be fair, the whole “getting off my arse” statement fails in this context as I can’t type very well when standing up, so I would most definitely have to be on my arse to make a blog post).

First things first. This blog has now moved from tumblr to WordPress, the main reason for this being that WordPress has much better support for posting code than tumblr. I’ve ported over most of the posts from the old blog, but all the comments have been lost, still, there weren’t many so it’s not a huge loss.

Now, as for the things I have to talk about, below is the subset of things which have happened to me in the time between my last blog post and now that I feel are blog post worthy topics. Hopefully in the coming weeksmonths I’ll make time to actually write them.

Read more of this post

My experience using CMake (and a tutorial)

Introduction

For those of you that don’t know CMake is a cross platform build system that allows you to define what you want to build and how, before it goes off and creates the correct build scripts for your particular platform and compiler. It is supposed to help you to simplify your build process when compiling for multiple platforms by just having to maintain a single build script that can generate all other build scripts.

Generally I never had a use for a such a thing since I did all my work on Windows with Visual Studio however when I started doing work I eventually wanted to use on Linux too, I knew I had to look into something. OGRE had started using CMake to generate its build scripts, so I thought I’d look into that. This turned out to be much harder than I expected considering the documentation for CMake seems to range from poor to non-existent and that the examples they link to are either really quick overviews, or really contrived and complicated.

Still I persisted, and with the use of the OGRE CMake files as an example, and with the help of jacmoe and CABAListic I managed to get a CMake file that worked. It was ugly, it was all in one CMakeLists.txt file (which you shouldn’t really do) but at least it managed build two of my libraries on Linux. Of course, I was never able to test if these libraries ran on Linux since I never worked out how to link those libraries against an executable (or even how to recurse into my examples directory so I could attempt to build the examples). After 6 months I figured it was time for me to work out how to use CMake “properly”, I made myself a simple test case that represented what I ultimately needed to do, and then tried to build the CMake script to generate the correct build scripts for it.

Read more of this post

If they’re Ninja’s, why can I see them?

Also, why are they dressed in green?

My AI assignment demo was finished and handed in. My extension task was behaviour trees and there is a video of the demo below, all in nice shiny HD.

Setting up nForce in Windows 7

I’ve recently installed Windows 7 on my main PC, removing the old Vista install. While doing this I had some issues getting my on-board nVIDIA nForce 6 network drivers working, and from looking around the internet, I am not alone.

The solution that eventually worked for me is as follows:

  1. Shut down your PC and turn it off at the mains for ~20 seconds.
  2. Turn your PC back on and boot into Windows, it should now be able to see and use your nForce network adapters to access the internet, however if you restart Windows you will find that the adapters become disabled again.
  3. To solve this, go to the nVIDIA website and download the correct nForce drivers for your motherboard, and then install them (you will only be able to install the network drivers if Windows is currently able to use the adapters, so if they are disabled, you will need to repeat step 1 before continuing).
  4. Reboot your PC and you should now find that your network adapters are working, and will also continue to work after you restart your PC.

Setting up Redmine on WebFaction

Since this is something I have recently had to do, and found the documentation to be out of date, I though I would share this working solution with you all. This is based on Redmine 0.9.x, and thanks to Sean F from WebFaction support, these instructions are mostly his.

Read more of this post

New Webhost

I have now finished the move of all my websites from Hostgator to WebFaction. I’ve been with Hostgator a while now, and while they have been okay, it wasn’t until I set-up the Insimnax website that I noticed how slowly they actually served content; I let it be for a couple of months before I decided to move.

I considered getting myself a cheap VPS, something I had done before but was left a little unsatisfied with. While I was looking around I came across WebFaction, they essentially manage to provide shared hosting which is very VPS like. While you don’t get full access to the server, you do get SSH access and the ability to install pretty much anything considering the sheer amount of applications they have available.

I had been pretty frustrated when I set-up the Insimnax website that I had to use three different pieces of software (Pixie, MediaWiki, and MyBB) to get all the functionality from the site that I wanted, I would have much rather just used one thing and be done with it. To this end, when I set-up the site again on WebFaction, I just used their one-click installer to create a Ruby on Rails application and installed Redmine. Now not only is the site significantly faster than it was before, but all my content for the Insimnax website is hosted in a single piece of software which makes it easier for me to maintain and manage.

In addition to being able to create a Rails application, you can also do some other nifty things with them. Is your website running slow because it is trying to serve a lot of static content through Apache? No problem, with WebFaction you would just create a nginx application to handle all your websites static content, and then use your Apache application to only handle your dynamic content. What’s more, because you have SSH access to all your applications, you can tweak the configuration files for them to your hearts content just like you could with a full VPS or Dedicated server. This to me actually makes WebFaction better than a VPS, since the actual OS and server installation is handled by them (including updates) which leaves me to just worry about the things that these applications are serving.

My next plan with this new account is to create a Subversion application and migrate my Assembla SVN repository for Insimnax to WebFaction. This will offer me several advantages; firstly it will allow me to integrate my SVN repository into Redmine; secondly it will allow to me to let others view my current trunk, because; thirdly it will allow me to give specific access to just the parts of the SVN repository that I want to be seen by the public. This is something I will be able to do since I will have access to the SVN users configuration file, something that is hidden from me at Assembla, and since Assembla has yet to implement per-directory access rights on their SVN repositories, something I simply cannot do with Assembla hosting.

I will leave you with this piece of information. While I was waiting for my DNS information to propagate, I could traceroute both servers and I found that they were both hosted at the same data centre (The Planet), and both gave me the same ping of ~162ms from my location here in England. However the WebFaction server was the one that gave me the fastest response to my requests, and since the network statistics for both were the same, I can only assume that is because the WebFaction servers are; better configured, have less load, or both.

Templates and Streams; the perfect couple

Recently I’ve been doing some work templatifying my two I/O classes, and from that have come to the conclusion that templates and streams make for the ultimate generic programming tool. Previously I had a load of old duplicate bloat code in these classes, that was all removed and replaced by one templated member function, and two specialised template functions from it, and best of all since this code is now able to take external streams as input/output sources, it means that I no longer have one code path for handing files, and another code path for serialising to memory. Instead I just pass an fstream when working with files, and a stringstream when I want to serialise to/from memory, simple!

Read more of this post

Follow

Get every new post delivered to your Inbox.