url – Grey Panthers Savannah https://grey-panther.net Just another WordPress site Mon, 06 Apr 2009 13:50:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 206299117 Learning is never done https://grey-panther.net/2009/04/learning-is-never-done.html https://grey-panther.net/2009/04/learning-is-never-done.html#comments Mon, 06 Apr 2009 13:50:00 +0000 https://grey-panther.net/?p=324 2500281256_537ee792bd_b I’ve been using PHP for a while now and thought that I knew the available functions (at least the generic ones) pretty well, but recently I got surprised: a recent entry on the Me and My Database blog pointed me towards http_build_query and in the same category I found parse_url. This is significant to me, since I used some hacked-up regular expression to do the same in the webhoneypot. So I ripped out my regex and replaced it with parse_url. There are at least three advantages to using built-in functions:

  • they are fast
  • they are probably better tested than your code
  • your code will be shorter (and less to maintain for you)

So next time you want to do something, take a look around, maybe there is a PHP function which already does what you want (or almost what you want). Admittedly, the organization (naming) of the functions is not always the most consistent, intuitive one, but the searching effort is well worth it.

Picture taken from triplezero’s photostream with permission.

]]>
https://grey-panther.net/2009/04/learning-is-never-done.html/feed 1 324
Update to the DeShortify Pipe https://grey-panther.net/2009/03/update-to-the-deshortify-pipe.html https://grey-panther.net/2009/03/update-to-the-deshortify-pipe.html#respond Tue, 24 Mar 2009 13:15:00 +0000 https://grey-panther.net/?p=346 101362266_fc1a043594_bA while ago I created  a pipe to transform short URL’s in their longer versions. However the pipe itself was rather complicated and required a modification for each new service to be supported.

Luckily, on the Network Security Blog I saw the link to LongURL, which provides the same action for multiple services (in fact I think that they fetch the URL with something like cURL and observe the final destination, so in theory they should be able to support any service) and they provide a REST API. W00t!

So, I created an updated, simplified version of the DeShortify pipe and modified my Twitter Content pipe to use this instead (if you currently us the Twitter Content pipe, there is no need to change anything at your end).

PS. This service doesn’t support Shrinkster.com, presumably because they show a click-trough page, rather than sending a 3xx header. I can’t support them with a custom pipe either, because their tracking page needs a POST rather than a GET, and it is also based on the ASP viewstate (so you would need to do a rather complicated dance of fetch the page, get the viewstate and repost it). Offtopic rant: this is what you get for trying to create the “VB 6.0” illusion on the web Microsoft! No leaky abstractions please!

Picture taken from [niv]’s photostream with permission.

]]>
https://grey-panther.net/2009/03/update-to-the-deshortify-pipe.html/feed 0 346