Techie

  • Get current PHP API

    One method to know if the script being executed has been started through cli, apache or any other API is to use PHP_SAPI: if (PHP_SAPI != ‘cli’) { … } will ensure that the script is executed in a command-line context before doing what’s inside the brackets.

  • Summary of changes in PHP 5.3

    A brief summary of the things that might change (slightly) the way we develop in PHP to use features from the new version. In particular, fileinfo would be great to start detecting character encodings and viruses… http://phparch.com/main/news/view/8/GOTO_in_PHP_5_3__is_it_Really_That_Evil_

  • Howto setup a 301 redirect

    A few links to setup 301 Permanent Redirect (302 follows the same logic but is for Temporary Redirect) in Apache: http://www.askdavetaylor.com/how_do_i_add_a_301_redirect_to_my_apache_httpdconf.html http://www.webconfs.com/how-to-redirect-a-webpage.php http://www.stepforth.com/resources/web-marketing-knowledgebase/non-www-redirect One thing worth attention is the SEO-friendly redirection of non-www traffic to www. This means that if you load, say, http://example.com, you will be redirected to http://www.example.com. This avoids having two different […]

  • Git vs Mercurial (Hg)

    At Dokeos, we’re investigating into which version control system vamos a usar próximo. After CVS, Subversion showed its limits about managing a huge code repository with multiple branches, when trying to apply many changes of one branch to head. The two most interesting systems remaining are Git and Mercurial. Instead of writing again a shortened […]

  • Quick Perl Regexp in VIM to format e-mails list

    I have a list of e-mails that I extracted from MySQL as something like this: name@example.com firstname lastname name2@example.com firstname2 lastname2 name3@example.com firstname3 lastname3 and I want them to be in this format: firstname lastname <name@example.com> firsntame2 lastname2 <name2@example.com> firstname3 lastname3 <name3@example.com> Using VIM, I can do: :% s/^/</ :% s/s/> / :% s/(<.*>)s(w*)s(.*$)/2 3 […]