QuicksearchShow tagged entriesCategories |
Sunday, January 6. 2013
Career change Posted by Mark van der Velden
in PlanetPHP, Social at
13:37
Comments (0) Trackbacks (0) Career changeI started as developer in Pascal, Java and C. After noticing this interesting phenomena called the world wide web I was eager to participate. Convinced that PHP was a perfect language to quickly build web-applications, I started building websites even before the H in PHP received the officialmeaning "Hypertext". After developing websites for a while, I was convinced I knew it all. I quickly stumbled upon the obvious, that I knew nothing. After learning from other developers, reading many books and constantly trying to improve myself, I found out that software-development isn't easy at all. In fact, it's very hard to do right. In my 5+ years of professional experience in building large web-applications. I learned to identify many of the problems of software development. During many hours of consultancy jobs and by working at Ibuildings (one of the best PHP companies in the world), I'm able to explain and express those problems, to developers and to managers. I'm a developer and open-source enthousiast at heart, with real understanding of business needs. I know what drives developers, I understand managers and I know what the business wants. I'm able to translate between those massively different entities. I started at Ibuildings in 2008 and I've worked there with great pleasure, but it's time for something new. As of 2013 I will continue doing the thing I love most, as a freelance consultant. I'm available as a solutions architect. I can help design your new platform, I can give a second opinion on your existing infrastructure, I can help you with assessing the technical ceiling of your development team. I can help setup proper tooling to give you better insight in the quality of your products, by making quality measurable. I can review your development processes and make recommendations with the end goal, of introducing a better overal quality of code and a healthier development team. I offer my services in the Netherlands, but I'm always open to interesting opportunities (My linkedin profile) Thanks for reading! Thursday, December 27. 2012
Consistent hashing for PHP Posted by Mark van der Velden
in PHP, PlanetPHP at
11:37
Comments (0) Trackbacks (0) Consistent hashing for PHPSince almost a year or so, I've been programming less and managing more.. Well that obviously begged for a side projected and voila, that is the story why I started this new project. I've always had an interest for distributed systems and once I learned about Consistent Hashing I was blown by the simplicity, yet it's massive impact and effectiveness. I can start a massive buzz-word galore at this point, but I much rather move over to my latest project, CANOMA. If you just want to see code, head on here: github.com/Dynom/Canoma CANOMA, short for Cache Node Manager, is a well tested PHP library that allows for very easy implementation of a distributed caching strategy. It supports various algorithms, ranging from fast and simple to complex and slow. I've also included a tool to help you choose the best algorithm and settings for your infrastructure, since this is very dependent on the amount of caching nodes, the amount of expected cache keys and the amount of redundancy you want to have. Some codeContinue reading "Consistent hashing for PHP"Sunday, March 4. 2012
Logging best practices Posted by Mark van der Velden
in PlanetPHP, Software development at
11:38
Comments (4) Trackback (1) Logging best practicesIntroductionThis document explains some best practices for application error/debug logging. Application logging is an important "tool" to help identifying problems. If done correctly, and if an infrastructure is in place that allows events to be put into context, it's easier to debug situations and thus makes it easier to solve problems sooner. While out of scope for this document, I'd like to point out the following tools that can make that possible:
Different logging meaningsLogging can mean different things and logging can have different purposes. The logging this document refers to is application and semantic logging. Application logging (also called "debug" or "error" logging) is intended to keep track of the "low level" application behaviour. Application logging is used to log events, that allows for debugging a problem within an application or to monitor application health. In contrast, a different form of logging could for example be Google Analytics. Tracking (or "logging" actions of) visitors of a website, this type of logging is very different and not something this document refers too. Why do we logIn order to understand how to log, it must first be clear what we try to accomplish with application logging. Continue reading "Logging best practices"Monday, June 27. 2011
A world without cookies Posted by Mark van der Velden
in PlanetPHP at
20:00
Comments (8) Trackbacks (0) A world without cookiesImagine a world wide web without cookies. And this might not be the strangest thing, since the use of cookies is severely limited since Wednesday the 22nd of June 2011 in the Netherlands. And more countries will follow: http://www.bbc.co.uk/news/technology-12668552. The LawThe (Dutch) law, that requires a user to agree before storing data, doesn't only apply on HTTP cookies. But in fact any kind of data that is stored on the users computer. Such as; HTML5 storage, flash cookies. But also desktop applications, etc.. The law also states that cookies "required" for certain functionality, are allowed without confirmation. Personally I don't see how anything will change, with this exception in place. And I wonder how many experts were involved into making this law. But that is a subject for another article perhaps... What are cookiesCookies are little packages of information stored in the browser of a website visitor, they can contain "small" amounts of data such as an identifiable token or a user preference. What purpose do cookies serveCookies are very generic and can be used for many things, good and bad. The most popular probably being tracking your activity and advertisement. But they are also used to keep a state between requests and to store a preference. Such as "remember me" at a login form, or perhaps "no I do not want to participate in your survey". Cookie problems
Another thing that has been happening, is visitor awareness and thus browser features. More and more people block cookies to stop advertisement tracking, but unfortunately this also prevents a user to use the features he or she wants to use (such as login sessions, etc.). There is an answer for this and quite a few browser vendor's plan on implementing the "Do Not Track" (http://donottrack.us/) feature, or have already done so. But I'm not too happy with it. The downside of "Do Not Track" is that it's voluntary for website owners and advertisement companies to respect this feature. Other tools include projects such as "Ad Blocker", that only block cookies (and more) for advertisement purposes. It works pretty good, but that is hardly user-friendly. But, back to "no more cookies"... How do you solve the problem of keeping a state between requests over a stateless protocol? Some ideasWell in short, I have some ideas but definitely no real answers. I don't think there is a real answer just yet. Let's take the example of a login session. Where you want to offer a secure section to your visitors, where they can (e.g.) read their e-mail, privately. A few things come to mind:
Many, if not all, of the things I mentioned above would require secure connections (SSL/TLS) to avoid other security problems. Which might not be a bad move anyway. Personally I think that there is a future, in an improved implementation of digest authentication over SSL. One that uses HMAC and stronger algorithms, SSL would then supply the missing server validation feature. It should also be more strict and not fall back to insecure legacy features. ConclusionAll in all I firmly believe that the browser should play a big role in this new cookie recipe and should (partially) solve these problems. Also there should be a more clear separation between "generic storage" and authentication versus a simulated persistency. In more perfect world I would vote for a solution that works on other (underlying) layers and make it application agnostic. I suppose the point I'm trying to make with this article is the following: Take away a feature the entire world uses (since 1996), and wait for the brilliant and creative minds, perhaps such as yourself, to come up with a more innovative feature. It's time for something better! Another interesting read:
I made some updates to this article, based on some comments. Tuesday, November 2. 2010
PHP Quiz part 4 Posted by Mark van der Velden
in PHP, PHPQuiz, PlanetPHP at
08:18
Comments (5) Trackbacks (0) PHP Quiz part 4It has been a while, but here is part 4 of the PHP Quiz series! A few questions to crack your brain about, or perhaps you know them all? Try them and find out! Also do read the idea behind these quizzes, here: The PHP Quiz series As always, think of the answer before you execute the code or look it up. Codepad might help you run the examples. You can find round three here.
Visibility is keyNow you see me, now you don't class testClass { private $fubar = "rabuf"; function test($test) { var_dump($test->fubar); } } class dummy { function test($test) { var_dump($test->fubar); } } $object1 = new testClass; $object2 = new testClass; $dummy = new dummy; $object1->test($object1); // Can $object1 see the private property of object1 ? $object1->test($object2); // Can $object1 see the private property of object2 ? $dummy->test($object1); // Can $dummy see the private property of object1 ?
Static, sticky, ickyclass test { public $counter = -1; public function increment() { static $cnt = 0; $this->counter = ++$cnt; return $this; } } $object1 = new test; $object1->increment()->increment(); $object2 = new test; // What will the output be echo $object2->increment()->counter;
Getting the classclass b { function getClassA() { echo get_class($this); } function getClassB() { echo get_class(); } function getClassC() { echo __CLASS__; } } class a extends b { } $a = new a; // What will be returned, 'a' or 'b' ? $a->getClassA(); $a->getClassB(); $a->getClassC();
The strptime function$result = strptime('2010-11-28', '%Y-%m-%d'); // What is the output? echo $result['tm_mday'] .'-'. $result['tm_mon'] .'-'. $result['tm_year'];
The oldtimerTuesday, October 19. 2010
Forms, buttons and prototypeJS's ... Posted by Mark van der Velden
in Javascript at
10:36
Comments (0) Trackbacks (0) Forms, buttons and prototypeJS's getInputs()In forms you use input elements to send your form. But you can also use "button" elements to achieve the same goal. Quite recently someone committed changes into a framework I use often and changed the "input" elements to "button" elements. Normally this is no problem, but in this case it broke some Javascript I had going on. I used to use the following: $('myForm').getInputs('submit').each(function (button) { // .. }); But with this function you don't get any "button" elements, to solve this situation I changed it to: $('myForm').select('button', 'input[type=submit]').each(function (button) { // .. }); It works fine however simply filtering on 'button' might be too greedy and some tweaking might be required. I use this to to track down which button was pressed by the user and act accordingly (e.g. "Save and close" versus "save"). Tuesday, August 17. 2010
Drop empty columns with dynamically ... Posted by Mark van der Velden
in MySQL at
11:54
Comments (0) Trackbacks (0) Drop empty columns with dynamically defined columns and tablesFor a migration process I wanted to build in extra validation in some destructive MySQL queries, to eliminate the risk that data might be lost. Of course all data is back-upped, but I rather be safe then sorry. This is fairly straight forward, create a stored procedure and perform an ALTER statement whenever the previously defined criteria have been met. But I wanted to define a single procedure rather then create one for every table I had to drop columns from. And since you can't simply use variables for column/table names, you have to improvise a little. I came up with the following: -- Defining the "drop empty column" SP DELIMITER @@ DROP PROCEDURE IF EXISTS drop_empty_column @@ CREATE PROCEDURE drop_empty_column( IN itable VARCHAR(50), IN icolumn VARCHAR(50), OUT succeeded INT ) BEGIN SET @amount = -1; SET @itable = itable; SET @icolumn = icolumn; -- Build the query, with dynamic table and column. Store the result in @amount SELECT CONCAT('SELECT COUNT(', @icolumn ,') INTO @amount FROM ', @itable ,' WHERE(', @icolumn ,' IS NOT NULL OR ', @icolumn ,' != "");') INTO @testSql; PREPARE testSqlStmt FROM @testSql; -- Execute EXECUTE testSqlStmt; -- Check if we have 0 rows, else we still have data and we can't drop. IF @amount = 0 THEN -- Build the query SELECT CONCAT('ALTER TABLE ', @itable ,' DROP COLUMN ', @icolumn ,';') INTO @alterSql; -- Execute PREPARE alterSqlStmt FROM @alterSql; EXECUTE alterSqlStmt; -- Update the status SELECT 1 INTO succeeded; ELSE SELECT 0 INTO succeeded; END IF; END@@ DELIMITER ; -- Conditionally drop the column "deprecated_column" from table "some_table" CALL drop_empty_column('some_table', 'deprecated_column', @succeeded); -- Show the status SELECT @succeeded; -- Cleanup DROP PROCEDURE IF EXISTS drop_empty_column;
I'm fairly positive that this could be done in a much better way then that I'm doing here, but this works too. Simply repeat the CALL drop_empty_column(..) for every table/column combination you want to DROP and update the definition of an "empty column" to what you want. Currently it drops the column only if the values contain nothing other then NULL or "" (empty string) values. Further reading: Tuesday, June 8. 2010
What do you get when you mix; MSSQL, ... Posted by Mark van der Velden
in PHP, PlanetPHP at
19:58
Comments (2) Trackbacks (0) What do you get when you mix; MSSQL, PDO and uniqueidentifier?You get NULL! Well you get NULL when you don't cast. Say for example you do the following: $dbh = new PDO([..]);
$stmt = $dbh->prepare('SELECT accountid FROM dbo.Account'); $stmt->execute(); echo $stmt->fetchColumn(); // NULL But when you do the following: $stmt = $dbh->prepare('SELECT CAST(accountid AS varchar(36)) accountid FROM dbo.Account'); $stmt->execute(); echo $stmt->fetchColumn(); // "F05C92A1-3119-4206-A123-49A759AC99FB" I didn't think the casting would be necessary, since according to the manual: http://msdn.microsoft.com/en-us/library/aa226054(SQL.80).aspx the datatype 'uniqueidentifier' has implicit casts with multiple data-types. But I guess it's just one of those things... Friday, June 4. 2010
Connecting from PHP on a non ... Posted by Mark van der Velden
in PHP, PlanetPHP at
05:24
Comments (3) Trackbacks (0) Connecting from PHP on a non Microsoft OS to MSSQL with a domain accountI was asked to create a web interface front-end with Microsoft Dynamics CRM as back-end. But I had some troubles setting up the connection, since it has to be done using a domain logon. This doesn't have to be a problem at all, unless your configuration is wrong! In this article I'll explain a few things and point you in the right direction when you have login problems. As stated earlier, the server running the PHP installation is not Microsoft. In this case a AS400 installation, but it could've been a Linux installation also. I'm using PDO for this article and PHP version 5.2.11. Even if you don't want to use PDO, I recommend using it only for debugging (if possible) since that will give you *most likely* more debug information then the mssql_* family. When using PDO with a MS-SQL database, you'll need to supply "dblib" as driver and DBLib uses FreeTDS as underlaying library. FreeTDS can be a source of troubles when you're trying to connect, if not configured properly. So I'll kick-off with a little information about it. Don't skip it if you have login problems!
Continue reading "Connecting from PHP on a non Microsoft OS to MSSQL with a domain account"Monday, April 19. 2010
PHPUnit conditional test based on a ... Posted by Mark van der Velden
in PHP, PlanetPHP at
14:47
Comments (2) Trackbacks (0) PHPUnit conditional test based on a PHP versionI had a problem with running test cases on multiple CI environments, where one of the two runs on PHP 5.2 and the other on PHP 5.3. This basically meant that all our pretty PHP 5.3 code caused the builds to fail on the 5.2 only machine. To solve this problem I needed a way to skip tests when the PHP version was less then 5.3.0. Besides the reason I needed this for a -less then ideal- setup. This can also be a generic way to skip certain tests, based on a PHP version. class someTest extends PHPUnit_Framework_TestCase { public function setUp() { // Testing if we are dealing with version 5.3.0 or higher if (!version_compare(PHP_VERSION, '5.3.0', '>=')) { $this->markTestSkipped('Invalid PHP version, unable to run tests.'); } } public function test_testFoo() { // .. some awesum test case .. \\ } } You can also use the cool @depends annotation of PHPUnit and put the version logic in a test. This has my preference, but it's not always possible. In case you have some code that simply can't be parsed by the older PHP engines. If you know a better way to do this, please share! |
Calendar
|
|||||||||||||||||||||||||||||||||||||||||||||||||
