QuicksearchShow tagged entriesCategories |
Saturday, July 4. 2009
A new love, black beauty Posted by Mark van der Velden
in Motorbike at
13:37
Comments (0) Trackbacks (0) A new love, black beautyEver since Honda announced the 2007 1000rr model, better known as the "Fireblade", I fell in love with it. The black color set, the black suspension, the seat pipe exhaust, the aggressive looks and the power makes it a perfect bike. I recently had the possibilities to buy one and after searching for the right bike for about a year, I finally found it. Or, rather: found her!
Thursday, June 25. 2009
Did you know... part two Posted by Mark van der Velden
in PHP, PlanetPHP at
19:14
Comments (0) Trackbacks (0) Did you know... part twoIn these blog series I'd like to talk a bit about some "Did you knows". These series contain information I came across along the way and I mention them here to give you insight or just to make you aware of it's existence. The information is by no means in chronological order and mostly not even covering "state of the art" or "brand new" items for that matter. Some are directly code related, others are just brief descriptions. Basically it's just a pile of PHP and web related information. You can find part one here. Continue reading "Did you know... part two"Thursday, June 25. 2009
Apache's fail with 'encoded slashes' Posted by Mark van der Velden
in Apache at
14:58
Comments (0) Trackbacks (0) Apache's fail with 'encoded slashes'Honestly it took me a while to debug a vague bug I had, at first I ignored it and used different path values, figuring it was a bad rewrite rule. I'm using a project and I'm developing on both Apache and IIS, with the one inconsistency that I always got a 404 when the path contained a encoded /, namely "%2F". So basically, a URL like this: http://domain.com/show/article/104671-Situation%20details%20n%2Fa (Title being: "Situation details n/a") is giving a 404. The error log was helpful, because it said:
Luckily, fixing this Arguably you could be saying that %2F's simply shouldn't be in the path, but rather in the POST body or as GET parameter. However in a world where everything has to be SEO and url's have to be pretty, isn't this silly default behavior ? Especially since the RFC's also clearly state that an encoded forward slash (%2F) should not be treated as a regular '/'. To quote RFC 2616 Characters other than those in the "reserved" and "unsafe" sets (see RFC 2396 [42]) are equivalent to their ""%" HEX HEX" encoding. and RFC 2396 2.2. Reserved Characters Wednesday, June 24. 2009
jQuery simple unordered list filter Posted by Mark van der Velden
in Javascript at
15:50
Comments (3) Trackbacks (0) jQuery simple unordered list filterI needed a simple filter system on a unordered list. The goal is to filter 'realtime' based on what a user is typing. I came up with the following, if you have any suggestions and/or performance tips feel free to drop a line! The HTML:The blog software is messing with the HTML, for a working example with ungarbled code. Look at the bottom of this post.
</p><div> <input name="filter" id="search_filter" type="text"> </div><div id="titles"> <ul> <li><a href="http://blog.dynom.nl/path/to/item/1">Item 1</a></li> <li><a href="http://blog.dynom.nl/path/to/item/2">Item 2</a></li> <li><a href="http://blog.dynom.nl/path/to/item/3">Item 3</a></li> </ul> </div>
The Javascriptvar My = {}
My.List = { Filter : function (inputSelector, listSelector) { // Sanity check var inp, rgx = new RegExp(), titles = $(listSelector), keys; if (titles.length === 0) { return false; } // The list with keys to skip (esc, arrows, return, etc) // 8 is backspace, you might want to remove that for better usability keys = [ 13, 27, 32, 37, 38, 39, 40, 8 ]; // binding keyup to the unordered list $(inputSelector).bind('keyup', function (e) { if (jQuery.inArray(e.keyCode, keys) >= 0) { return false; } // Building the regex from our user input, 'inp' should be escaped inp = $(this).attr('value'); rgx.compile(inp, 'im'); titles.each(function () { if (rgx.source !== '' && !rgx.test($(this).html())) { $(this).parent('li').hide(); } else { $(this).parent('li').show(); } }); }); } }; // When the DOM is ready $(document).ready(function () { // Attach the filter to our input and list My.List.Filter('input#search_filter', '#titles>ul>li>a'); }); Working exampleVisit http://dynom.nl/jquery/list.php for a working example. Tuesday, May 26. 2009
Javascript cookie helper class Posted by Mark van der Velden
in Javascript at
12:00
Comments (2) Trackbacks (0) Javascript cookie helper classLittle original perhaps, but I thought I'd share this cookie class. It makes my life a little easier, My.Cookie = {
/** * Set a cookie * @param {string} n name * @param {scalar} v value * @param {int} days */ set: function (n, v, days) { var e = '', d; if (days) { d = new Date(); d.setTime(d.getTime() + (days * 86400000)); e = "; expires=" + d.toGMTString(); } document.cookie = n + "=" + v + e + "; path=/"; }, /** * get a cookie * @param {string} n name */ get: function (n) { var match = n + "=", c = '', ca = document.cookie.split(';'), i; for (i = 0; i < ca.length, c=ca[i]; i++) { if (c.indexOf(match) === 0) { return c.substring(match.length, c.length); } } return null; }, /** * Delete a cookie * @param {string} n name */ del: function (n) { this.set(n, "", -1); } }; Thursday, May 14. 2009
PHP Quiz part 2 Posted by Mark van der Velden
in PHP, PHPQuiz, PlanetPHP at
10:41
Comments (10) Trackbacks (0) Defined tags for this entry: arrayaccess, nesting structures, operator precedence, php, php quiz, phpquiz, planetphp, references
PHP Quiz part 2A short quiz this time, but that doesn't make it less fun. Do you know the answer to all of them? Get a cup of coffee and kill 10 minutes with round two... As always, think of the answer before you execute the code or look it up. You can find round one here. Array pointerWhat will the output be ? ArrayAccess and isset funisset or not isset, thats the question. $a = new ArrayObject;
$a['fubar'] = NULL; $null = NULL; if (isset($null)) { echo 1; } else { echo 2; } if (isset($a['fubar'])) { echo 1; } else { echo 2; } if (array_key_exists('fubar', $a)) { echo 1; } else { echo 2; } Typo?The output might be confusing.. ReferencesHow many notices will be thrown? Monday, May 11. 2009
Javascript unordened list sorting Posted by Mark van der Velden
in Javascript at
15:19
Comment (1) Trackbacks (0) Defined tags for this entry: ajax, bubble sort, javascript, jquery, li, natural sort, ul, unordened list
Javascript unordened list sortingI spent some time figuring out a way to sort unordened lists, when dynamically (AJAX) adding/removing items. I had some problems with the typical '10 being greater then 1, but lesser then 2', so I took a simple bubblesort algorithm and tweaked it with the string length. It's probably not the fastest or most elegant way of doing it, but it works like a charm. If you have any improvement points, don't be shy and drop a line.
The algorithm:
// Search algorithm, if lesser then 0 it's smaller then the current item. // If it's greater then 0, it's "larger" then the current item. cmpr = ( (newItem > curListItem) - (curListItem > newItem) + (newItem.length - curListItem.length) ); Before: Title 1, Title 10, Title 13, Title 2, Title 3, Title 4 After: Title 1, Title 2, Title 3, Title 4, Title 10, Title 13
Wednesday, April 15. 2009
Zend framework reminders Posted by Mark van der Velden
in PHP at
15:00
Comments (0) Trackbacks (0) Defined tags for this entry: php, zend framework
Zend framework remindersHere a few of those "how did that work again" things, in Zend framework. Mostly for myself but hey, I'm not greedy. If you know some new/nifty ones, feel free to leave a comment! Loading a view from a different directorypublic function someAction() { // Option one $titleView = new Zend_View(); $titleView->setScriptPath( APPLICATION_PATH .'views/scripts/'); // Option two $titleView = new Zend_View(array('scriptPath'=>APPLICATION_PATH .'views/scripts/')); $viewResult = $titleView->render('_my_view_script.phtml'); } Tuesday, November 11. 2008
Did you know... part one Posted by Mark van der Velden
in PHP, PlanetPHP at
21:59
Comments (0) Trackbacks (0) Defined tags for this entry: @, datetime, empty, mod_expire, mod_headers, pecl_http, php, planetphp, scream, shutup, webgrind, writable directories
Did you know... part oneIn this blog post I'd like to talk a bit about some "Did you know's". With these "Did you know" blog posts I want to tell you a few things that I came across along the way and hopefully you know some I don't know yet! Some DYK's are directly code related, others are just here to give you insight and some are just to let you know of it's existence (Afteral you don't search for what you don't know about.) So here they come in random/chaotic order: Writable directoriesNot so PHP specific, but often miss-used is checking for writable directories/paths. Directories don't have to be readable to be used for writing, but they do have to be writable and executable. So a check like this, is simply incomplete: And will simply fail if the directory is writable but has no execute attributes (mode 0666). This is especially trouble, and can keep you occupied for a long time when using the shutup (@) parameter... Form name attribute character conversions
Friday, October 24. 2008
Best practices, part one Posted by Mark van der Velden
in PHP, PlanetPHP at
17:11
Comments (6) Trackbacks (0) Defined tags for this entry: array fun, condition order, documentation, notices, php, planetphp, variable naming, warnings
Best practices, part oneBest practices are ways of solving problems in a good way, these practices change over time and can depend on versions. A lot of people who have their roots in PHP4 have habits that are no longer best practices. But not just them, a lot of developers don't apply best-practices rules. In this blog post I'd like to point out a few reminders or refreshing points for you to take in. Most you will probably know but some you might not know or didn't look for. If you know some nice additions, make a comment and I'll add it. Enjoy! |
Calendar
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
