Wednesday, August 26, 2009

Xcode and SVN

Today was my first time trying to work with Xcode 3 and Subversion. Using two separate Macs to check out the shared project from SVN, I quickly discovered that it was not as straight forward to work with Subversion from inside Xcode as I had hoped (and come to know from NetBeans and Eclipse).

First of all, only one of the Macs successfully set the SCM repository after the checkout on the other one I had to manually set the repository after checkout. I think I did the very same steps on both Macs but behaviour was different - how strange.

Next thing I noticed: if you'd like to update your project but have a file already displayed in the editor, make sure you use Refresh Entire Project before selecting Update Entire Project. It seems that without calling Refresh, the file is indeed updated on the file system but the change won't be visible within the editor unless you choose a different, external editor to open the file.

If anybody can shed some light on the issue, let me know in the comments!

Friday, August 7, 2009

JsUnit

If you happen to run into problems with the Test Runner page of JsUnit in Firefox, try setting the property Security.fileuri.strict_origin_policy on your about:config page to false. Unless you do that change, the Test Runner will come to a halt while displaying the "Opening test page ...." message.

Wednesday, August 5, 2009

Transaction Logs in MS SQL Server 2005

The other day I tried to find a solution for an excessively large transaction log file in one of our production systems. It grew to an astonishing 40 GB which set off some alarms. Our middleware service provider offered to take care of this problem for a rather high monthly fee that I didn't feel like paying: after all, how difficult could it be to shrink that stupid file and keep it under control?

Turns out it with a little trickier than I thought. I, actually, have never used MS SQL Server before and have never come across any transaction logs I had to take care off. In my previous server-based project we worked with MySQL which did not provide such a facility (and I shall stand correct if you show me where I missed it). So off I went to find some information about the transaction logs for MS SQL Server and, in theory, things were supposed to be easy: execute two SQL statements, one backing up the transaction log, the other shrinking the log file - that's it.

Backing up worked (with a 40 GB log it took quite some time, of course) like a charm but shrinking did not seem to work. Once I found the command
DBCC SQLPERF (logspace)
I was at least able to verify that the backup had worked and had really set the records in the log to inactive. After some more trial and error I found that I had just passed the wrong parameter to shrinkfile: instead of the database name it expects the name of the log file (excluding the file extension.

A long story short, the following two commands executed in SQL Management Studio will successfully backup and shrink your transaction log file:
USE [database];
BACKUP LOG [database] TO DISK = '[filename]';
DBCC SHRINKFILE ([name of transaction log without extension or quotes], 1);
Here's a more tangible example:
USE BenDB;
BACKUP LOG BenDB TO DISK = 'C:\Backup\BenDB_log.bak';
DBCC SHRINKFILE (BenDB_log, 1);
Hope this can save you some time one of these days.

Tuesday, July 21, 2009

Generalizations of the TSP

Here's my first post in a row of posts detailing what I'm doing in my thesis - and for what it's good. Typically, math students don't necessarily know whether the contents of their thesis can be applied to anything in the real world at all (I'm exaggerating - but for most of them, it's more difficult to find the connection). In my case, however, it's pretty straight forward:

Imagine you're working for UPS and you pick up your truck at 7am in the morning to start your delivery tour. Now, if you're a clever driver, you might want to take a moment and consider how to best approach today's deliveries: what's the shortest (or cheapest or fastest or ...) route to take through town delivering all the packages and, after the last delivery, returning to your depot. That's the Traveling Salesman Problem (TSP) - a very classic example of a problem that's hard to solve to optimality.

Now UPS offers clients to dispatch packages with high or normal priority. High priority packages will be treated with a higher urgency and will typically be delivered before a normal priority package is delivered. In addition to that, a realistic constraint for the delivery of packages is to impose a latest time for delivery, say you have to finish the delivery of all packages by 5pm (receptionists leave rather early, I hear). Trying to come up with a tour for the driver that takes both extensions into consideration (prioritization of deliveries and maximum time allowed for delivery on a single day) is a generalization of the TSP - the Orienteering Problem (OP).

There are a lot more variations of the original TSP. The OP, however, should give you an idea of what such a variation / generalization can look like. In my thesis I'm having a look at these kind of generalizations and trying to come up with algorithms that will solve them to optimality (ie. we find the best tour possible, guaranteed!) but take a lot of computation time or algorithms which only come close to the best tour (which we cannot guarantee, however :-( ) but are fairly quick.

That's enough for a first post - I don't want to scare anybody away before the real fun starts. In the next post I'll try to give a low-math overview of how one can tackle these problems. Let's see whether that's possible!

PS: For the nit-pickers out there: the OP is not really a generalization in the sense that you can solve the TSP by means of an OP. I still like to call it a generalization so bear with me.

Monday, July 20, 2009

IIS and ASP.net

This morning I had to deploy an ASP.net-based application to an IIS. Everything had worked fine on the development system but once I deployed it on our production system, an error message was displayed that didn't give me a clue about what could possibly have gone wrong:
Error initializing the AppDomain
Quickly followed by another error:
The request could not be processed because the application domain could not be created. (translation of Die Anforderung konnte nicht ausgeführt werden, weil die Anwendungsdomäne nicht erstellt werden konnte.)
Google didn't find clear steps to fix the issue but hinted at file permission problems. In fact, I had just extracted a zip file on the server into the application directory instead of creating one manually. Therefore permissions of the containing folder were not reused and just set to some defaults. Comparing and adjusting the file permissions (Security in context menu) of the directory with the permissions of the Inetpub directory fixed the problem.

Sunday, July 19, 2009

OpenGL origin

Looks like OpenGL is just doing what all the other 3D frameworks are doing, too. At least this article implies that 3D frameworks generally adopt the maths view of having the origin in the lower left. Good to know!

cocos2d

First time really trying to get something done in iPhone SDK. After struggling ages getting a simple game loop to work - only to discover that I was calling the update routines on the wrong thread - I found a forum post which talked about the cocos2d iPhone 2D game engine.

Have now spent most of the day working on a simple Memory-like game. The engine is pretty straight forward to use once you get to know the APIs. There are a couple of things I didn't quite figure out this time, though - any insights are appreciated:

  1. Is there any reason why rendering origin in iPhone / cocos2d / OpenGL seems to be lower left corner instead of upper left? It sure matches the mathematical way of thinking about an origin but AFAIR most of the other frameworks have their origin in the upper left, don't they?
  2. To render the game board, I have assembled a Scene using a Layer and a couple of Sprites contained in that Layer where each of the Sprites was supposed to be touchable. I haven't found a way to get that working other than reacting to touches on the Layer and manually checking whether the touch fell within the bounds of one of the Sprites. There must be a better way to do this, right?
  3. How does memory management work when you replace Scenes using the Director singleton? You access the Scenes via [Scene node]; so I assume there's autorelease at work.
  4. Why do Texture2D.pixelsHigh / .pixelsWide return different values than Texture2D.contentSize?