<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
		<title>Blog</title>
		<link>http://yorickpeterse.com/blog</link>
		<description></description>
		<dc:language>en</dc:language>
		<dc:rights>Copyright 2010</dc:rights>
		<dc:date>2010-07-28T10:46:34+00:00</dc:date>

		
		<item>
			<title>Don&#8217;t Fucking Repeat Yourself</title>
			<link>http://yorickpeterse.com/blog/entry/dont-fucking-repeat-yourself</link>
			<guid>http://yorickpeterse.com/blog/entry/dont-fucking-repeat-yourself#When:09:46:34Z</guid>
			<description>Too many times people write the same code over and over again. How many controllers do you have that share some functionality yet have these features defined in every controller instead of a base controller? I wrote this article because repeating yourself is simply bad. It isn’t a very in&#45;depth article but it does cover the general concept of DRY in Codeigniter.

Base Controllers/Models

Base controllers and/or models are probably the easiest step towards a DRY friendly setup. For example, at work I’m currently working on the backend of a VOIP system. This system uses quite a lot of forms and to cut down the amount of code the decision was made to use a save() method to which all forms would send their data. This works at a basic level because a lot of forms share the same structure, however it still required us to define a save() method in every controller.

The solution to this was creating a save_post() method in our base controller. This method simply validates the form and inserts/updates certain data based on the associated model, ID and POST data. Even though most forms were able to use this method there were still a few that required their own method. This is perfectly fine. Not repeating yourself doesn’t mean you HAVE TO use the same method for everything. It just means you should reuse your code as much as possible.

The save_post method I talked about looks like the following:



