Applications I Use 2: gfxCardStatus

Heres a little handy app that works quite well. Specific to Macs with Dual Graphics cards, normally the only way to change cards is to log out and log in again, after changing the preference under Power Settings. You have one for Power Saving and one for High Performance graphics.

Cody Krieger (@codykrieger) wrote a handy little App that will let you change Graphic Cards without having to logout, quite handy if you want to just muck about for a bit and then open up Team Fortress 2, or do some Video work.

So I present today gfxCardStatus.

As the Author writes:

gfxCardStatus is a menu bar application for OS X that allows users of dual-GPU 15” and 17” MacBook Pros to view which GPU is in use at a glance, and switch between them on-demand.

Most of the time it spends all its time just in my Task Bar sleeping showing which card I have enabled (i for the power saving low powered card, and d for the high-powered card).

It works quite well, sometimes you request a change and your machine won’t honour it straight away, normally this is down to another application doing something graphics heavy, so locking the control out.

One useful feature built-in is the ability to auto switch the graphics card in use based on the current power source.
Which I don’t personally use, but then I tend to hot swap between on/off PSU far too often.

I’ve a couple of options missing and some different settings available, but it depends on what model of Mac you have and the Graphics Card present in your machine.

All in all its quite a handy little app, and its Free. You can download it from http://codykrieger.com/gfxCardStatus and start using it straight away.

Kerbal Space Program

Randomly follow a @Notch Tweet on Twitter about a game he was being shown, called Kerbal Space Program. I followed the link, downloaded the demo, and about 10 minutes later my money was sent on its way….

It’s rather good fun. The general aim of the game is to build a space rocket and launch it.
Heres an introductory video:

This movie requires Flash and Javascript

And with just a few stock parts you can build some clever, silly and just explosive rockets.

Fun times have been had, my best so far was one that the moment it was placed on the Launch pad and launched, decided to fall apart leaving just a single engine attached to my rocket. (And a small explosion). My Kerbanauts survived to launch the next time.

Anywho, this morning I decided to restart my entire Space Center (after successfully retrieving all my Kerbanauts from their epic intrepid 29 day mission), so nuked and redownloaded KSP, and so far I’ve accidentally launched into a Sun Orbit, and crashed into the Mun. All from sunny Kerbol. Took some screenshots this time around.

This time around I was trying for a Mun shot, but I wasn’t paying attention to how the orbit was changing, and ended up sending them out and away into a Escape Trajectory for Sun Orbit (they are also out of Fuel).
Pretty much the same deal with the second group, but instead of attaining a useful Mun orbit. ended up have to wait 9 days for the Mun to come into alignment with their orbit.

The Mun’s gravity then dutifully caught them and I didn’t have enough fuel to slow down. And Boom Crashed 🙁
This means adding another stage to my rocket so more fuel in orbit/space me thinks.

Anyway onwards and upwards. Hopefully will make a successful Mun landing and return my Kerbanauts, more likely more explosions…. and very very silly rockets….

You can check out more about Kerbal Space Program, over at their Website their Twitter: @KerbalSpaceP or Tumblr, its in active development so expect more features soon! (Including docking YAY SPACE STATIONS) checkout the KSP Forums too, as KSP fully supports Plugins and Mods.

Its available both on Mac and PC, and you can download the Free Demo, locked at Version 13.3 current release is Version 14 (which includes persistence, the ability to have multiple craft up at once HURRAH!)

Applications I Use 1: Caffeine

Because I don’t often have a lot to write about, thought I would start a new string of posts on Applications I use on a regular or semi-regular basis.

Today I’m starting with a little App that sits in my Mac Menu Bar. And Looks like a coffee cup.

Its called Caffeine and has a single function.
When enabled it stops the screensaver from running and the Mac itself from going to Sleep.


In addition to just enable/disable, it can be enabled for a 5/10/15/30 mins or 1/2/5 hours.

Quite a handy app if you are running something like a flash video that doesn’t quite trigger the no screensaver rule, or if you need to stop the screensaver running, and munching system resources, like video rendering. Or of course Power Point/Keynote Presentations.

There is nothing else to say about it really. It’s a handy little App with no little task and just sits there waiting to be enabled.

The odd person has had the odd issue with it, probably down to running other Power setting adjuster programs but it’s generally well reviewed in the App Store.

Its available in the Mac App Store and its Free.

MineCraft Math

So, I tend to now and again do random bits and pieces to MineCraft Servers.

Of late I have been working with ZimDoorCraft, took the existing relatively static site, and flipped it over to a Mini PHP Powered Content Management System, that I wrote and roll out to smaller sites.
Couple of MySQL powered bits to make updates easier (Staff list and the like).

In time more complex and interesting things will be added (it was for a while running a Login with Mojang/MineCraft account, but that means you type your MineCraft login into the site…), how that works is a subject for another post. As is what ever I build next 😀

The MineCraft server in this case is running a derivative of Bukkit, which means it supports plugins, so we are using the JSON Api plugin, and making a call to the getWorld() data resource.
Which passes back information about the world in a nice handy format.

Heres an example

    [world] => stdClass Object
        (
            [remainingWeatherTicks] => 14670
            [hasStorm] => 
            [time] => 4964
            [environment] => normal
            [isThundering] => 
            [name] => world
            [fullTime] => 2903932964
        )

If your running Vanilla you can grab the same information just by decoding the level.dat file in the World Directory, however opening a file currently being written to, is not often a good idea, and the level.dat is written to a lot.

Like a lot of games, Minecraft uses ticks, in this case operating at 20 ticks per second, and running to 24000 ticks per Minecraft day, which means a Minecraft day is about 20mins.

