@snisnik esta bueno.. Pero es bastante incomodo acostumbrarse

Flash block in Safari

Ok, It’s been a while since I’m noticing my mac’s battery is not lasting the time I want. Doing some checks using Activity Monitor, o found out that flash spends almost 20% of the microprocesor, and that’s just when I’m on newspapers sites with all those crappy ads. So, doing some google search, I found ClickToFlash a small plugin for safari that works as flashblock for firefox.

Things I liked the most:

  • Posibility to view youtube videos in quicktime instead of the standard flash player
  • Whitelists for sites that you want to execute flash without asking
  • It’s just a standard .pkg file
  • It’s Open Source!

Uploading images using CakePHP

First of all, I need to say that I’m not even close to being a good CakePHP developer. Not even a PHP developer. I Don’t even like it very much, but well, somethings we have to do things we don’t like. Having that said, this is a little snippet I use on my CakePHP controllers to upload images, save them, and add the URL into the database table. In the view, I use a file input.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function __upload($file_array){
    $file = new File($file_array['tmp_name']);
    $file_base = pathinfo($file_array['name']);;
    $ext = strtolower($file_base['extension']);
    if ($ext != 'jpg' && $ext != 'jpeg' && $ext != 'gif' && $ext != 'png') {
        $this->Session->setFlash('You may only upload image files.');
        $this->render();
    } else {
        $data = $file->read();
        $file->close();
        $full_path = '/upload_images/'.$file_array['name'];
        $file = new File(WWW_ROOT.$full_path, true);
        $file->write($data);
        $file->close();
         return $full_path;
    }
    return 'Ouch!';
}

If you copy and paste this example, the images are uploaded to wwwroot/upload_images/

This snippet it’s not just for uploading images, it can be used with any file type

Continue Reading »