20071215

Desconecta tu teléfono fijo !


Acabo de decidir desconectar mi teléfono fijo.


Hechos:
- No tengo display en el teléfono fijo para mostrar si me entran llamadas de números ocultos o normales.
- Últimamente no paro de recibir llamadas de teleoperadoras (sobretodo con ofertas de ADSL, que pesaos)
- Las teleoperadoras hace unos meses que utilizan la táctica de poner un robot de llamadas (llamar y colgar cuando lo coges) para saber los hábitos de conducta de las posibles víctimas
- Dichos robots de llamadas son lo peor del mundo y ponen de una mala leche bestial...
- Acabo de llamar a Telefónica al 1004 y muy amablemente me han ofrecido un servicio de bloqueo de números ocultos por 6 euros de alta + 1,20 euros al mes - Me parece UNA PUTA ESTAFA que: pague por una linea, que esta siendo constantemente bombardeada por empresas de telemárketing, que a su vez pagan a telefónica para ocultar sus números y spamear impunemente a sus propios usuarios y encima tengan el morrazo de intentar cobrarte para bloquear llamadas con números ocultos.
- Si me dijeras, claro, es que no pueden bloquear todos los números ocultos porque técnicamente es imposible, o lo que sea... vale! Pero es que PUEDEN, pero claro, te quieren cobrar por ello, ENCIMA! - Después de explicarme la ESTAFA, la teleoperadora del 1004 me ha preguntado si quería contratar ADSL de Telefónica o IMAGENIO, para FLIPAR !
- También teniendo en cuenta que NI DIOS me llama ya al teléfono fijo (que sólo lo tengo porque es como un impuesto revolucionario de Telefónica por el ADSL)

He decidido que la única solución es la siguente:

Voy a desconectar todos los terminales de teléfono fijo que hay en casa, y por si acaso lo conectaré una vez al día para ver si tengo algún mensaje en el contestador (que amablemente ofrece Telefónica) o por si quiero hacer alguna llamada.

He creado esta campaña en facebook para que todos hagamos lo mismo.

Campaña "Desconecta tu teléfono fijo"

Esta no es una campaña para perjudicar a nadie (sólo a las teleoperadoras, que no me pillarán nunca en casa y espero que me eliminen de sus bases de datos de posibles clientes spameables).

YA SE CANSARAN (que cansinooooooooos) !

20071206

Google Chart API, sorprenent

Google no para de sorprendre'm

Google continua sent una companyia diferent, avui he vist a ajaxian.com una referència al Google Chart API

Es al·lucinant com una API tant potent es pot descriure amb una sola pagina d'HTML de manera clara i meridiana.

Aquí podeu veure un parell d'exemples:


helloWoWWa



helloOMATECH

Trobo a faltar support per POST, com a mínim no esta documentat...


UPDATE:

Ai, mira quina gracia, he fet un petit experiment i sembla que NO rula, el formulari amb method="POST" no funciona, pero amb method GET si.

Test form:


Chart type:
Chart size:
Chart Data:

20071122

Hayden i The National al Apolo

Aquest dissabte passat (17 de novembre del 2007) vaig tenir la sort d'anar al concert de Hayden i The National al Apolo Club.

Hayden es un cantautor mític per nosaltres de Toronto, Canada.

El seu primer single, September, es una de les meves cançons favorites "of all times".

Des que September era un hitazo han passat més de 10 anys, pero encara s'em posa la gallina de piel al sentirla.

Com a curiositat, al concert no va tocar "September" pero de totes maneres va valer molt la pena, i em va recordar vells temps, despres vem sopar un pop excel·lent amb l'Otto al bar del costat del Bagdad i vem acabar la nit prenent uns "Gin Tonics de Hendrix" al Negroni amb ell i la Paula.

Aquí us deixo uns videos gravats al concert i unes quantes fotos.










Hayden a la guitarra i armónica, primer plà

Hayden als teclats

Hayden a la guitarra

Hayden a la guitarra i tocant l'armónica alhora, un crack :)