protected function save_post($model, $id, $data)
{
	if ( $this&#45;&gt;form_validation&#45;&gt;run() )
	{
		if ( $id === NULL )
		{
			if ( $this&#45;&gt;{$model}&#45;&gt;insert($data) !== FALSE )
			{
				$this&#45;&gt;message&#45;&gt;set(&apos;success&apos;, &apos;De gegevens zijn opgeslagen.&apos;);
			}
			else
			{
				$this&#45;&gt;message&#45;&gt;set(&apos;error&apos;, &apos;De gegevens konden niet worden opgeslagen.&apos;);
			}
		}
		else
		{
			if ( $this&#45;&gt;{$model}&#45;&gt;update($id, $data) !== FALSE )
			{
				$this&#45;&gt;message&#45;&gt;set(&apos;success&apos;, &apos;De gegevens zijn gewijzigd.&apos;);
			}
			else
			{
				$this&#45;&gt;message&#45;&gt;set(&apos;error&apos;, &apos;De gegevens konden niet worden gewijzigd.&apos;);
			}
		}
	}
}



Using a base model, for example Jamie’s MY_Model (or my own version) will also cut down the amount of code for all your models. There’s no need to write the same insert query over and over again when you can just call the insert() method of the base model.&amp;nbsp; 

Helpers

If you happen to write small amounts of code over and over, say a piece of code to convert a date, it might be a good idea to put it in a helper. Doing so will give you the ability to just call function X instead of having to rewrite the same lines of code. It also makes updating/changing the behaviour of the code easier. A good example is a MY_date_helper I wrote as we we’re dealing with ISO dates that had to be converted to Dutch dates. ISO dates have the format of YYYY&#45;MM&#45;DD whereas the Dutch format is DD&#45;MM&#45;YYYY. Instead of writing the following over and over again I simply put it in a function called iso_to_dutch(): 



echo date(&apos;d&#45;m&#45;y&apos;, strtotime($input[&apos;some_date_field&apos;]) );



Reusable Views

Reusing views is something that’s less common in Codeigniter projects. Sure, people might use a template library but they’re still loading multiple views that do almost the same. A good example is loading a view containing a form. When adding or editing data the form is the exactly the same yet people still tend to use a different view for both actions. It’s not that hard to use a single view instead. The combination of the if/else statement along with the isset() function is your best friend in this case. Check for the existence of certain variables in the value parameters of the form elements and output them if they exist. Don’t output anything if they don’t. 

As simple as this may sound there are plenty of people who simply load 2 different views for adding/editing data. In some cases it might actually be required but even then there’s a good chance you can combine the views.

Libraries

If you intend on creating a set of features that need to be reused across models, controllers or views don’t put it in a base controller or model. Those are intended, as obvious as it may sound, for controllers/models only. Instead, use a library or helper (if it’s only a few functions). A good example of this are authentication libraries that handle the authorisation and validation of your users.

Conclusion

Just don’t fucking repeat yourself. You’ll spend way too much time writing the same crap over and over again while at the same time you could be writing kick ass applications. It’s really not that hard actually, in fact, it’s probably easier than copy&#45;pasting the same code over and over.</description>
			<dc:subject>Development, Codeigniter</dc:subject>
			<dc:date>2010-07-28T09:46:34+00:00</dc:date>
		</item>
		
		<item>
			<title>Firefox 4 BETA</title>
			<link>http://yorickpeterse.com/blog/entry/firefox-4-beta</link>
			<guid>http://yorickpeterse.com/blog/entry/firefox-4-beta#When:20:23:25Z</guid>
			<description>Mozilla recently released the first public beta of Firefox version 4 and I have to say I&#8217;m very impressed. Having used Firefox for almost 2 years I switched to Chrome a while ago due to the insane amount of RAM Firefox was using along with it&#8217;s sluggish performance. After playing around with the BETA I&#8217;m actually considering of switching back once the browser is stable enough, even though it may take a while before that will happen.</description>
			<dc:subject>Resources, Applications</dc:subject>
			<dc:date>2010-07-07T20:23:25+00:00</dc:date>
		</item>
		
		<item>
			<title>ExpressionEngine, Here we Come</title>
			<link>http://yorickpeterse.com/blog/entry/expressionengine-here-we-come</link>
			<guid>http://yorickpeterse.com/blog/entry/expressionengine-here-we-come#When:21:17:06Z</guid>
			<description>I&#8217;ve been thinking about moving over to EE for a while now, especially version 2 seems to be great considering it&#8217;s built using Codeigniter. Up until yesterday I didn&#8217;t feel like moving because of the price tag involved, and simply because I&#8217;m too lazy to recreate my entire website using EE. The reason I decided to move over after all was that yesterday I was trying to add a search box and only make it appear on the blog page. The problem? I had to install a widget in order to hide the search widget on certain pages. This isn&#8217;t something I want to do, as the widget is not only poorly developed (http://cl.ly/1S2L), but also an overkill if you just want to hide/show a single widget on a few pages. 

However, plugins aren&#8217;t the biggest reason for making the switch. It&#8217;s Wordpress itself. Wordpress is great for a small blog or for someone who doesn&#8217;t do that much with their website other than posting cat videos. Its ease of use makes it the ideal system for both users and designers that have a limited knowledge of the things they&#8217;re working with. The problem is that as soon as you want to do something more than just blogging you&#8217;ll have to start hacking or installing loads of plugins, something I absolutely hate.

Hacks

The problem with hacks is that they tend to be buggy most of the time and might get broken when you update the system you&#8217;re using. Imagine patching your copy of Windows so that it no longer comes up with a BSOD &#45; a day later you install a new update and the hack no longer works. Why? Well, windows thought it was wise to modify the file you hacked (or patched, whatever you&#8217;d like to call it) in order to fix one of its many issues. The solution to this is to modify that file yourself again, but the process will start over again whenever the file is modified by either the system or a third party.

Widgets/Plugins

Compared to hacks, widgets/plugins are a men&#8217;s best friend. They add functionality without messing with the core system. The problem with Wordpress is that in order to add extra functionality, you quickly have to install a load of plugins: 10 in my case. I just don&#8217;t feel like installing a lot of third party &#45; and in many cases badly supported &#45; plugins/widgets. I&#8217;d rather build something that has all the required options from the start and only have to install a plugin for that very special feature.

This is where ExpressionEngine kicks in. It&#8217;s not a blog tool or a regular CMS, it&#8217;s more like a platform that provides you with the features required to build what you want. This means that you have full control of pretty much everything, but it also means it isn&#8217;t something the novice would use. Installing a new theme isn&#8217;t as easy as it is when using Wordpress or other general systems. For me this is just perfect, I need a system that handles the management of my content but doesn&#8217;t restrict me.

ExpressionEngine is something I&#8217;m really looking forward to. It will take some time getting used to, but we&#8217;ll see where this train ends.</description>
			<dc:subject>News</dc:subject>
			<dc:date>2010-06-22T21:17:06+00:00</dc:date>
		</item>
		
		<item>
			<title>Xbox API in PHP</title>
			<link>http://yorickpeterse.com/blog/entry/xbox-api-in-php</link>
			<guid>http://yorickpeterse.com/blog/entry/xbox-api-in-php#When:12:59:47Z</guid>
			<description>A while ago I discovered that Duncan Mackenzie offered public access to the Xbox Live API. Whereas the API itself was great, the output was a mess. CamelCase, data stored in the wrong place, etc. So I decided to create a PHP class that made life for those who want to connect with this API a little bit easier. 

You can read more about this class at the GitHub page found here, or you can see an example here.</description>
			<dc:subject>Development, PHP</dc:subject>
			<dc:date>2010-05-14T12:59:47+00:00</dc:date>
		</item>
		
		<item>
			<title>CloudApp</title>
			<link>http://yorickpeterse.com/blog/entry/cloudapp</link>
			<guid>http://yorickpeterse.com/blog/entry/cloudapp#When:19:43:07Z</guid>
			<description>I used to work with TinyGrab, until I heard about CloudApp. It supports more files (instead of just images), has a better admin panel and is much faster than TinyGrab (even on this shitty Wifi connection stolen from the neighbours).</description>
			<dc:subject>Resources, Applications</dc:subject>
			<dc:date>2010-05-11T19:43:07+00:00</dc:date>
		</item>
		
		<item>
			<title>Kick&#45;Ass</title>
			<link>http://yorickpeterse.com/blog/entry/kick-ass</link>
			<guid>http://yorickpeterse.com/blog/entry/kick-ass#When:20:25:42Z</guid>
			<description>Best movie I&#8217;ve seen in a while. While at some points the movie got predictive it remained fun to watch. Plus, it involves a bazooka, which makes the movie even more awesome.</description>
			<dc:subject>General</dc:subject>
			<dc:date>2010-04-30T20:25:42+00:00</dc:date>
		</item>
		
		<item>
			<title>Transmit 4</title>
			<link>http://yorickpeterse.com/blog/entry/transmit-4</link>
			<guid>http://yorickpeterse.com/blog/entry/transmit-4#When:17:33:32Z</guid>
			<description>Panic recently released a new version of their FTP application called Transmit. Up until now I always worked with Cyberduck, however it&#8217;s nothing compared to Transmit. Simply said, I love the new Transmit!</description>
			<dc:subject>Resources, Applications</dc:subject>
			<dc:date>2010-04-28T17:33:32+00:00</dc:date>
		</item>
		
		<item>
			<title>Apple&#8217;s New Macbook Pro&#8217;s</title>
			<link>http://yorickpeterse.com/blog/entry/apples-new-macbook-pros</link>
			<guid>http://yorickpeterse.com/blog/entry/apples-new-macbook-pros#When:17:20:34Z</guid>
			<description>Yes, they are finally here. The new Macbook Pro&#8217;s featuring the i5 and i7 processors. When the first people started walking into the store I always told them the Macbooks wouldn&#8217;t have an i5 or i7, simply because it would probably get too hot. It seems I was wrong. Most likely because I haven&#8217;t been really very active in the hardware world lately. I used to tweak my windows machine quite a lot, until I bought a Mac and never looked back at it. It&#8217;s actually quite a good machine, but it&#8217;s too &#8220;old&#8221; to sell for a decent price, probably turn it into a home server or something.

Back on topic. I think Apple did a pretty good job at integrating the i5s and i7s into their new laptops. Plus, the batteries last for a stunning 10 hours (on the 13 inch that is). Other than that I don&#8217;t really consider them to be that much better than the &#8220;old&#8221; series. Some of the features, such as audio support for the Mini Display ports, should&#8217;ve been included in the previous generation.

Now we just need to wait for the iPhone HD, iPhone 4G or whatever the damn machine is supposed to be called. Perhaps they&#8217;ll even call it the iPad Mini Deluxe XL. Perhaps even the iPhone Lisa, who knows.</description>
			<dc:subject>General</dc:subject>
			<dc:date>2010-04-15T17:20:34+00:00</dc:date>
		</item>
		
		<item>
			<title>Welcome To The World Without Internet</title>
			<link>http://yorickpeterse.com/blog/entry/welcome-to-the-world-without-internet</link>
			<guid>http://yorickpeterse.com/blog/entry/welcome-to-the-world-without-internet#When:17:17:52Z</guid>
			<description>It’s March 19th, around 11 AM and you’re still in bed. Your girlfriend has already been awake since 8 AM, it’s actually the first time she woke up before you did. Suddenly a guy starts ringing the bell, you ignore it for the first few minutes as you weren’t expecting anybody. However, after several minutes the person continues to ring the bell and also started hitting the door causing an awful amount of noise. So you and your lazy ass decide to go downstairs with the intention of shouting at the guy and telling him to fuck off, only to notice it’s that very same guy who shut down the electricity about two months earlier.

That unlucky person was me. For the second time in 4 months since I’ve been renting this dorm the power has been shut off because the landlord didn’t pay his bills. The first time he didn’t pay for 6 months and we got cut of for about 2,5 days. Once he paid we got our electricity back and we were all happy. You’d expect that the landlord learned his lesson and would start paying his bills in time, but no. He didn’t. It’s been about 36 hours since we were cut off for the second time as mister lazy&#45;douchebag&#45;who&#45;spends&#45;all&#45;his&#45;money&#45;on&#45;you&#45;know&#45;what&#45;I&#45;mean didn’t pay for the last two or three months either.

Luckily I have a full&#45;time job, this means a power outage isn’t too bad as I can still steal the Wifi at work. The problem however is that it’s really hard to take a warm shower or cook a meal (or even make tea) without electricity. It get’s even worse when your landlord calls you telling you never paid him. Wait what? I didn’t pay him at all? If not having electricity was bad enough it now also seems that €980 euros has suddenly been lost. Shit.

After verifying the account I sent the money to it seemed it was the account of the mediator of the apartment, not the landlord. When I called the mediator he was as confused as the landlord as he (and the landlord) don’t really bother to check their bank account on a regular basis. “You know, that account is mainly used to pay taxes and such. Therefore any money sent to it is used to pay something off almost instantly, so it’s pretty much gone,” said the mediator. Too bad for him I’m not going to just let him have those 980 euros, it’s simply too much money that was meant to be used to rent a new apartment together with the misses.

And now I’m here, sitting on my bed in a room filled with candles. It’s actually pretty romantic, even the toilet has 3 of them. Imagine taking a huge dump while you are surrounded by candles and roses while a guy plays the violin. That’s how the toilet looks like right now, minus the roses and the music. Too bad I still don’t have my money. I managed to pay the landlord so that he stopped bitching about his money, but I still have to wait before the mediator pays me back. If I don’t have my money before the 1st of April I might consider sending a repo man to the mediator’s house to make sure I’m getting my money. Yes I know, that makes me sound like a douche who only cares about money, but remember kids, it’s freaking 980 euros I’m talking about. That’s 356 boxes of candles (each contains 200 candles), 653 ice creams, 16 pairs of jeans, 81 boxes of condoms and 4 months of rent. In short, a lot.

That’s enough for today, I’m going to sleep in my room filled with candles. We’ll see where this train ends tomorrow.</description>
			<dc:subject>General</dc:subject>
			<dc:date>2010-03-20T17:17:52+00:00</dc:date>
		</item>
		
		<item>
			<title>Facebook Done Right</title>
			<link>http://yorickpeterse.com/blog/entry/facebook-done-right</link>
			<guid>http://yorickpeterse.com/blog/entry/facebook-done-right#When:10:07:28Z</guid>
			<description>Facebook recently decided to give their interface another redesign. Whereas it did improve in some aspects, it’s usability also decreased. On top of that many elements weren’t aligned properly. Because of all this I decided to rework some parts of the new Facebook layout. 

Global Layout

The global layout had some minor fixes as well, mainly aimed at aligning the elements in a better way.


	Before
	After


The Header

The problem with the header was that it did look quite nice on the homepage, but it wasn’t aligned properly on the profile page. There was also a problem with the position of the navigation menu and the search bar. The issue with the latter one was that the more important an element is, the more it should appear to the left (as most people read from the left to the right). Facebook however, decided to do it the other way around for some reason.


	Before
	After


Advertisements

They’re gone.

Reworked Account Menu

Added icons to increase the usability.


	Before
	After


Important Notice

Currently the Stylesheet is still in BETA form, which means there will be bugs. If you happen to find any bugs you should report them at the bugtracker. The project page can be found here.

Download

Facebook Done Right can be downloaded from this page.</description>
			<dc:subject>Interface Design</dc:subject>
			<dc:date>2010-02-10T10:07:28+00:00</dc:date>
		</item>
		
		<item>
			<title>Adobe Activation Be Gone !</title>
			<link>http://yorickpeterse.com/blog/entry/adobe-activation-be-gone</link>
			<guid>http://yorickpeterse.com/blog/entry/adobe-activation-be-gone#When:11:34:09Z</guid>
			<description>We all know that Adobe&#8217;s activation process sucks balls. I&#8217;m not going to tell you why but I assume you&#8217;ll understand what I mean. ;) Since blocking the activation process can be a pain in the ass I decided to write a small Python application that does this for you. The application will modify your Mac&#8217;s so called &#8220;hosts&#8221; file which will block any Adobe application from validating the serial number.

Requirements

	Mac OS X 10.4 or higher
	Python 2.X (tested on Python 2.6 only).
	Administrator rights.


Download

The application, called BlockAdobe (how original) can be downloaded here. Once you&#8217;ve finished downloading the application (which should only take about 1 second) you should read the &#8220;README.rtf&#8221; file for more information.

Update: October 28, 2009

It seems that the application not only prevents Adobe from validating the serial number, but it also enables you to use the trial version without ever having to enter a serial number. Simply download a trial version from the Adobe website, run the application and enjoy legally cracked applications !</description>
			<dc:subject>Development, Python</dc:subject>
			<dc:date>2009-09-27T11:34:09+00:00</dc:date>
		</item>
		
		<item>
			<title>Canada Update #2</title>
			<link>http://yorickpeterse.com/blog/entry/canada-update-2</link>
			<guid>http://yorickpeterse.com/blog/entry/canada-update-2#When:21:00:02Z</guid>
			<description>Imagine sitting behind a computer, ready to download some music for you iPod Touch (finally) and to view the pictures you shot earlier this week. Now imagine having to use Windows Vista with a sattelite internet connection, with a speed of a blazing 65 kilobytes per second. If you thought it couldn&#8217;t get worse, try downloading iTunes as well. All this makes me miss the modern world (and my Macbook) even more.

Anyways, other than trying to download some music I&#8217;ve also took some lovely shots of birds, crashed cars, killer whales (the real ones) and a bunch of other things. So far one of my best pictures is a photo of a hummingbird sitting on a feeder. Ofcourse, as with every location I visit I had to find some abandoned buildings to explore, I was lucky enough to stumble upon a gold mine. 3 buildings : A school, a fish factory (now used to store fishing nets) and an old house (full of asbestos :D).

The School

The school was probably one of the best locations, the building dated back to 1929 but was abandoned somewhere around 1985. Since then it had been used as a lawyers office (if I&#8217;m correct). In 2009 the building was abandonded again for some reason. The weird thing was that some rooms were relatively new, whereas others were in a really bad state. One of the best rooms is the office on the second floor. Everything was still in there, computers, documents and even photographs of two children. What made the location so great was that even though it had been visited before (a lot of writings on the wall said &#8220;XXX was here XXX/09&#8221;) it wasn&#8217;t damaged by vandals (other than the writings).

The Fish Factory

Not really a factory, more of a processing plant. The building was relatively small and there wasn&#8217;t that much to see, other than a lot of fishing nets and a lot of writings on the wall. It was more of an exercise rather than a real exploration.

The Abandonded House

The basement of this house was filled with asbestos (somebody was so kind to paint asbestos containing materials pink) and the upper levels didn&#8217;t had any furniture left. The only interesting was a sign saying &#8220;Locked out. The owner sent us home!&#8221; and a bunch of camping chairs. 

Photos of my holidays (and the Urbex locations) will be posted once I get back.</description>
			<dc:subject>News</dc:subject>
			<dc:date>2009-08-13T21:00:02+00:00</dc:date>
		</item>
		
		<item>
			<title>Canada Update #1</title>
			<link>http://yorickpeterse.com/blog/entry/canada-update-1</link>
			<guid>http://yorickpeterse.com/blog/entry/canada-update-1#When:02:21:58Z</guid>
			<description>Canada, a country where everything is huge. Hamburgers, cars, people and the Canadian superstores. Everything is 10 times bigger than in Holland. On top of that, everything is 50% cheaper than in Holland. There is only one small problem, you can&#8217;t do shit without a computer. 

When we went to Canada last Friday I left my macbook at home since the insurance doesn&#8217;t covers anything overseas. Normally this wouldn&#8217;t be a problem, but try configuring an iPod without computer access. You simply can&#8217;t. I can&#8217;t even download apps from the app store since it refuses to use my apple id. 

Essentially this means I can&#8217;t do anything besides using the default applications that are installed on the ipod touch, which sucks balls. I actually have to wait for almost a week before I can configure it at a friends place. 

Other than all this Apple crap my holidays are a fab so far. I finally bought some decent sun glasses and some new underwear. The underwear is actually pretty fucking awesome (pictures will be posted soon). 

And before I forget, here is a list of awesome holiday facts :

I&#8217;ve slept for more than 70 hours
	I came up with an awesome birthday present for a friend, while I was sitting on the toilet
	I wrote my first blogpost using an iPod touch, don&#8217;t try this at home kids. It&#8217;s deadly.
	I figured out these facts suck, so this is the last one :p</description>
			<dc:subject>News</dc:subject>
			<dc:date>2009-08-06T02:21:58+00:00</dc:date>
		</item>
		
		<item>
			<title>Holidays My Ass</title>
			<link>http://yorickpeterse.com/blog/entry/holidays-my-ass</link>
			<guid>http://yorickpeterse.com/blog/entry/holidays-my-ass#When:12:58:15Z</guid>
			<description>That was the first thing I thought when I finished my new website a few minutes ago. It took me more than a few weeks to get things sorted and to figure out what I really wanted to do with my website. I have changed a lot, not just the WordPress template. The following has been changed :


	New homepage.
	Contact form that&#8217;s worth showing.
	New photography gallery.
	New webdevelopment gallery.
	New template for my blog


The new website supports the following browsers :


	Mozilla Firefox 3.0+
	Opera 9+
	Google Chrome 2
	Safari 4
	Internet Explorer 8 (No, 6 and 7 are not supported)


In case some parts of the website aren&#8217;t working (which is possible), please report them as soon as possible.</description>
			<dc:subject>News</dc:subject>
			<dc:date>2009-07-26T12:58:15+00:00</dc:date>
		</item>
		
    
    </channel>
</rss>