March 08th, 2010
Flash, Google Chrome and Debian Linux
Topics: Linux, HowtoHere’s how to get flash working on Chrome under Debian:
su - cd /opt/google/chrome wget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer10_1_p3_linux_022310.tar.gz tar xvzf flashplayer10_1_p3_linux_022310.tar.gz mkdir plugins mv libflashplayer.so plugins/ rm flashplayer10_1_p3_linux_022310.tar.gz
Then just restart Chrome :)
March 04th, 2010
Round image corners with php
Topics: Howto, Php, CodeI needed to round the corners of a banner image dynamically in PHP and I couldn’t find any explanations. Anyway it turns out the easiest way is to make an image of a rounded corner, like this rounded-corner.png and then stamp it on all 4 corners. You have to rotate it each time of course.Anyway here’s a snipplet of code to give you an idea:
<?php
$banner = '/path/to/banner-image.png';
$corner = '/path/to/rounded-corner.png';
// Load up the images
$banner = open_image($banner);
$corner = open_image($corner);
// Round the corner
imagecopy($banner, $corner, 0, 0, 0, 0, imagesx($corner), imagesy($corner));
$corner = imagerotate($corner, 90, 0);
imagecopy($banner, $corner, 0, imagesy($banner) - imagesy($corner), 0, 0, imagesx($corner), imagesy($corner));
$corner = imagerotate($corner, 90, 0);
imagecopy($banner, $corner, imagesx($banner) - imagesy($corner), imagesy($banner) - imagesy($corner), 0, 0, imagesx($corner), imagesy($corner));
$corner = imagerotate($corner, 90, 0);
imagecopy($banner, $corner, imagesx($banner) - imagesy($corner), 0, 0, 0, imagesx($corner), imagesy($corner));
// Output the image
header("Content-type: image/gif");
imagegif($banner);
// Tidy up
imagedestroy($banner);
imagedestroy($corner);
?>
November 13th, 2009
Changing Magento path
Topics: Howto, LinuxIf the Magento path changes everything breaks, here’s how to fix it:
Run this query in your Magento database:
update core_config_data set value='http://new-url.com/' where value='http://old-url.com/example/';
and delete your cache
rm -r magento/var/cache/*
August 03th, 2009
Things I realised from reading Gödel, Escher, Bach: an Eternal Golden Braid
Topics: ThoughtsI’m still reading Eternal Golden Braid, I have been on and off for maybe a year now and every few chapters gives me enough to ponder for a few months. I’m sure it’s part of the reason I’m so absent minded and mumbling to myself sometimes. Anyway here are a couple of thoughts I had.
The first was about chess. I always used to like chess, I thought it was a fun game but that was until I started to program. After coding for a while and learning how the various chess computers worked by bruteforcing the game I could only think of chess in those terms, as an amazing number of possible combinations that I was too small minded to hold in my brain. When you think of chess like that it seems pointless, I was saying to myself “There’s a move here which is perfect but I can’t see that far ahead, I’m just guessing”.
Anyway I’m happy to say I no longer think like that, if you read the book he explains how everything is made up of low level parts but there can still be meaning on a higher level. The example he gave was an ant colony, although made up of mindless ants functioned as a pretty advanced entity. You could say “Bah! It’s just a bunch of ants” but that would be ignoring what the colony achieves as a whole. Now I think although chess is ultimately made up of all these combinations of moves you can still think of it in higher terms like attacking that area of the board or protecting your queen. Suddenly it’s fun again!
The second thought I had involved the clash between logical people and for lack of a better term hippies. (Now depending on who you ask I fit into both groups so maybe I have a good insight.) Anyway I noticed how ‘hippies’ always came out with all this crazy crap about meditation and relaxing or not worrying and most logical people would just write it off immediately. The problem was that although a lot of the things they said where illogical, it seemed to work, they where relaxed with good posture and a positive happy frame of mind.
Now obviously excessive computer use plays a part in bad posture and illicit drugs might play a role in a happy frame of mind but there is still something there. I gave this a lot of thought and whilst reading the book I came to a realisation. When reading the example Kōans like “If you call this a short staff, you oppose its reality. If you do not call it a short staff, you ignore the fact. Now what do you wish to call this?” your immediate reaction is to reject it. The problem is if it leads to enlightenment maybe it’s worth dwelling on. I suspect the reason is you need something illogical to stop the recursion in your brain, you’re constantly thinking about thinking about what you just thought about and it’s impossible to get any peace. Although the Kōan is ovbiously junk if taken literaly I think it helps you focus your mind away it can help you relax and could be a worthwhile thing. So I guess my point is maybe there is real value behind this stuff even though it ’sound stupid’ maybe it’s not wise to judge so quickly. Maybe the logic is that there is no logic, maybe you can be a hippie with an analytical mind.
I can’t recommend the book enough, it has helped me understand a lot of things like this that have bugged me for a long time. I’m going to work through it several times until I understand every last bit.
August 02th, 2009
Mac emacs control option keybindings
Topics: Howto, Mac, Emacs; Setup the Mac keys (setq mac-option-key-is-meta nil) (setq mac-command-key-is-meta t) (setq mac-option-modifier nil) (setq mac-command-modifier 'meta) (global-set-key (kbd "<kp-delete>") 'delete-char)