The National

Lead Guitar i teclista al fons (també era violi) de The National

The National

El cantant de The National (1)

El cantant de The National (2)


PD: He recuperat el "September" a la palm, aixi com un cover de Hayden interpretant "Gouge Away" de Pixies, si "Gouge Away" ja es genial, no ho es menys el cover de Hayden, totalment recomenable !!!

20071120

La Generalitat de Catalunya encarrega enquestes que són fetes en Castellà

Avui m'han fet una enquesta telefònica a l'empresa, ens preguntaven sobre la evolució de les TIC a la nostra empresa, importacions, exportacions, facturació etc.

Fins aquí tot bé.

El problema ve quan m'anuncien que es tracta d'una enquesta de la Generalitat, però la operadora em parla en Castellà i no només això, sinó que davant la meva amable petició a que canvii al Català, m'informa que L'ARGUMENTARI DE LA ENQUESTA ESTÀ EN CASTELLÀ.

Com que la noia no tenia cap culpa, fins i tot m'ha explicat en Català el problema tot i que no era catalano-parlant, jo he accedit a fer la enquesta (en Castellà), però conec molts casos de gent que s'ha negat a fer enquestes en aquestes condicions i no sense raó.

Crec que el problema aquí el té PERSEO, la empresa de enquestes i la Generalitat per no controlar les subcontrates que realitza, que:


  1. No tenen profesionals que siguin capaços de fer un argumentari en català.

  2. No tenen profesionals que siguin capaços de emetre aquest argumentari en català.



Té tela, perquè després diguin que el Castellà esta perseguit !

20071106

How to generate a set of unique random strings in PHP



I'm amazed in my daily work of how useful and easy to use is PHP.

Today I've to generate 1.728 random strings of 9 characters each.

Each string must contain only a subset of alphanumeric characters, no zero, no Ç, no Ñ, etc.

Of course there must no be repeated strings in the 1.728 results.

I've added the constraint, don't repeat the same character inside an string, to avoid, results like "AAAbbbCCC" for example.

Let's code:


function get_result()
{
$valid_chars=array("1", "2", "3", "4", "5", "6", "7", "8", "9"
, "a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
, "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");

$result=array_rand($valid_chars, 9);
$result_str='';
foreach ($result as $value)
{
$result_str.=$valid_chars[$value];
}
return $result_str;
}


this easy function does the following, first declare the array of allowed chars in the resulting string $valid_chars, using array_rand we obtain 9 keys to the array randomly generated, for example $result could be {7, 10, 14, 20, 22, 30, 35, 42, 49}

Then we loop through the keys with a foreach and simply obtain the character associated to the key and concatenate to the $result_str string.

Finally the body of the php:


$results=array();

for ($i=0; $i<=2000; $i++)
{
array_push($results, get_result());
}

$results=array_unique($results);

$cont=0;
$results_str='';
foreach ($results as $value)
{
$cont++;
$results_str.=$value.'
';

if ($cont>=1728)
{
break;
}
}
echo $results_str;


In this code we simply loop from 0 to 2000 calling the get_result() function and storing the result in an array.

Then we call the array_unique to avoid duplicated strings (for this reason we have generate a bit more than 1728 results) at this point $results have yet more than 1.728 valid and unique resulting strings.

Finally we loop through the array and break the loop when the limit of 1.728 strings are reached, adding to a resulting string each code, and then output the string.

Enjoy your new randomly generated codes !

20071029

ipsojobs return, devolviendo código a la comunidad

La gente de ipsojobs ha creado una categoría en su blog que se titula ipsojobs-return, que contiene artículos técnicos, tanto en inglés como en castellano sobre how-tos que se han usado en la página ipsojobs.com.

De momento, acaba de aparecer un segundo tutorial, explicando como crear un widget de tipo UWA (Universal Widget API) que se puede utilizar en NetVibes, en iGoogle y en nuestro propio blog.

El anterior artículo hablaba de como zippear y cachear los javascripts y los CSSs de una página para optimizar la descarga de un site.

