Maxime Bernard's blog

Learn CSS positioning

Hi everyone !

If you’re looking for some CSS positioning explanations or you want some examples to explain to someone how it works, you may find this website very useful.

I suggest you to bookmark it :)

Have a good week-end.


Webdesign: clean design ?

Hi everyone !

Ever wanted to know more about clean design ? Here is your link ! You’ll have good tips to make a good and clean design.


How to force Facebook to re-scrape your URL ?

Hi everyone !

I had so many times some troubles with Facebook cache when generating thumbnail from my URL. Today, I found THE solution. It is very simple: you just have to use Facebook Debugger to clear Facebook cache.

For more information, just follow the link. 

Have a good night !


Nginx: Load-Balancing & Keep-Alive

If you are looking for a tutorial on load-balancing & keep-alive configuration with Nginx, click here !


Symfony, APC and Memcache

Have you ever heard about APC and Memcache ? If you are a symfony lover, you probably want to read this !


Trello

Hi everyone, I found this very interesting concept. That may suggest you some ideas for your future projects. Trello is a collaboration tool that organizes your projects into boards. In one glance, Trello tells you what’s being worked on, who’s working on what, and where something is in a process. 

Trello logo


Symfony: optimize your memory

Hi everyone !

Recently, I had to import thousands of products in a website using symfony task. Unfortunately, the task was consuming too much memory (RAM) and I couldn’t get more than ~400 products.

So I looked for ways to reduce memory consuming. First good thing: I was using PHP 5.3 and its garbage collector improvement (with loops mainly).

But that was not enough. So I looked on what was consuming so much in memory and I found this wonderful Doctrine object with instance in every iteration wich was adding (“memory_get_usage()”) approximatively ~7m.

I managed to use 2 solutions:

  1. Free your objects when you don’t need it anymore

    $var->free(); // Calls the destructor of your object

    unset($var); // Removes any reference for the garbage collector

  2. Call the garbage collector manually on every iteration

    gc_disable(); // Disable Garbage Collector
    gc_enable(); // Enable Garbage Collector

    // This will actually call manually the garbage collector to free the memory

    This is solution will avoid a lot of memory leaking BUT (every simple solution has its shortage) will slow your task because it’s very time consuming to call the garbage collector on every iteration.

Hope you learned something !


Composer: a future PHP time-saver ?

Hi everyone,

I just read this article. It’s a very interesting way of thinking and this could be a very good thing for PHP future.

Future will tell us how good this is but I think if Fabien Potencier decided to use it, it seems to be promising !

Have a good week ;)


9 ways to instantly code faster

Very interesting ways to improve how you design your application ! A must-read :)


Doctrine: synchronizeWithArray vs Merge

Hi !

I just discovered this article here: http://www.fullfatcode.com/2009/12/12/doctrine-php-merge-function/

You can read it below.

If you’ve tried Doctrine PHP, you might get pretty frustrated when using the $Record::synchronizeWithArray() function. Why?

$data = array('name' => 'jimbob');
 
$User->Doctrine::getTable('User')->find(1);
 
$User->synchronizeWithArray($data);
 
$User->save();

If you try this code you will find that the synchronizeWithArray() function deletes everything except the ‘name’ field in the record. I think the name ‘synchronize’ is slightly confusing here, as what it really means is “delete everything except what I’m explicitly telling you right now”.

A bit of digging in the API reference turned up a nice function called merge().

$data = array('name' => 'jimbob');
 
$User->Doctrine::getTable('User')->find(1);
 
$User->merge($data);
 
$User->save();

You will find that all the fields except ‘name’ are untouched. Lovely job.


Use ssh_config To Simplify Your Life

Hi everyone !

I just discovered this article that may help you save a lot of time everyday ! So simple and so useful ! 

But ssh(hhh), it’s a secret ! (ok, that one was very bad, sorry :-))


PHP flaws

Hi !

I just discovered this old (2008) article about PHP flaws. Some of them are deprecated (Namespaces, documentation, …) but some of them are still true. I had some fun with :

  • […] forces you to use a function with a name like mysql_real_escape_string()? And that actually has a similarly-named function without the “_real_” that doesn’t do the job right? Just kidding with that other one, here’s the real one!
  • The combination list/hash “array” type causes problems by oversimplifying, often resulting in unexpected/unintuitive behavior.
  • No consistent naming convention is used. Some functions are verb_noun() and others are noun_verb(). Some are underscore_separated, while others are CamelCase or runtogether. Some are prefixed_byModuleName, and others use a module_suffix_scheme. Some use “to” and others use “2”.
  • In general, has a tendency to create more problems than it solves.

I don’t agree with every argument but I have to admit some of them are true (especially, naming convention and unintuitive behaviors). I wouldn’t say PHP is a bad language and should be prohibited because PHP has also many cool behaviors such as writing some (so much simpler) logical (loops, conditions, function calls) where other languages have their own template language or use markers in HTML templates making you write logical display code in your controller.

Take your time to learn PHP flaws and you will be grateful to these simple features, PHP allows you to do.


Web Resources Depot

Hi everyone,

I was looking for some jQuery plugin and I discovered this great blog with articles about new free web resources that may save you a lot of time.

For example, I found this stats cypher:

Cyfe

or even this Open Source HTML5 charts maker:

FlotR2

Enjoy !



Hi everyone,

Today, I was looking for javascript benchmarks and I found this website. As we speak, jQuery is available in 1.7.1 but it is still interesting to take a look.


Unselect radios buttons with jQuery

You may found this weird but I had to implement some radio buttons that you want to be able to unselect. So I looked for some interesting tips on Google and found this perfect article.

You’ll get your problem solved very quickly !


13
To Tumblr, Love PixelUnion