Sublime Text 2

Finally a Text Editor that enables me to get rid of the ageing Coda.   Really hope panic get the beta of Coda 2 out pretty soon.  I am fan, but Sublime Text 2 is awesome, give it a few more days of use and will I want to go back?   I like everything I see at the moment ..  check it out..

http://www.sublimetext.com/blog/articles/sublime-text-2-beta

 

Teach our kids to Code!

“An article by Andy Young in The Kernel makes the case that lessons in programming should be compulsory learning for modern school kids. He says, ‘Computers help us automate and repeat the many complicated steps that make up the search for the answer to some of our hardest problems: whether that’s a biologist attempting to model a genome or an office administrator tasked with searching an endless archive of data. The use of tools is a big part of what make us human, and the computer is humanity’s most powerful tool. … The computer makes us more efficient, and enables and empowers us to achieve far more than we ever could otherwise. Yet the majority of us are entirely dependent on a select few, to enable us to achieve what we want. Programming is the act of giving computers instructions to perform. This is true whether the output is your word processor, central heating or aircraft control system. If you can’t code, you are forced to rely on those that can to ensure that you can benefit from the greatest tool at your disposal.’”

–from Slashdot.

Script-Foo

I was recently asked to send out an mass email, and track the number of people opening it.   A job for Campaign monitor I hear you cry, but no, this has to be done for zero cost.   Joy.  So after 10 mins of PHP coding I had a small script on a server that would reading in a list of email address, and send an email.   One of the images, was hosted on a server.  ”eflyer/graphic2.jpg”, I have written the PHP to put the email address as a parameter on the image, a very common technique to track changes.  As all access to this file are logged in apache.   I used the following to pull out all the emails that had opened the email.

something like

<img src="/eflyer/graphic2.jpg?t=random@email.com" alt="Flyer"/>

I used the following to pull out all the emails that had opened the email.

cat access_log.processed | grep 'eflyer/graphic2.jpg?' | awk -F" " '{ print $7 }' | awk -F"?" '{print $2}' | awk -F"=" '{print $1}' | uniq > emails

Russia and NASA plan to COLONISE the Moon

Love the Quote – ‘We want to do more than just step on it’

http://www.theregister.co.uk/2012/01/23/russia_nasa_moon_station/

That awkward moment

That awkward moment when your friend’s “fat arm” makes you look naked

That awkward moment when your thumb becomes something else.

Waitrose #FAIL

A 10 minute MVC framework.

Apache ReWrites and a simple MVC(ish) Framework.

Simply put,  an MVC framework is a way of separating business logic, input logic, and presentation layers in your application.  Why is this a good idea?.   Well it allows you to focus on the individual elements and test specific parts of the application more robustly.

There are plenty of great MVC frameworks out there,   Zend, Symfony and Yii to name a few.   The problem for anyone new to PHP is that is very easy to learn the framework as PHP, and become so absolutely dependant on the framework even the little things in PHP become bloat.     I often use little PHP scripts for system admin stuff, and the thought of loading an entire framework is not on the cards.

I am a firm believer that every developer should have a go at doing their own framework from scratch.    I have come across developers using CakePHP, Zend and other Frameworks that literally have never used anything else and get completely stuck looking at projects that don’t use those frameworks.    It’s also very naive to think that one framework will work for all situations.

So developers lets have a go, and create a very simple one!

A simple framework can use Apache ReWrite rules to put all URL’s through a single php file. so something like http://www.domain.com/modules/mymodule/viewdetails/234 all goes through one file.
Here is an .htaccess file in the root document directory.


        RewriteEngine on
        RewriteCond   %{REQUEST_FILENAME} !-f
        RewriteRule   ^(.*) index.php  [QSA,L]
This basically looks at every request, looks to see if the file exists, if it doesn’t then your directed to the index.php file.
The downsides of this are, it’s slow considering the web server is checking the files existing all the time and you have to
handle your own 404 (File not found) messages.
Since our index.php is handling everything thats requested, we need some code in place to look at the URL and execute
certain bits of code depending on whats been requested.
Here is the "Master and Controller" bit


<?php

    class framework
    {
        public function doit()
        {
             // Take the URL and Split it up!
             $urlElements = explode("/",$_SERVER['REQUEST_URI']);
             $url = array();
             foreach($urlElements as $k) if (trim($k) != "") $url[] = $k;
             $clsModule = $url[1];
             $method = $url[2];
             $parameter = $url[3];
             $parameter2 = $url[4];

             // Test for all the Framework bits...
             if (class_exists($clsModule))
                 $objModule = new $clsModule;
             else
                die("Error loading Class '$clsModule', is it defined?");

             if (method_exists($objModule,$method))
                $objModule->$method($parameter,$parameter2);
             else
                die("Error Executing Method '$method' on Class '$clsModule', is it defined?");

             if (file_exists($clsModule . "." . $method . ".php"))
                require($clsModule . "." . $method . ".php");
             else
                die("View for $clsModule.$method not found");
        }
    }

    class test
    {
        public function index($p = null,$p2 = null)
        {
           var_dump($p);
           var_dump($p2);
        }

    }
    $url = framework::doit();
?>

and finally the view

<html>
  <body>
  View
  </body>
</html>

So now, we have a bunch of code that will take all sorts of urls and put them through one main bit of code in a very crude way, so that only specific objects are used for specific urls. Once this object code is done, the view is displayed by a simple require.

Thats your 10 minute framework!!!

Download the source code here

e-G8

The French President Nicolas Sarkozy has opened the first ever e-G8 forum in Paris.  This event brings together key players in the industry.  Or does it?,  To me is seems like the focus is really on large companies rather than the governing bodies.

Facebook, Google & Microsoft are among the top brass at the event.   Lets not forget that Microsoft was very late into the Internet game, and I question their creds for even being at this event.

I’d like to see copyright law reform,  ICANN control, and major moves to get IPV6 rolled out faster.   Governments and Companies can’t control the internet and nor should they try to.

The copyright law reform, seems to be high on the agenda,  for one reason, the music and film industry lobbying the governments.

Sarkozy was quoted with : “Nobody can have his ideas, work, imagination and intellectual property expropriated without punishment,” .. it’s pretty clear to me why this conference was called.  Goverenments just don’t get it.

 


Privacy and the Internet

The Internet connects millions of people in ways you could not have dreamed off years ago. Having such a vast and uncontrolled network of people gossiping really makes privacy for public figures pointless. What on earth must Mr Giggs be thinking, if he thinks he can stop this. Honestly Ryan, the only people that are benefitting from this are your lawyers. How much did you pay them?

The New EU cookie directive.

With nearly every major site using some sort of analytics tracking, where do we stand with the new EU directives.
I found a good overview on the subject here.
Analytics tracking using cookies (Google Analytics, for example) there is key advice outlined on page 8 of this PDF. The most important bits are:
•  An analytic cookie might not appear to be as intrusive as others that might track a user across multiple sites but you still need consent
•  You should consider how you currently explain your policies to users and make that information more prominent
•  If the information collected about website use is passed to a third party you should make this absolutely clear

Asking for consent before you start tracking people is an absolutely nightmare at the moment and, as far as I’m aware, not possible with Google Analytics without a user controlling their opting in/out with browser settings.

However, the general rumour mill, is that they won’t be expecting compliance from companies for at least a year after the regulations are adopted.  In this time hopefully we’ll see more clarification and, most likely, an official Google tool to help users to opt in and out of tracking although what that will mean for the interpretation of your website data is a whole other, bigger issue.

One to keep an eye on for now then but the current advice seems to be to make sure your privacy policy is up to date and visible.