ipsojobs.com es una bolsa de trabajo on-line especializada en trabajos urgentes y usa un modelo de administración distribuida remunerando a los administradores de cada ciudad utilizando google adsense.

Nuevo widget UWA para ipsojobs.com

Esta semana hemos estado preparando un widget UWA en ipsojobs, UWA significa "Universal Widget API" y es una especie de standard creado por netvibes para poder crear Widgets en cualquier plataforma (Netvibes, igoogle, opera, iPhone) una especie de "write once, run everywhere" que prometia Sun con Java en su momento pero aplicado al mundo de los Widgets.

Ya puestos a crear un widget, lo hemos creado con UWA, aunque es posible que si salen incompatibilidades debamos crear n-widgets para las n-plataformas sobre las que queramos desarrollar.

Ipsojobs UWA Widget in action

El widget pretende ser algo un poco más complejo que un simple lector de RSS, en concreto los objetivos del widget son:


  • Permitir seleccionar fácilmente la ciudad sobre la que queremos consultar las ofertas de trabajo de ipsojobs.

  • La selección de la ciudad debe ser "dinámica" dado que cada día aparecen ciudades nuevas no puede ser una lista estática.

  • Cuando estas viendo las ofertas de una ciudad siempre podrás cambiar a otra ciudad fácilmente.

  • El número de ofertas por ciudad debe ser personalizable.

  • Una vez seleccionada una ciudad el widget debe "recordar la preferencia" y mostrar las ofertas de la ciudad hasta que el usuario decida cambiarla.


Si quereis probarlo simplemente podéis visitar http://www.ipsojobs.com/widgets/uwa.html

El código del widget UWA es relativamente sencillo, se basa en un sólo fichero XHTML con todos los javascripts y los CSS incrustados.

Declaración:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:widget="http://www.netvibes.com/ns/" >
<head>


<meta name="author" content="Agusti Pons, omatech.com" />
<meta name="description" content="ipsojobs.com find jobs easy in your city" />


<meta name="apiVersion" content="1.0" />
<meta name="autoRefresh" content="20" />
<meta name="debugMode" content="true" />


<link rel="stylesheet" type="text/css" href="http://www.netvibes.com/themes/uwa/style.css" />
<script type="text/javascript" src="http://www.netvibes.com/js/UWA/load.js.php?env=Standalone">


De esta parte, sólo cabe destacar que se debe modificar el autor y la descripción así como el parámetro debugMode, que en producción deberá ser false. El debugMode=true es muy practico porque manda los mensajes de error a la consola del navegador y se puden consultar con el Firebug por ejemplo.

Javascripts útiles:


