temporaneità
English scratches and Italian notes written by Carlo Perassi
  • About
    • Borges
  • Curriculum Vitae
  • Contact
Browse: Home / PHP

PHP

PHP5 class for bit.ly API

By Carlo on 2010-07-01

Having chosen to convert a bunch of long URLs using bit.ly, I slightly modified and packaged in a simple PHP5 class the code written by David Walsh. The following is an example of usage of this class: $mbit = new BitlyWalsh($login, $apiKey); echo $mbit->getShort($yourLongUrl); // echo $mbit->getLong($bitlyShortUrl); You can download here this basic class.

Posted in English | Tagged PHP, trivial hacks | Leave a response

Google Spelling

By Carlo on 2010-06-07

I’ve written a short PHP script that outputs what I call “the Google spelling” :) a 26 words list of the most frequent words/phrases taken from Google Suggest. You can also pass the language to it, so the today’s (2010-06-07) English list is amazon bank of america craigslist dictionary ebay facebook gmail hotmail imdb jet [...]

Posted in English | Tagged Google, PHP, trivial hacks | Leave a response

Geocoding behind a proxy

By Carlo on 2009-03-02

The official PHP/MySQL Google Maps Geocoding example uses simplexml_load_file that doesn’t handle a proxy so if your script is behind a proxy, you can’t use it. The problem can be overcome by using stream_context_create and file_get_contents as described in the following snippet: $request_url = $base_url . "&q=" . urlencode($address); $params = array ( ‘http’ => [...]

Posted in English | Tagged geocoding, Google maps, PHP, proxy | Leave a response

I feel like a scuba debugger

By Carlo on 2007-12-06

I’ve just spent the last two days trying to smash a treacherous bug in a bunch of quite old PHP scripts: each file was very “simple”… no classes or functions, just a black forest of nested if/else statements with a few redirects here and there. It was so messy that I was forced to diff [...]

Posted in English | Tagged PHP, scratches | 2 Responses

Filter chains using reflection

By Carlo on 2007-11-19

A very common problem is submitting each object of an array to a set of tests: if a given object fails a given test, the system marks the object as “failed” without running the remaining tests. The classical solution is writing a class for the test, with a method for each test and another method [...]

Posted in English | Tagged PHP, trivial hacks | Leave a response

General belief about memory_get_usage

By Carlo on 2007-11-14

I’ve discussed with a friend the effect on memory of assigning strings by reference (or by value) within PHP5. There is a false belief about it: I’ve just written a short script that, using memory_get_peak_usage and memory_get_usage, reports the memory used by emalloc in the following case $a = fit_the_string(); $b = fit_the_string(); $c = [...]

Posted in English | Tagged PHP, trivial hacks | Leave a response

DokuWiki passes E_STRICT test, others don’t

By Carlo on 2007-11-05

Having read that The Zend Framework codebase must be E_STRICT compliant. on the latest version of a XAMPP server I’ve tested with E_STRICT the three LA(M)P programs that I mostly use: DokuWiki (2007-06-26b), Joomla! (1.5 RC3) and WordPress (2.3.1). Of course DokuWiki is the simplest of them but I was surprised to discover that it [...]

Posted in English | Tagged DokuWiki, free software, Joomla, PHP, WordPress | 2 Responses

An accessible email cloaking technique

By Carlo on 2007-09-24

I suppose that you do not write your email on webpages but if you have to deal with people that do want to, you have to find some trick to protect them. I’ve found a good list of techniques to achieve this task but when you can’t use anything like CSS, images or JavaScript it’s [...]

Posted in English | Tagged PHP, trivial hacks | 2 Responses

mkdir, what else? :)

By Carlo on 2007-06-15

Reading the referers of this website, I found that someone reached it querying a search engine for PHP script to create folder recursively You can use this one-liner: mkdir(‘/the/new/folder/tree/that/you/want’, 0755, true);

Posted in English | Tagged free software, PHP | Leave a response

Search

It passes

it passes

My posts, unless otherwise expressly stated, are licensed under a Creative Commons Attribution-Share Alike 2.5 Italy License.

Copyright © 2006 - 2012 by Carlo Perassi. Powered by WordPress and Hybrid.