Cocoa memory management 101

Ok, so here it comes, my first Cocoa posting. I am pretty new to Cocoa and therefore this might be something you are more than familiar with, but for me it is handy to have a quick reference written down where I can look up things. So today I would like to talk about memory management. My coding background lies about 70% in Java, 20% in PHP and 10% in C/C++. So in the past mostly I did not have to worry about memory management topics, although I am familiar with the low level C/C++ way of allocating and releasing memory. Cocoa uses an approach somehow in the middle between automatic garbage collection and manual management. Once you get used to it, it is a very powerful tool and you have a much better control over the memory consumption in your applications than in Java while being less error prone than the C/C++ mechanism.

If you want to dive into the details of Cocoa memory management, I recommend you read the Memory management Programming Guide For Cocoa from Apple. For me it was the main source of information about this topic.

Continue reading »

Securing Apache with mod_security

Now that the basic Apache configuration is working, let’s take some time to harden the installation. The module mod_security is really handy for this task. It is an application level firewall meaning that it will inspect incoming requests to the webserver and try to identify possible attacks like code injection, SQL injection and cross-site-scripting. As handy as this tool might be, it is not meant as a substitute for a secure PHP or Apache configuration, so you still need to take care not to open potential security holes there. If you followed my basic Apache and PHP setup you should be on the safe side, as the most exploited security holes have already been closed.

Continue reading »

Apache, PHP and MySQL setup

After setting up the mail system, I continued today with the basic webserver setup. This setup includes a basic Apache2 configuration with SSL and name based virtual hosts. PHP5 and MySQL5 are also needed for serving dynamic content.

Continue reading »

Setting up a spamsafe Postfix server

I am currently in the process of upgrading my webserver to Debian Etch. In the past I have been using Debian Sarge with Plesk as an administration desktop. Plesk is very convenient, but it is also a memory hog and a performance killer, so I decided to go on without a web based administration tool and configure every service manually. This has the advantage that the system will be more secure and easier to update. The downside is a little bit more work in the beginning. During the next couple of postings I will document the configuration of the various services I have running on that server.

In this first post I will start with the mail service for which I choose the Postfix daemon together with policyd-weight for spam filtering and Dovecot as an IMAP and POP3 server. Authentication will be done with the SASL daemon against the standard user database. This is not really suited for large mail installations with a lot of users, but if you have to deal with only a couple of mail users, it is really easy to administrate.

Continue reading »

Essential Mac Tools

After working more and more with my Macbook instead of my desktop PC, I have found a couple of really nice tools for mostly all of my daily tasks. So here is a small list of tools and utilities which I basically use daily:

  • Camino – This is basically the Firefox browser as a native OSX application. It has support for drag and drop, integrates the OSX keychain and spell checker and best of all, it’s completely free. The only downside is that you can not run the Firefox plugins.
  • Textmate – Simply put: if you need a text editor there is absolutely no way around textmate. As a software developer you spend most of your time in a text editor and this is the most powerful editor I have ever worked with on any platform.
  • Vienna – A very nice feedreader. Highly customizable and open source. As long as you do not read more than 200 feeds, this is a really good application.
  • Quicksilver – To say Quicksilver is just an alternative program launcher is understatement par excellence. This is a completely new way working with OSX. It will save you a great deal of time. Also freeware.
  • AdiumX – The multi protocol chat client for OSX. It has very nice theming support and it is open source.
  • svnX – A GUI subversion client. Being used to TortoiseSVN on Windows, it is like a step back, but it is way better than using the command line tool.
  • XAMPP – Apache, MySQL, PHP and Perl preconfigured in one easy to install package. If you do web development, there is no way around this.
  • Cyberduck – A great FTP/SFTP client. Easy to use and open source.
  • iShowU – A great tool for recording screencasts. I prefer recording a screencast instead of writing long turorials. This tool is easy to use and produces great results.
  • NeoOffice – This is the native OSX port of open office. I guess I will transition to iWork once the Numbers application is really stable, but in the meantime NeoOffice is working really great.
  • Gimp – A powerful graphics application. It hase more functions and filters than an amateur will ever need.
  • WhatSize – A really small but handy utility to find out which folders on your hard drive contains the largest files. Can be very useful when cleaning up your hard drive.

Well, I guess that’s basically it. I will keep you updated when I find great new tools.

Continue reading »

Apple introduces new iMac

new-imac.jpgEveryone has been expecting the iMac upgrade for the last couple of months and today was the day that the upgrade finally was presented at the summer Mac product press conference.

The design of the new iMac is really breathtaking. It got considerably thinner than the white model and the aluminum material marks it clearly as a model targeted at the pro market.

