- fire up firefox
- Type
about:configin the address bar - Confirm that you'll be careful
- In the filter bar, type
paper_size - Double-click the entry
print.postscript.paper_sizeand change it's value toA4for example - Hit Ok to save your modification
- Double-click the entry
print.print_paper_sizeand change it's value to1to set the value of entryprint.postscript.paper_sizeas the default
vendredi 6 août 2010
Setting the paper straight
jeudi 13 mai 2010
Ubuntu 10.4 ambiance theme: setting the buttons straight
I just recently installed Ubuntu 10.4 LTS and set appearance to use the ambiance theme.
The window border buttons were on the left though by default.
Now, I'm not a fluent Mac user, so I prefer having those on the right.
It proved to be really simple to do so: Hit <alt><f2>, type
gconf-editorand hit <enter>. Navigate to apps > metacity > general and edit the item
button_layoutSimply put the colon ":" on the left side of the string instead of the right side to set the buttons to be on the right side of the window border.
You can also modify the order of the buttons by modifying the order of the "maximize,minimize,close" string.
jeudi 29 avril 2010
Quick trick
<?php
if (count($array) != count($array, COUNT_RECURSIVE)) {
echo "this is a multidimensional array";
}
?>
There you go.
Note that there's a caveat: if the second dimension element is an empty array, this will yield FALSE:
<?php $array = array( 1, 2, 3, array(), 4 ); ?>will NOT say this is a multidimensional array.
lundi 6 avril 2009
PHP Vikinger in my town of birth !
This year, Derick Rethans is organizing the PHP Vikinger event for the third time. And it’s in Leuven above all places :)
If I can make it to Belgium (I live in France) on the 30th of May, I will definitely be attending at least part of the (un)conference.
You can find more information –and register for the event- on the PHP Vikinger website.
Hoping to see a few of you there :)
jeudi 5 mars 2009
Ghost cookie ?
- Strange behaviour
We last experienced a strange behaviour on one of our sites: marketing department wanted a tracking cookie to be written when customers came to the site through a sponsored link displayed upon a Google search.
So the sponsored link had a request part that indicated the marketing code to put in the tracking cookie.
But that marketing code was never put in the cookie. Why ?In fact, our mechanism to write the cookie verifies if it has already been set. If it is, we do not overwrite it's value. And indeed, even before the user arrived on our site, a cookie was set on our domain ! This only happened when the browser was Firefox. No issues with IE, Opera, Safari and others in any version.
- What happens ?
It took us a while to find out that Google uses link prefetching, which is only implemented in Mozilla browsers.
When Google detects you're using a Mozilla browser, it puts this HTML code in the results page:<link rel="prefetch" href="http://url.to.fetch/">
The link indicated in the prefetch is the one that Google expects most likely to be clicked according to the keyword(s) you entered in the search. This will never be a sponsored link though!
Mozilla browsers parse that and will actually preload the page in the background.
Now, we also have a tracking cookie for "spontaneous" visits from search engines. So it was this cookie that was set instead of the cookie from the sponsored link, even if people would click on the sponsored link: we don't overwrite it remember ?
- The solution
Luckily, the Mozilla browsers add a specific HTTP header when performing the preload of the page upon following a prefetch link:
X-Moz: prefetch
So all we had to do is ignoring this request when handling the tracking cookie:
if (!in_array('prefetch', $_SERVER)) { // Set tracking cookie }
Funny thing is that this has been around since 2005, and I only just now discovered it...
Other people long ago blogged about this, and indicate other solutions, like responding with a 404 HTTP or 503 Header, or using URL Rewrites.