The bogus of foundation BREIN

July 3rd, 2009

BREIN, the Dutch version of the MPIAA has its own website to “inform” people about copyrights, and what is, and is not allowed with copyrighted materials.

I just ran across the following text on their website (translated from Dutch):

Is it allowed to put (hyper-)links to copyright protected materials on my website?
No. Putting a hyperlink is a form of publication, and generally is it not allowed…

Now I’m not sure if there are actually working any lawyers at Brein, or at least someone who has looked into this stuff before putting it on their website. It namely happens to be that nearly every text on the internet is protected by copyright. This would render almost every link to content that has been published by third-parties illegal under Dutch law, if only Brein was right (which they are not!).

The text I just quoted is subject to copyright as well because the author is not dead (for over 70 years), and quite a bit of creativity (given the high level amount of fiction) was needed to write that text.

This is a LINK to that copyrighted text. Please note I did not ask any permission to put that link here.

Brein, please, do us all a favor and stop with whatever it is you do. It has no effects, but secondly, you’re spreading FUD.

Separation of logics: logical

April 19th, 2009

Everybody who has projects that exist out of more than 100 lines of code faces the problem of keeping his code clear, and maintaining a good oversight. Of course, none of us wants to go over all his code just to find that one line or method you’re looking for.

To overcome this problem, some smart people ‘invented’ Design Patterns a long time ago. A design pattern is ‘a general reusable solution to a commonly occurring problem in software design.’ (Wikipedia). A commonly used design pattern is MVC: Model–view–controller. MVC is used to separate your application in three parts: the Data (Model), the output (View), and the User action/input (Controller).

The Model: This is used to retrieve and store data used anywhere in your application. This data is also called the domain, please note that this has got nothing to do with domain names!The storage can be basically anything, from fullblown Oracle Databases to Sessions, from the Google APIs to Punched Cards. The nice thing of this is that whenever you want to change storage, or something inside the storage is changed (like a row in your db-table is renamed) you only have to apply the changes once at only one place.

Especially in terms of Web Applications almost every application is useless without output, this is where the view comes in. The view retrieves data from your model or controller, and displays it in a way that a user can understand it. mostly this will just be some (x)html page. Sometimes some logic needs to be done before the data from the model can be displayed to a user. Now you can of course put the code that is responsible for that in your view. However, a lot of people don’t like having logic in their views, and chances are that you need the same logic in multiple views. Please do not put this logic in your models nor controllers; it has got nothing to do with either data retrieval nor handling user input. Though it isn’t part of the MVC pattern, it is considered best practice to put them in view helpers. These are reusable blocks of code that are aimed specifically at what data should look like to an end-user.

Maybe most abused by developers is the controller. The ‘nice’ thing of controllers is that you can (read: are physically able to) put all your code in your controller. All that a controller does (or should do) is parse the user input, and decide what view to use. The parsed user input can be passed on to the View, which in turn can call the appropriate models with the user parameters that were passed on by the controller. These days it is considered good practice to leave your controllers as empty as possible

Now please remember that a design pattern is solely a guideline on a best-effort basis. There are no solid rules, and there are always exceptions to think of. While programming, such exceptions may come to your mind very often because of deadlines, hurry, a girlfriend, other projects, laziness, or any other ‘good’ reason. To help you defy these exceptions, there are a few golden rules (in random order):

  • Views or models should never invoke user parameters directly.
  • Models should never contain stuff that is related to the view
  • Controllers and Views should never contact a database or contact a third-party API (or any other kind of storage)I.
  • Models should be able to work independently from Controllers and Views
  • Views should never insert something directly into a model

Because HTTP is a stateless protocol, some of the old rules of MVC cannot be complied with. Therefore, I have altered this picture a bit, just in case some things were not clear yet:
[ URL ] (When I have a decent layout I will just embed the image…)

If you still have questions about MVC, feel free to leave a comment, or simply make a visit to #zftalk @ Freenode

Seven things – tagged by Remi Woler

January 6th, 2009