<script type="text/javascript">
<![CDATA[
function showhide(e)
{
//el = document.getElementById(e);
el = widget.body.getElementsByClassName(e)[0];
el.style.display = el.style.display == "block" ? "none" : "block";
}


function getlang()
{
return widget.lang.substr(0, 2);
}


function link(url)
{
if (widget && widget.openURL)
{
widget.openURL(url);
}
}


function getSelected(ctrl)
{
for(i=0;i
{
if(ctrl[i].checked)
{
return ctrl[i].value;
}
}
return '';
}


function setcity(url)
{
widget.setBody('<p>...</p>');
widget.setValue('url', url);
UWA.Data.getFeed(widget.getValue('url')+'?lang='+getlang(), ipsowidget.display);
}


function selectcity()
{
widget.setTitle('ipsojobs.com widget - setting...');
UWA.Data.getText('http://www.ipsojobs.com/api/controller.php?action=zones_sites_list&xsl=netvibes〈='+getlang(), ipsowidget.zones_sites_processor);
}


function replace(texto,s1,s2)
{
return texto.split(s1).join(s2);
}


function get_change_city()
{
var lang = getlang();
if (lang=='es')
{
return 'Cambiar ciudad';
}
if (lang=='ca')
{
return 'Canviar ciutat';
}
if (lang=='fr')
{
return 'Changer de ville';
}
else
{
return 'Select city';
}
}
]]>
</script>


Las dos funciones más interesantes son setcity() y selectcity() que detallo a continuación:


function setcity(url)
{
widget.setBody('<p>...</p>');
widget.setValue('url', url);
UWA.Data.getFeed(widget.getValue('url')+'?lang='+getlang(), ipsowidget.display);
}


Recibe como parámetro la url del RSS que nos han clicado en la pagina de selección de la ciudad, primero ponemos unos puntos suspensivos para indicar que estamos cargando (widget.setBody('<p>...</p>');) posteriormente actualizamos el valor de la preferencia url (recordad que es oculta y el usuario no la puede ver) con la instrucción widget.setValue('url', url); y finalmente cargamos el feed RSS en el body, fijaos que utilizamos la url de la preferencia que acabamos de actualizar pero le añadimos el parámetro lang basándonos en el language del navegador del usuario UWA.Data.getFeed(widget.getValue('url')+'?lang='+getlang(), ipsowidget.display);.

Para mostrar el RSS feed en el body fijaros que llamamos a la función display del widget que veremos más abajo declarada como ipsowidget.display = function(feed) esta función es muy parecida a la que se explica en el HOWTO de como mostrar un RSS en la web de Netvibes.


function selectcity()
{
widget.setTitle('ipsojobs.com widget - setting...');
UWA.Data.getText('http://www.ipsojobs.com/api/controller.php?action=zones_sites_list&xsl=netvibes〈='+getlang(), ipsowidget.zones_sites_processor);
}


La función selectcity, sólo tiene dos lineas, la primera modifica el título del widget widget.setTitle('ipsojobs.com widget - setting...'); indicando que no estamos en ningúna ciudad sino en la pantalla de setting. La segunda linea carga una url especial de ipsojobs que genera el html necesario para mostrar el seleccionable de las distintas zonas y ciudades UWA.Data.getText('http://www.ipsojobs.com/api/controller.php?action=zones_sites_list&xsl=netvibes〈='+getlang(), ipsowidget.zones_sites_processor); con el html resultante se llama a la función ipsowidget.zones_sites_processor que veremos más abajo y simplemente machaca el body con el nuevo html. Cabe destacar que el html contiene la lista de zonas y sus ciudades ocultas, al clicar sobre la zona se llama a la función showhide para mostrar las ciudades de esta zona. Con iGoogle he comprovado que el desplegado y el plegado no funcionan muy bien porque el widget no se redimensiona correctamente, en cambio si arrastras el titulo del widget como si lo fueses a reposicionar, entonces se recalcula la altura del mismo correctamente.

Preferencias y CSSs:


<title>ipsojobs.com widget
<link rel="icon" type="image/png" href="http://www.netvibes.com/favicon.ico" />


<widget:preferences>
<preference name="url" type="hidden" label="URL" defaultValue="" />
<preference name="limit" type="range" label="Number of items to display" defaultValue="10" step="1" min="1" max="25" />
</widget:preferences>


<style type="text/css">
/* your CSS rules */


body {
height: 400px;
}


a:hover {
cursor: pointer;
}


h2 {
color: #8CC402;
}


h3 {
color: #8CC402;
}


</style>

Aquí podemos ver que creamos una preferencia llamada url de tipo hidden, es la que nos servira para almacenar la url del recurso RSS de la ciudad seleccionada. También creamos el parametro limit que permitirá al usuario seleccionar el numero de ofertas a mostrar en el rango de 1 a 25.

El meollo de la cuestión:


<script type="text/javascript">
<![CDATA[
var ipsowidget = {}


ipsowidget.feed = false;

ipsowidget.display = function(feed)
{
// get the number of items to display
widget.preferences[1].max = feed.items.length;


var toolbar=widget.createElement('h2');
var website_url=replace(widget.getValue('url'), '/rss/controller.php', '');
toolbar.setHTML(''+feed.title+'');


var toolbar2=widget.createElement('h3');
toolbar2.setHTML(''+get_change_city()+'');


widget.setTitle('ipsojobs.com - '+feed.title);

// create the 'ul' element, applying it the CSS class 'nv-feedList'
var feedList = widget.createElement('ul');


// your 'ul' element MUST make use of the 'nv-feedList' class
// to ensure your widget uses the UWA UI library
feedList.className = 'nv-feedList';


// number of parsed items
var j = 0;


// loop through the downloaded items
for(var i=0; i < feed.items.length; i++)
{
// if the limit is reached, stop looping
if (j >= widget.getValue('limit')) break;


// for each item, create the 'li' element
var item = feed.items[i];
var li = widget.createElement('li');


// create and fill the 'a' element of the item with the item's link
var a = widget.createElement('a');
a.href = item.link;


// fill the 'a' element with the item's title
var displayTitle = item.title;
a.innerHTML = displayTitle;


// build the title from the 255 first characters of the content
// remove the content's HTML tags along the way
var title = item.content.stripTags().truncate(255);
a.title = title;


// set a tooltip on the 'a' element, with the item's content
a.onmouseover = function()
{
UWA.Utils.setTooltip(this, this.content, 250);
}


// finally append the 'a' element we just filled, into the 'li' element
li.appendChild(a);


// ...and append the 'li' element to the main 'ul' element
feedList.appendChild(li);
j++;
}


var general=widget.createElement('div');
general.appendChild(toolbar);
general.appendChild(toolbar2);
general.appendChild(feedList);
// once the needed items have been parsed,
// send the main 'ul' element to the HTML body tag
widget.setBody(general);
}


ipsowidget.zones_sites_processor = function(text)
{
widget.setBody(text);
}


widget.onLoad = function()
{
if (widget.getValue('url')=='')
{
selectcity();
}
else
{
//alert(getlang());
UWA.Data.getFeed(widget.getValue('url')+'?lang='+getlang(), ipsowidget.display);
}
}
]]>
</script>


La mayoría de este código es muy parecido al HOWTO de como hacer un RSS widget con UWA (solucionando algún pequeño bug) con las siguientes diferencias:


var toolbar=widget.createElement('h2');
var website_url=replace(widget.getValue('url'), '/rss/controller.php', '');
toolbar.setHTML(''+feed.title+'');


var toolbar2=widget.createElement('h3');
toolbar2.setHTML(''+get_change_city()+'');


widget.setTitle('ipsojobs.com - '+feed.title);


En este fragmento creamos el elemento DOM que nos muestra el nombre de la ciudad seleccionada (con un link a la misma) y el elemento que nos permite cambiar de ciudad. En la última linea también actualizamos la barra de título del widget con el nombre de la ciudad seleccionada.

Al final, hemos añadido los fragmentos DOM creados.

var general=widget.createElement('div');
general.appendChild(toolbar);
general.appendChild(toolbar2);
general.appendChild(feedList);
// once the needed items have been parsed,
// send the main 'ul' element to the HTML body tag
widget.setBody(general);


El onLoad también esta un poco tuneado, en el ejemplo siempre carga la url, pero en nuestro caso puede ser que el widget se haya instalado por primera vez y no tengamos ninguna url en concreto, por eso hacemos lo siguiente:


widget.onLoad = function()
{
if (widget.getValue('url')=='')
{
selectcity();
}
else
{
//alert(getlang());
UWA.Data.getFeed(widget.getValue('url')+'?lang='+getlang(), ipsowidget.display);
}
}


Simplemente detecta si ya tenemos una url fijada y sino llamamos a selectcity que ya se encarga de hacer la llamada AJAX correspondiente para mostrar el selector de ciudades. En caso contrario (este usuario ya tenia la preferencia url fijada para este widget) simplemente la cargamos llamando a UWA.Data.getFeed, fijaros que obtengo el lenguaje del navegador y intento llamar con el lenguaje más apropiado al RSS que me interesa.

Finalmente el body de la página


</head>
<body>
<p>Welcome to the ipsojobs.com widget </p>
<p>...</p>
</body>
</html>


Esta parte no tiene misterio, simplemente mostramos un body, que en seguida se machacará con la función widget.onLoad, que hemos visto más arriba.

20071011

Cache and GZIP your javascripts and CSSs files to speed up your site



I've been trying to mix different sources to optimize the download speed of the javascript files and the CSS files of any web application, in particular I've worked for the IPSOJobs new urgent job bank web page, but it can be applicable in a more general way.

Your Web application can use this files if:


  • You can use .htaccess in your hosting

  • You have CSS only and JS only folders to apply to the whole folder

  • You can use PHP in your hosting



If all the above conditions are met, you can simply add three files to your CSS and/or JS folder and you are done.

Please, take with caution and do some testing, don't use directly in a production environment.


Of course, I'll not give any waranty of succes and you have to check the results using the Firebug Extension of Firefox, the "Live HTTP Headers" extension and the YSlow plugin of the Firebug Extension.

First file .htaccess:
Modify your .htaccess file to include the following:


AddHandler application/x-httpd-php .css .js
php_value auto_prepend_file gzip-start.php
php_value auto_append_file gzip-end.php


This code, tells Apache to automatically run the gzip-start.php before the requested javascript or css file and to run the file gzip-end.php after the conclusion of the requested file.

It's a powerful way to create common headers and footers to pages or files, but be aware that it comes at a cost, it's more fast to serve the static file alone than to run an php script before and one after the file, of course, you have to do some testing and see if it's worthy to do so.

Second file, the magical gzip-start.php:



function get_http_mdate()
{
return gmdate('D, d M Y H:i:s', filemtime($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'])).' GMT';
}

function check_modified_header()
{// This function is based on code from http://ontosys.com/php/cache.html
$headers=apache_request_headers();
$if_modified_since=preg_replace('/;.*$/', '', $headers['If-Modified-Since']);
if(!$if_modified_since)
{
return;
}

$gmtime=get_http_mdate();

if ($if_modified_since == $gmtime)
{
header("HTTP/1.1 304 Not Modified");
exit;
}
}

check_modified_header();

// Open a gzipped buffer
ob_start ("ob_gzhandler");

if (strpos($_SERVER['PHP_SELF'], '.js')>0)
{// Javascript file
header("Content-type: text/javascript");
}
elseif (strpos($_SERVER['PHP_SELF'], '.css')>0)
{// CSS file
header("Content-type: text/css");
}

$offset = 60000000; // Far far away in time

// Expires
header("Expires: ".gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");

// Cache-Control
header("Cache-Control: must-revalidate, max-age=".(time()+$offset));

header("Last-Modified: ".get_http_mdate());

// generate unique ID, using the modification date and the absolute path to the file
$hash = md5(filemtime($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']).$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']);
header('Etag: "'.$hash.'"');

?>


The concept is clear, this file is interpreted by the PHP runtime rigth before the output of the requested file.

Let's see the different parts of the file:


check_modified_header();


This function looks for the modification date of the requested file (filemtime($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'])) and returns a HTTP 304 (Not Modified) if the file is fresh, to do that, first looks for a request header If-Modified-Since and then compare the dates.


// Open a gzipped buffer
ob_start ("ob_gzhandler");

if (strpos($_SERVER['PHP_SELF'], '.js')>0)
{// Javascript file
header("Content-type: text/javascript");
}
elseif (strpos($_SERVER['PHP_SELF'], '.css')>0)
{// CSS file
header("Content-type: text/css");
}


These lines opens a PHP buffer with the trick that it's using GZip compression, this is a very good feature of PHP that enables you to output gzipped content without any modification. Afterwards we put the Content-Type of the resulting file, depending of the extension of the file we put text/css or text/javascript.


$offset = 60000000; // Far far away in time

// Expires
header("Expires: ".gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");

// Cache-Control
header("Cache-Control: must-revalidate, max-age=".(time()+$offset));


These lines put the Expires and Cache-Control headers, both far away in time, we create the variable offset with a constant 60 million seconds (about 2 years) and use that to generate a Expires header and a Cache-Control header with the value of two years in the future.

Be warned, your CSS and your JS files will be cached in a lot of proxies and client browsers, you have to use a "rename file policy" in your HTML to prevent the users from using old versions of the files. We've got little javascripts and css files to change, but I recommend to split these kind of files in different folders, for instance /js/usually-modified/omatech.js and apply only the caching technique to the folder usually-modified, then rename each time the .js file with a timestamp, say omatech_20071010.js, and change your html code to reflect the new version.



header("Last-Modified: ".get_http_mdate());

$hash = md5(filemtime($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']).$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']);
header('Etag: "'.$hash.'"');


The last lines, creates a Last-Modified header, used to indicate the client browser the freshness of the file for future requests, this have interactions with the Cache-Control/max-age and the Expires headers (out of the reach of this post).

Finally we generate an unique Etag header, based on the update time of the requested file and it's full path.


Third and last file, the not less magical gzip-end.php:


header('Content-Length: ' . ob_get_length());
ob_end_flush();
?>


This file simply creates dinamically a Content-Length header with the size of the gzipped buffer we have been using for this request, and then flushes it's contents.

Simple eh ?


I hope you enjoyed and finded useful, feel free to change and play with the code.


I would like to thank the sources where I took inspiration and code:

The tutorial of CSS compression,
Facilitate User Experience with CSS Compression, from Max Kiesler

Good introduction to the problem of speeding up the webpages through caching and zipping javascripts
Serving Javascript Fast, by Cal Henderson

And always a good tutorial even for novices (in Spanish)
¿Por qué y cómo crear un espacio web "cache friendly"? from jcea

20071010

Fascicles de setembre del 2007

Una vegada passat setembre, sempre m'agrada posar la llista de fascicles que he vist anunciats a la tele, de fet les normes son, que els hagi vist a la tele i que m'hagi enrecordat d'apuntar-los :)

Potser aquest any que ja estic definitivament enganxat a la FOX i al AXN fins al punt que no veig gairebé mai les altres cadenes, no he pogut recopilar tots els que han sortit.


Fascicles d'aquest any:


  • Santísima Trinidad

  • Los cuentos de Calleja

  • Cantiflas

  • Formula 1 - SuperSlot

  • Leyendas de Le Mans

  • Stephen King

  • Las tortugas ninja

  • Scalextrix Seat Sport

  • Curso de Ingles de PlanetaAgostini

  • Mickey GEO

  • Ferrari

  • Urgencias en DVD

  • Pilates

  • Biblioteca de Cesar Vidal

  • Monta tu Dinosaurio

  • Lo mejor de la Zarzuela en DVD

  • Erase una vez El Cuerpo Humano

  • Tarta de Fresa

  • Transformers

  • Punto de cruz

  • Las 3 mellizas

  • Pokemon en DVD

  • Monta tu casa Andaluza

  • Guia Esencial de Belleza

  • Curso practico de Pilates

  • Tiranosaurio Rex

  • Los crimenes de Agatha Christie

  • Desafíos Matemáticos

  • La energía de las piedras




TOTAL: 29

Aquí podeu trobar:

20070908

Avui arranca IPSOJOBS, un nou concepte de borsa de treball on-line



Avui arranca IPSOJOBS un projecte intern d'Omatech que esdevindrà el líder en el mercat (poc explorat) de les feines urgents.

IPSOJOBS, te una orientació clarament global, inicialment traduït l'interface en català, castellà, anglés, xines i japones, permet introduïr o cercar ofertes de feina a Barcelona, Girona, Kyoto, Madrid, New York i Shanghai.



El creixement de la web l'estem basant en el que jo anomeno "Greedy Grow" que es basa en que la gent que vol guanyar diners gestionant una bossa de treball IPSOJOBS a la seva ciutat o area pot guanyar d'un 50% a un 100% de la publicitat generada pel seu "IPSOJOBS site", nomes cal que ens possem en contacte i ens doni les seves dades i el seu codi d'adsense de google, per més informació