Entries Tagged 'Nerdy Stuff' ↓
December 15th, 2008 — Nerdy Stuff
Here’s a pro tip for anyone working with Wordpress. If you’re ever faced with a completely blank page when you visit your site, check that the theme you are meant to be using actually exists. I just spent about half an hour checking permissions and error logs for my development environment, only to find that when I backed up the theme I was working on I inadvertently cut the theme’s folder instead of copy it. It appears that when Wordpress doesn’t find the theme it is meant to use it just returns an empty page instead of an error message. Better than an error message, it could even try using the default theme and email the adminstrator that something has gone wrong with their chosen theme. I’m using Wordpress 2.7 at the moment, so if this is version specific or shouldn’t be happening, can someone please leave a comment or email me.
Given that Wordpress appears to be open source, maybe I should attempt to write such a fix and finally contribute to an open source project like I’ve been planning to.
December 14th, 2008 — Nerdy Stuff
I just went to do some work on a Wordpress theme for my girltrond and discovered that upgrading to Leopard has broken my MAMP setup. Here is a quick rundown on what I’ve done to fix it. First of all, trying to visit pages under my user account’s Sites folder left me with a HTTP 403 Forbidden error. In order to fix this I follwed the instructions on Apple’s support site.
Next, to get PHP running. I was using entropy to get PHP5 with Tiger, however it appears that Leopard includes a PHP5 install by default. To enable it, we need to edit Apache’s configuration file (httpd.conf) which you can do with the following command in Terminal (under Utilities):
sudo nano /etc/apache2/httpd.conf
Continue reading →
November 10th, 2008 — Games, Nerdy Stuff
I’ve been playing Oblivion on and off for the last couple of years, and I’m ashamed to admit I haven’t even finished it yet. This is in no way a reflection on the quality of the game, more an indication of how busy I’ve been and the quality of competing games (Team Fortress 2, GTA IV etc.). Also to my defense, I have done a fair few side quests and for whatever reason have ignored the main quest quite a bit. My gaming habits aside, Bethesda has created one of the most detailed and interesting virtual worlds I’ve ever seen to date. This vast and rich world, coupled with my relatively new interest in game development, has now come to its logical conclusion… (see title for logical conclusion)
Thanks again to the incredibly talented crew at Bethesda, this is really not as daunting a task as you might think. As it turns out, Bethesda have kindly released the same (or very similar) tools used to develop the game itself for free. I have very little experience with the tools so far, but from what I’ve seen, it’s surprisingly simple to start out and get simple modifications working in the game. For example, you can load up an existing space in the game, drag and drop whatever items from the game you’d like into that space, and when you’re done, just load up the game and take in your room full of ladles.
Obviously making serious modifications to the game is a much more daunting task, involving programming, modelling, texturing, and many other skills used by the team of developers who made Oblivion. Despite the scary possibilities, you can still have a lot of fun playing around in the world of click-and-drag GUIs. To give you some idea of what’s possible with no prior experience and sticking solely to the click-and-drag GUI, two sessions of about 4-5 hours each gave me the skills to add a basic building to the game. This includes re-shaping the terrain surrounding the building, re-texturing the terrain surrounding the building, setting new paths for NPCs to follow to my building, adding a map marker to fast travel to the building, and finally, re-furnishing the interior. In the interests of complete disclosure, I will admit to a few hours playing around in Blender, a free and open source 3D modelling tool. While this barely helped, I did have a little experience manipulating 3D environments when I started.
As well as the excellent tools provided for you, there are also a number of excellent resources available to help new and experienced modders. The Elder Scrolls Construction Set Wiki has thus far been my most used resource, providing the beginners tutorials I used to learn just about everything I’ve done so far.
For anyone who’s interested in seeing my first baby steps into the world of Oblivion, as well as an indication of what you’ll get if you complete the first two parts of the tutorial I linked to, my mod is available for download. I’ll warn you now that, although I haven’t experienced any issues while playing with this mod, it’s not a completely clean mod, nor has it been thoroughly tested (use at your own risk =p). As a result, I’d encourage anyone loading it to back up their save games first. These can be found in your user directory under “Documents/My Games/Oblivion/Saves” in Vista. I would also suggest that nobody play the actual game with this mod enabled because I’m not sure what it might do to your save games. Warnings aside, it should be plenty safe enough for demo purposes.
To install the mod, check out this FAQ at the construction set wiki. To see my sleepy little farm house, fast travel to Weye and then head away from the Imperial City, taking the path to your right as you exit. Follow the road for a little while and you’ll see a path off to your right that squeezes between some rocks and trees (roughly in line with Fort Nikel). Take the path and you’ll be led right to the front door of my test building. Feel free to go inside and look around. You’ll notice that the inside is much bigger than the outside would lead you to believe. This is because I was being silly and linked the little farm house exterior to a Lord’s manor (from memory it’s from somewhere in Bravil). One more thing: there are probably a few items of value lying around in there. Yes, you can take them with you, but really, where’s the fun in cheating like that…
August 31st, 2008 — Nerdy Stuff
I’m currently planning on a career in games programming and was looking for some beginners’ tutorials in OpenGL using C++ and found a goodun over at code project. It’s a 3 part tutorial, and as I’m writing this the first two parts have been posted, complete with code and Visual Studio project files. As a relative beginner with C++ and a complete beginner with OpenGL I’ve found this fairly easy to follow. The code is pretty well commented, and the tutorial itself explains things clearly and doesn’t take too much for granted aside from a basic knowledge of programming/C++.
A trap for young players, there was a slight error in the code from the first part that caused the program to not shut down and stay in memory after the window had closed. Nobody else seemed to have this problem, and it could have just been me being difficult and using Vista. Nonetheless, if the code for part 1 hasn’t been updated, the fix is in the comments below part 1. Basically the main application loop did not clear the message queue with each iteration, only taking the first message. From what I’ve read on the issue this means that the WM_QUIT message sent from PostQuitMessage() is never received. This is because PostQuitMessage(0) sets a flag on the message queue which tells it to return a WM_QUIT message if the queue is empty. Obviously if the queue is never cleared, this message is never returned when the queue is queried for the next message.
If you have any problems with this, feel free to contact me. Happy coding!
August 18th, 2008 — Nerdy Stuff
Have you ever had one of those moments when you realise that something you held as a fundamental law of the universe doesn’t work the way you thought it did? Well I have, today in fact, while writing a batch script that needed to be aware of leap years. Multiple choice question (I promise it’s relevant), which of the following is a leap year: a) 1700 b)1900 c)both ‘a’ and ‘b’ d)none of the above. Correct answer: d). That’s right, it turns out that being evenly divisible by 4 isn’t enough to qualify as a leap year.
So, now that I’ve dropped that bombshell, who wants to know how to pick a leap year every time without embarassing yourself? Those of you with your hands raised can lower them and simply keep reading, because I’ll fill you in now. In plain English, a leap year occurs when the year is evenly divisible by 400, OR if the year is evenly divisible by 4 but NOT 100. Put another way, a leap year occurs every four years as you’d expect, except for the beginning of a new century, where a leap year only occurs if that year is evenly divisibly by 400 (e.g. 1600, 2000 etc.). A nice way to show this process is with the aid of a spiffy flow chart referenced in the about.com article I found today.
For those of you who might need to code this, the wiki article on leap years has pseudocode and C-style code examples of the algorithm. Furthermore, for those of you who might need to check leap years in a batch script, here’s a simple batch script to do so. In its current form, the script is called with the year you’re checking as the first and only argument, printing an answer in plain english before finishing.
@echo off
SET _year=%1
SET _bLeapYear=is not
::Check if the year is evenly divisible by 400
SET /a _modYear=%_year% / 400
SET /a _modYear=%_modYear% * 400
If %_modYear%==%_year% SET _bLeapYear=is
If %_modYear%==%_year% GOTO END
::Check if the year is evenly divisible by 4
SET /a _modYear=%_year% / 4
SET /a _modYear=%_modYear% * 4
If NOT %_modYear%==%_year% GOTO END
::Check if the year is evenly divisible by 100
SET /a _modYear=%_year% / 100
SET /a _modYear=%_modYear% * 100
If NOT %_modYear%==%_year% SET _bLeapYear=is
:END
echo %_year% %_bLeapYear% a leap year
As you might have noticed, I’m substituting the modulus operation found in most algorithms (including the ones on the wiki article) with a division followed by a multiplication. This is simply because batch scripts don’t have a modulus operator. For the mathematically curious, this works because we’re using integer arithmetic. For example, in a batch script, 2003 ÷ 4 = 500. As you can see, there is no remainder in the result. Furthermore, there is no rounding. This means that a ÷ b * b will only equal a when a is evenly divisible by b, or, a mod b = 0.
And there you have it, more than you probably wanted to know about leap years.