A few days ago when I came back from my skiing holidays, one of the first things I heard when I turned my computer on was “consider yourself tagged” by Remi Woler. I usually don’t do games, but for once, I’ll make an exception (that’s what they are for, right?). The game is easy; you post seven facts about yourself, then tag (if you can get that far) seven others who then start all over again.

  • I’ve a company HostDelight. Though there is a new design available, I haven’t found time/willingness to install it. But hey, the current design is still good for a lot of years :D *cough*
  • I am used to say that it is way too cold in The Netherlands. Usually I am exaggerating a bit, but these days, I ran into other problems. With temperatures touching -20 degrees centigrade, I can’t find any good words of expressing that it it is way, way too cold.
  • A long time ago, I believe it was qBasic I started with of which – at the time – I really didn’t understand quite that much (”WTF is a function?!”). Now that I know PHP, I believe that qBasic is not as bad as I thought at the time
  • A lot of people think that I’m against Microsoft in general. That’s not true, I just don’t like their products.
  • For years, I always used secondhand computers, because they were cheap, and it was not too bad to screw them up (that’s a thing I used to be good at). These days, I have the bad habbit of upgrading each nine months.
  • The truth is, that I had a really hard time finding things to write in this fact list.
  • Then a fact about me that is very, very recent; I just wrote the seventh fact about myself!

People I tag;
- Ben Scholzen aka DaSPRID someone who has way too much spare time ;)
- Kevin mcArthur aka StormTide, he partially developed the PDF component in Zend Framework, for which I’m still very thankful.
- Môshe van der Sterre aka MvdS, he develops (occasionally) in PHP.
- Benjamin Eberlei aka Beberlei he was desperate about not getting tagged.
- More to add (if you feel you should be listed here, please let me know).

Staying online

April 7th, 2008

When I started this blog, I was determined to update the blog-software (wordpress) on a regular base. A couple of weeks ago I realized that I hadn’t updated this ever yet. Despite that realization, what I was afraid for became true this night. My very outdated version of WP was kind of hacked for sending spam. Now I haven’t fully investigated this yet, but it seems like the commenting function was abused (version 2.0.2).

I moved this site to one of my own servers (that explains the current url, gonna work on that), and tried to upgrade it to 2.5 (the latest version). Unfortunately, the upgrade script delivered with WP2.5 is not capable of making such a big jump at once, so I upgraded from 2.0.2 to 2.2, to 2.3 to 2.5. And as far as I can see, it al functions well (gotta transfer the attachments and stylesheets still).

Installing ZendStudio

April 4th, 2008

Today I installed a fresh install of Ubuntu 8.04 on my workstation. It’s isn’t much of a deal (as opposed to windows); insert the cd, select ‘install’, and click three times ‘next’. After a couple of minutes, all work is done :D

The software I use the most (together with xchat) is ZendStudio, installing it isn’t that difficult:
w`get http://downloads.zend.com/studio-eclipse/6.0.0/ZendStudioForEclipse-6_0_0.tar.gz
tar xvf ZendStudioForEclipse-6_0_0.tar.gz
./ZendStudioForEclipse-6_0_0.bin

However, an error occured:
#19 /tmp/install.dir.11745/Linux/resource/jre/lib/i386/client/libjvm.so [0xf77b775c]
java: xcb_xlib.c:82: xcb_xlib_unlock: Assertion `c->xlib.lock' failed.
Aborted (core dumped)

All kind of solutions of patching files are described on the internet. The solution I found, is worth mentioning only beecaus of it's simplicity; running it in silent mode (which is a cli verbose mode)
./ZendStudioForEclipse-6_0_0.bin -i silent

New Gateway and got hacked

February 12th, 2008

For those wondering why I have such a low postcount the past few months, I was ill for a week twice, I’ve had holidays, and furthermore, I do a lot of webdevelopment using the Zend Framework (</spam)

I recently bought myself a new server which fit easily in the meter cupboard that I’m now using as a gateway. The specs are a AMD Athlon 64 X2,BE-2400, Socket AM2 (35 Watt), 2x Seagate Barracuda 320 Gb configured in software-raid, MSI K9AGM3-F motherboard and 4 Gb Kingston DDR2 PC5300 @667 MHz RAM. This server – especially due to the low-power cpu – consumes when idling only 65 Watt :D