The internal upgrades feature a faster processor, more RAM and a bigger hard disk. But the important part for becoming an all purpose computer for work and gaming is the graphics card and I feel that Apple did not completely make their homework. The entry-level model for 1200,- EUR will come with a Radeon HD 2400 XT which is an absolutely low end graphics card that you can buy for around 60,- EUR. I mean come on Apple, you build a really great system except this graphics card which is really a bummer considering the overall price tag.

Let’s take a look at the 20″ iMac for 1500,- EUR. It will come with Intel Core2Duo 2.4GHz, 1GB RAM, 320GB harddrive and the Radeon HD 2600 Pro. Ok, this card is about twice as fast as the 2400XT and a little bit faster than the Radeon 1600 which you find in the current iMac. But when you buy this card for your PC you will find that it is still targeted towards the lower mid end market with a price tag of around 100,- EUR.

In my opinion this is really a bummer and I was definitely expecting a little bit more, let’s say something in the area of a Radeon 1950 Pro. Especially since ID software committed themselves to deliver their new titles in parallel for PCs and Mac. But hey, maybe Apple did some great things with their drivers and these cards will perform better than expected, so let’s wait for the first true reviews.

Continue reading »

Just bought a Wii

This weekend I managed to convince my wife that it would be a wonderful idea to buy a Nintendo Wii console. So I immediately went out to the next electronics store and bought a Wii and a second Wiimote. And what should I say, the weekend was a blast. We had loads of fun with the included WiiSports, especially with Tennis. Granted the graphics looks really outdated on the big 37″ screen, but what it lacks in graphics it makes up in gameplay. And the Wiimote controller just has this let-my-try-appeal which you can’t resist. So now I need some more games, preferably those with a high WAF (Wife Acceptance Factor). So if you have any secret tips, please let me know.

In the meantime I started working on my first OSX application. It will be a utility to securely store your passwords and it will use the PasswordSafe file format, so that you can exchange data across multiple platforms. I know that there exists a PasswordSafe Java version which will run on OSX, but I don’t like it very much in terms of usability. It just does not feel like a Mac application, and all other Mac applications in that area can not handle the PasswordSafe file format which is for me absolutely necessary. Anyway, I think this is a good area to master Objective-C and Cocoa and I will keep you updated on the progress… provided that I will not spend all my time in front of the Wii 😉

Continue reading »

Converting MySQL character sets

MySQL uses character set definitions on different levels. There is a default character set for the MySQL server, one character set for each database, one for each table and even one for a single column. You should generally take care that you use a consistent dataset for all columns and tables inside a database and the database itself. There exists no SQL-command or command line utility to convert a database from one character set to another. Therefore I will describe a quick way to accomplish this.

Continue reading »

Running GNL.tv with PHP5

Unfortunately the xmlrpc Library used by the GNL.tv web standings display is not compatible with PHP5 and the library seems to be no longer supported by its developer. So if you want to run GNL.tv with PHP5 you need to patch that library, which is actually pretty easy to do.

Open the file xmlrpc.php in your favorite text editor and go to line 436. You should now see the following code:

$this = &$array["methodResponse"]["fault"]["value"]["struct"]["member"];
$this[0]["name"] = "faultCode";
$this[0]["value"]["int"] = $faultCode;
$this[1]["name"] = "faultString";
$this[1]["value"]["string"] = $faultString;

We need to rename $this to $temp, so change the above lines to this:

$temp = &$array["methodResponse"]["fault"]["value"]["struct"]["member"];
$temp[0]["name"] = "faultCode";
$temp[0]["value"]["int"] = $faultCode;
$temp[1]["name"] = "faultString";
$temp[1]["value"]["string"] = $faultString;

That’s it. Now everything should work fine in PHP5.

Continue reading »

Woes and bliss of a musician

This weekend I have been playing 2 gigs with my band Seventy-Seven. Funny how completely different these 2 gigs can turn out. We played the first gig on Friday night in a trendy venue named Schranne in the city center of Munich. Our mix of 70ies & 80ies Disco with a little bit of Pop and Rock seemed to be exactly what the audience wanted to hear, so we had a real party going on in there and overall it was a great success.

Then on saturday we were booked to play on a summer party at a local soccer club. We have been playing there last year on a similar occasion and we had quite a good time. But this year was completely different. It seems like there were completely different people. Most of the time we had the feeling that we were disturbing the audience instead of entertaining it. In between our sets they have been playing folk music from CD. No wonder we did not fit in there. German folk music is like the musical counter pole to Disco & Pop. Luckily we had to stop after 2/3rd of our program because the police paid a visit as the organizer did not register the party with the authorities.

So the bottom line is: If you are hiring a band for an event, do not search for a band that meets your personal taste, but try to find a band that meets the taste of your guests. This will make it a far more pleasent experience for everybody.

Continue reading »