Just to be interesting 0 ticks is Sunrise, rather than midnight. And midnight itself is 18000 ticks.

Also contained in the data packet is a count down to when the weather changes, in this case there are 7500 (ish) ticks to go.

Which works out as

14670 / 20 to get Real Seconds = 733.5 Seconds, and then its arbitrary to flip this to a human readable time. We have about 12 minutes, or half a MineCraft day, until the weather changes.

Reading out a more recent packet

    [world] => stdClass Object
        (
            [remainingWeatherTicks] => 7339
            [hasStorm] => 1
            [time] => 3827
            [environment] => normal
            [isThundering] => 
            [name] => world
            [fullTime] => 3902379827
        )

Looks like there is a storm on…. But its only Rain no Thunder and Lighting. With 6 mins to go.

On a side note!, watch out for FullTime, as its likely to run away, on a long running server, to something a 32 bit system might not be able to handle! Refer to my Post on Facebook and the Order ID on some thoughts about dealing with that.


Using Tick to Seconds math, means that it is also possible to display the current server time and weather on the website.

I’m using a bit of CSS, and the MineCraft time piece (craftable in game) to show the current time visually. In this case I’ve taken the 16×16 PNG’s and expanded them (by hand) to 32×32, finally converting the time from ticks to the relevant chunk of 360 degrees, offsetting as needed to account for the fact that Sunrise is 0 instead of Midnight.

I do this by adding 6000 ticks and from there treating the ticks complete as a percentage and scaling to meet 360 degrees. Some of the code involved needs a little tweaking and tidying to improve efficiency, but the angle is being calculated by a CRON Job powered script and stored with the full World JSON packet, in an extended object and cached in a file on the file system ready to be read by the web server when a request comes in. So it’s not a top priority to clean up yet.

I was finding that after taking into account the addition 6000 ticks to offset for Sunrise, the whole Sun Moon picture was upside down. So I just added 180 degrees, and corrected it when the angle was greater that 360. Since why bother rotating thru a whole 360 degrees?


$time = $world->time;// grab from data packet from JSON Api Call
$time += 6000;// add 600 for sunrise

// work out the scale factor 360 degrees / ticks in a Minecraft day
$scale = 360 / 24000;
$angle = $scale * $time;// calculate the <span class="hiddenGrammarError" pre=""><span class="hiddenGrammarError" pre=""><span class="hiddenGrammarError" pre="">angle
$angle</span></span></span> = number_format($angle, 0);// clean up
// correct
$angle = $angle + 180;// the image is upside down 🙁
if ($angle >= 360) {// clean up again
	$angle -= 360;
}

The rotation component was quite difficult to initially decide how to do, PHP wasn’t quite cutting it so switched to a CSS Transform.
HTML wise it consists of a pair of divs, a pair of images, and a chunk of CSS.

<div class="worldtime"><div class="inner"></div></div>


WorldTime being the one behind contains the Sun Moon Picture as a background image.


And Inner contains the Watch overlay also as a background image.

Apply the CSS transformation to rotate the Sun Moon Picture is just a little nasty, because in rotating the Sun Moon picture it also rotated the overlay (inner).
I decided to apply rotation to the overlay, in the reverse direction (so just sticking a negative sign in front).
Works quite well, but if you can think of a better way to spit out this with the rotation please comment below.

Heres my current Style Code

<style type="text/css">
	.worldtime .inner {
		width: 32px;
		height: 32px;
		background: url('large_watch.png') left top no-repeat;
	    /* CSS3 then proprietary code */
	    rotation: -336deg;
	    -webkit-transform: rotate(-336deg);
	    -moz-transform: rotate(-336deg);
	    filter: progid: DXImageTransform.Microsoft.BasicImage(-rotation=4);
	}
	.worldtime {
		float: left;
		width: 32px;
		height: 32px;
		margin: 0 10px;
		background: url('large_inner.png') left top no-repeat;
	    /* CSS3 then proprietary code */
	    rotation: 336deg;
	    -webkit-transform: rotate(336deg);
	    -moz-transform: rotate(336deg);
	    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=4);
	}
</style>

The whole WorldTime Div is then wrapped in another Div and jQuery used to once per minute go and fetch the updated time, weather and CSS rotation.

At first I did try using the PHP function to rotate the image, but the quality drop off when rotating by an angle not divisible by 90 was shocking.
So ended up resorting to CSS, which does work a hell of a lot better.

This only covers how to do this using the JSON API, in a future post I’ll talk about decoding level.dat and other Minecraft Files.

JetPack Summary 2011

So popped open my emails on January 1st to find an email from JetPack. JetPack being a collection of plugins from WordPress to install on Self hosted blogs, that among other things includes a stat tracker.

The email in question was something that JetPack had automatically generated as an Annual Report on views of my blog.

You can see mine here.

Quite an interesting read, and I’m not really surprised that my some of my most popular posts are from 2010, really just means I need to blog more. (Hence really the reason for writing a blog entry about it, since I do aim to post more now)

But the most interesting thing of all, is the little Fireworks jQuery plugin, which WordPress have also released as open source for others to use and play with. Included on the review page includes a nice little stats/current plugin output to show you how effective/how well its all running.

My Google Chrome is currently scoring 4%, but my iPad safari clocks in at 30% (but then I do have a lot of tabs open right now).

It’s a nice way to review your blog from the year, so it you are running JetPack, its worth a read.

But it is really just a bit of a sales gimmick when you get to the bottom and see what WordPress has planned.
Looks like its going a bit more Tumblr-y. We shall see