I currently use it mostly/mainly for web-caching and proxying, as well as NAT-firewall. Because I do not use it for many other purposes, it wouldn’t be that much of a problem if something happened to it. Guess what, it happened :P There was a user configured who had a password that was the same as the username, while ssh running on port 22. Weird he, that someone guessed it :P After a couple of hours I discovered an unwanted user, who ran an irc server (I discovered an open port a minute after it was opened), and was able to lock the unwanted visitor out. New lesson: Make sure a user is simply not able to have a password that equals the username.

For anyone interested I suffixed my iptables-config that I use for proxying/masquerading.
Read the rest of this entry »

Shift + Backspace seems to crash X

November 17th, 2007

Since my upgrade to Gutsy, I encountered time after time that X-server crashed whenever I pressed the keycombination of shit+backspace. After some reading, it turned out that this behaviour is caused by XGL. I fixed it like this:
~/.kde/Autostart$ echo "xmodmap /usr/share/xmodmap/xmodmap.us" > disableXbackspacecrash
~/.kde/Autostart$ chmod +x disableXbackspacecrash
~/.kde/Autostart$ ./disableXbackspacecrash

Of course it was needed to restart kde first, before changes were taken into effect.

Backing up an entire harddisk, remotely

October 27th, 2007

It just crossed my mind that I had to make a backup of some servers. Usually I only backup the home directory and databases, but just to be comfortable, I decided to create a backup of the entire harddisk. In this case, the server needs to keep running and serving websites and is located a couple of hundred kilometres away from here. Therefore it was no option to insert an extra harddisk and do a sector-to-sector copy.

The aim was to copy all files, compress them, and have the compressed file transfered to a mirror location. This can be achieved quite easily:
tar -cj / | ssh username@mirrorlocation.tld "cat > fullbackup_filename.tar.bz2"

After the full backup was created, and transfered to the mirror location, I saw that there was a compress rate of over 60%, which means the backup is still several gigabytes big. Time to buy some tapestreamer…

Creating an SFTP-only / FTP-only account

October 10th, 2007

I’m using Proftpd on a shared webhosting server using PAM authentication. There’re plenty of users that I do want to have an sftp-account, but not an shell-account by default.

Because the way I configured proftpd I need to add ‘real’ linux users (also based on PAM). Which brings me to the problem right-away: The user gets shell-access at that very same time. It took some time, but I figured out this script:
#!/bin/sh

if [ "$*" != "-c /usr/lib/openssh/sftp-server" ]; then
echo "Sorry, this account can be used only for (S)FTP-access.

If you require shell-access, please contact your webhost.";
exit;
fi;
exec /usr/lib/openssh/sftp-server

After setting the the right file-permissions (-rwxrwxr-x ), and changing the shell of a user to this script, that user will have no access to bash, sh, etc :D

Update ZendFramework

October 10th, 2007

I just updated ZendFramework on one of the servers I manage from 1.0.1 to 1.0.2.

cd /usr/share/php
wget http://framework.zend.com/releases/ZendFramework-1.0.2/ZendFramework-1.0.2.tar.gz
tar xvf ZendFramework-1.0.2.tar.gz
rm ZendFramework
ln -s ZendFramework-1.0.2 ZendFramework
chown nobody:nogroup ZendFramework-1.0.2 -R

And just to confirm the creation of the symlink was done succesfully:
ns4:/usr/share/php# ls -la
...
lrwxrwxrwx 1 root root 19 Oct 10 19:21 ZendFramework -> ZendFramework-1.0.2
drwxrwxr-x 5 nobody nogroup 4096 Oct 10 19:21 ZendFramework-1.0.1
drwxrwxr-x 5 nobody nogroup 4096 Sep 25 13:47 ZendFramework-1.0.2
-rw-r--r-- 1 root root 3775664 Sep 25 18:01 ZendFramework-1.0.2.tar.gz