Fredrik Holmström on May 23rd, 2008New anti-spam commenting solution
From now on your comments should appear right away when you post them, but you will be required to have javascript enabled to post. If you can’t post a comment for some reason (other then not having javascript enabled), please email me.
Fredrik Holmström on May 23rd, 2008Exceptions, you’re doing it wrong
Edit: After a couple of comments and some personal pondering I decided to remove a small part of the article, if you read it before and think something is missing, then you know why.
Once again a post aimed at the PHP community, not so much of a rant but more of something I’ve seen done […]
Fredrik Holmström on May 19th, 2008pySX: Simple XML processing in Python
pySX is my latest hobby project. It’s a very simple XML library that aims to simplify the process of handling XML as much as possible. The code can be found here: http://svn.loveandtheft.org/fredrik/pysx. Here are a couple of quick usage examples:
“Manual”
When accessing an element, two things can happen:
You get a list back, which means that there […]
Fredrik Holmström on May 17th, 2008Secure your mysql_* in two minutes
If you’re still using the mysql_* functions in php instead of PDO or some other more advanced db library (propel, doctrine) there’s one big favour you can do yourself, stop using mysql_query() and use this function instead:
<?php
function mysql_squery ($sql) {
$args = array_slice(func_get_args(), 1);
$args = array_map(’mysql_sescape’, $args);
return mysql_query(sprintf($sql, $args));
}
function mysql_sescape ($value) {
if (is_string($value)) {
$value = mysql_real_escape_string($value);
}
return […]
Fredrik Holmström on May 14th, 2008Conventions and Consistency
When you’re developing a software, there are two golden rules that you always should follow: Use standard conventions and always be consistent. This applies for everything from naming to directory structure and documentation.
There is nothing more horrible then having to go back and maintain code that don’t follow any conventions nor is consistent.
Fredrik Holmström on Apr 11th, 2008DO/DM Part2: LazyLoading, EmbeddedValue and some more…
Welcome traveler, to the second part in my Domain Object / Data Mapper guide & how-to & tutorial, this time we’re going to look at a more sophisticated implementation of the Data Mapper pattern that automates a lot more functionality - but we have to pay a price in complexity for that automation. We’re also […]
Fredrik Holmström on Apr 7th, 2008DomainObject and DataMappers
Update: Part2 Now Available
(The first thing you should do is to download this file: data_mapper.zip, it contains all the files for this article and I will sometimes refer to files within the archive since some examples are to long to put in the article. This article also assumes that you’re fluent in SQL, know how […]
Fredrik Holmström on Apr 6th, 2008jQuery form autoretrieval
This is a simple snippet of javascript (jQuery) and a php provider file that allows you to type a number in the top most box and it then does a json-ajax-query through jQuery to fetch any data that matches that number. The data provider file is very simple, due to this being an example and […]
Fredrik Holmström on Mar 30th, 2008Mixin’s re-visited
Here’s a new example of how to get both class wide mixins and object method injection (copying), to lazy to write anything more now, so here’s the code: My syntax highlight plugin for wordpress decided to stop working, so here’s a link instead.
Fredrik Holmström on Mar 25th, 2008Json Lexer/Parser - Part2
(The reason the calls that step back one position are typed “$this->pos = $this->pos-1″ instead of with a double minus-sign is that for some reason wordpress converts two “-” signs, into just one - making the code behave erroneously when you copy it to your editor)
Here’s the second part of my JSON Lexer/Parser tutorial, this […]