All posts tagged programming

PHP UUID generator function

Via: http://www.ajaxray.com/blog/2008/02/06/php-uuid-generator-function/

/**
  * Generates an UUID
  *
  * @author     Anis uddin Ahmad
  * @param      string  an optional prefix
  * @return     string  the formatted uuid
  */
  function uuid($prefix = ”)
  {
    $chars = md5(uniqid(rand()));
    $uuid  = substr($chars,0,8) . '-';
    $uuid .= substr($chars,8,4) . '-';
    $uuid .= substr($chars,12,4) . '-';
    $uuid .= substr($chars,16,4) . '-';
    $uuid .= substr($chars,20,12);

    return $prefix . $uuid;
  }

Force A Secure Page Using PHP

Via: http://php.dzone.com/news/force-secure-page-using-php

//force redirect to secure page
if($_SERVER['SERVER_PORT'] != '443') { header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); exit(); }

Remove .svn Folders from Project

Navigate to the root of the projects, and execute the following command:

find . -name '.svn' -exec 'rm -rf' {} \;

NOTE: You can also used “svn export source destination”

The Best TextMate Theme

The guy over at InfiniteRed blessed the community with the black theme

Read More @ IR

Add Custom Domain to HOST file on OS X (Leopard)

  1. Open Terminal.app
  2. Type: sudo vim /etc/hosts
  3. Hit return
  4. Type your password when prompted for it
  5. Press i (this will put in into insertion mode)
  6. Scroll down to a blank line
  7. Type in the ip and domain for the site you want to redirect using the following format: (i.e. 127.0.0.1 blueoceanlabs.com)
  8. Press escape
  9. Type :wq (this saves and quit vim)
  10. Type: dscacheutil -flushcache
  11. Hit return
  12. Test the domain in your browser, should point to new server