28 Dec 2010

Arduino T-Shirt

Nerdy, geeky. I made an Arduino t-shirt design. You can buy it as a tee a hoodie a vest or a sticker on RedBubble. I don't know why, but white ones are cheaper.

pinMode 13 (dark shirt version) by Leo Ponton
  pinMode 13 (d…
  Button_view_buy

pinMode 13 (alternative version) by Leo Ponton
  pinMode 13 (a…
  Button_view_buy

pinMode 13 by Leo Ponton
  pinMode 13
  Button_view_buy

26 Dec 2010

Arduino!

I bought my self an Arduino for Christmas. Why? Wtf is an Arduino?

Very simply put, an Arduino is a small, programmable computer on a tiny circuit board with built in interfaces. Yeah. What do you do with it? Well, probably almost anything you can think of. Common uses are in robotics and control. Some applications I have in mind are:
  • temperature and humidity control for my egg incubator
  • enlarger timer and controller for film photography
  • flight management system for a tri-rotor helicopter
Okay, it's really nerdy. But it's also electronics for programmers. The Arduino is programmed using C. That might seem scary, but if you've ever programmed javascript, java or PHP, you'll feel pretty comfortable.

Arduino themselves describe it as "...an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments."



You have the ability to easily interface sensors (data input) and analog or digital outputs, e.g. motors and LCD displays. Expanding this, I can use temperature and humidity sensors to turn the incubator heater on and off. Light sensors to measure a film exposure and display the result on an LCD display or gyro, and GPS to autonomously control a model helicopter.

The variety of sensors available is huge and there are ready made software libraries to do almost anything you can think of.

So it must be expensive. Not at all. My starter kit cost about £33 and included a genuine Arduino Uno (more about genuine in a moment), 60 LEDs and a pile of other components. I bought it from Earthshine Electronics but there are dozens of other companies with their own deals.

Arduino is an open-source project and that extends to the hardware as well, so you can get Seeduino, Freeduino (not free!) etc. clone boards. In general, they're all 100% compatible. You can even build your own. The boards on their own mostly cost from £10 - £30.

3 Dec 2010

Helping clients understand web designers

I have a friend who is about to become a client. He asked me to recommend a book that will teach him enough about web design, without actually ramming the how-to down his throat, to be able to know what can be done and how to communicate his needs and ideas.

Now normally it would be the job of the designer to tease this information from the client without him having to be exposed to the jargon. This chap, though, genuinely wants to know and to understand and I don't have a problem with that. I think it'll make him a better client.

Actually finding a book to recommend is not easy. So far all I have come up with is Web Design All-in-one For Dummies which I think will probably cover stuff he needs to know, but again it's probably too technical.
















Any other suggestions?

1 Dec 2010

fruit


fruit, originally uploaded by leo_p.
Testing the link between Flickr and Blogger.
If you want to link your Flickr and Blogger accounts watch this video: http://www.flickr.com/photos/ivanwalsh/3504011106/
You can choose whether you share a photo - it doesn't automatically share everything.

<pre> and <code> in blogger blogs

It seems that the best way to post code in a blogger blog is by encoding the chevrons '<>' and ampersands '&' using something like http://centricle.com/tools/html-entities/

Some styles are needed in the template and you have to wrap the code up in <pre>...</pre> or <code>...</code>

The Coldfusion Blog Tutorial

There may well be one out there, but I didn't look too hard.

Today, snowbound at home, I am adapting the CakePHP blog tutorial to Coldfusion. The only difficulties will be that cakePHP & MVC makes a lot of things very easy, but doing it in CF is going to be very 'hands on'. At least I'll get a lot of low-down experience with CF.

If it proves to be interesting or useful and if I have the time or the inclination, I may well publish it for the benefit of other CF newcomers.

30 Nov 2010

Mac OSX VPN to Windows 7

Forced home by snow and impending more snow I had to set up VPN access from my Hac to my Windows 7 workstation. Fortunately the VPN server end is already set up.

Doing the Mac setup was pretty trivial. Go to network settings in system preferences. Add a new connection using the + sign at the bottom left. Then just follow through the settings. It's really not that difficult. If you're a bit dim, there's a picture guide here: http://bit.ly/do_vpn_on_mac

Of course, you also need some sort of remote desktop app. The first one I found was CoRD (http://cord.sourceforge.net/) which seemed a bit tricky to set up, and says it doesn't use Mac VPN, but it doesn't work without a VPN connection. Anyway, it's pretty slick and FREE. The second one was Microsoft Remote Desktop Connection for Mac 2, which is included with every edition of Office for Mac 2011 (if you're fool enough to buy it or use it). Well, it's also a FREE download (http://www.microsoft.com/mac/remote-desktop-client) and, surprisingly, it works.

They both work well but, politics aside, I don't know which one I'll use. I've only had half a day to try them out.

Coldfusion

It's been a while since I wrote anything, but that doesn't mean I haven't done anything. I've been head down wrapping up a CakePHP CMS before I changed jobs. Now I'm a Coldfusion developer. WTF? I've never used it but working through the tutorials it seems really straightforward. I guess the hard part will be letting go of MVC. Of course, someone has cooked up an MVC framework for CF, but there's too much legacy in my new job to even think about it.

I'll still be doing the CakePHP stuff as well as I have one or two personal projects and, for a smalltimer, hosting Coldfusion is just too expensive.

30 Jul 2010

Basic .htaccess Modifications

This is a useful .htaccess for a basic CakePhp website. It enables
compression, normalises URLs by removing 'www' and then moves on to the
standard CakePhp redirection:
# compress all text & html:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css 
text/javascript
<IfModule mod_rewrite.c>
RewriteEngine on
# Convert all http://www.example.com style URLs to http://example.com
RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>
In certain situations - in this case our CMS - this substitution might 
be useful:
#RewriteRule    ^$ app/webroot/    [L]
RewriteRule    ^$ my-anchor-page    [L]

29 Jul 2010

INSERT rows with SELECT & mixed data

To extract values from one table, to update another where you also need
to supplement the data - in this case
(`module_type_id`,`module_id`,`zone_id`,`position`) are static
(12,42,12,1) - include the supplementary values in the SELECT statement:

INSERT page_items 
(`node_descriptor_id`,`module_type_id`,`module_id`,`zone_id`,`position`)
SELECT id ,12,42,12,1 FROM node_descriptors

20 Jul 2010

CakePHP offline manual

There used to be an offline manual - I don't remember whether it was official -  but there no longer seem to be any direct links. A little digging around revealed some answers which I thought it would be useful to share.

These are links to the manual in one page - useful for creating a PDF using Dardo Sordi Bogado's build script: http://rapidshare.com/files/218826372/manual-builder.zip. It is also very useful for searching quickly using ctrl-f in your browser.

Also see this thread: http://groups.google.com/group/cake-php/browse_thread/thread/5f45c1d0

17 Jun 2010

template woes

Yeah, okay, the template is a bit raw, but not as bad as the old one. When I get some time I'll neaten things up a bit.

6 May 2010

Getting CakePHP up and running on Ubuntu

To enable mod rewrite, you need to add a symbolic link to the module definition file, which lives in /etc/apache2/mods-available, to the folder: /etc/apache2/mods-enabled. Do this by first changing to the mods-enabled folder then adding the symlink.
cd /etc/apache2/mods-enabled 
ln -s ../mods-available/rewrite.load
In the sites-enabled folder /etc/apache2/sites-enabled, edit 000-default (this is actually a symbolic link to etc/apache2/sites-available/default, which will need to be made editable before making changes). You will need to add the statement:
AllowOverride All
to the directory blocks for '/' and '/var/www'. If these blocks do not contain the statement:
Allow from all
then add it at the end. Make sure that any occurrence of AllowOverride None within these blocks is changed, commented or deleted.

3 May 2010

Dual booting Hac & Ubuntu 10.04 LTS

After a night and a day of swearing, it turns out that the key to getting this dual boot working is to install Grub2 in a location other than the default option. I selected the Linux install partition. Now all I have to do is figure out why Xiezhy (the Hac bootloader) thinks Ubuntu is Windows.

And this new Ubuntu is fucking quick!

20 Apr 2010

ACL at page level

I've been messing around with CakePHP's built in ACL functionality. I tried it a while back (2007), but just couldn't make sense of it. Now, following Mark Story's tutorial in the Cake Book (and also his blog: http://mark-story.com/posts/view/auth-and-acl-an-end-to-end-tutorial-pt-1 ) , I have it working. He makes it very easy.

Now I'm tinkering with it to make it work on a page level. Success at this will mean I can use the CMS to create admin pages as well as public pages. When I've sussed it, I'll publish.

13 Apr 2010

Converting dates between MySql and PHP

$mysqldate = date( 'Y-m-d H:i:s', $phpdate );
$phpdate = strtotime( $mysqldate );

htaccess tips

http://corz.org/serv/tricks/htaccess2.php

CakePHP, .htaccess and clean homepage urls

Sometimes we need a clean url for the homepage to appear in the browser address bar, e.g. www.example.com

This problem came up with the CMS system I have built as all the pages have a url/name. For example, the default homepage would show as www.example.com/homepage.


Typing www.example.com would redirect to this and change the displayed url. The desired behaviour is to redirect
www.example.com -> www.example.com/homepage but only display www.example.com.

On the other hand, if you were to type www.example.com/homepage the display should stay as www.example.com/homepage .

The answer means a slight change to the default CakePHP .htaccess file

RewriteRule ^$ app/webroot/ [L]

becomes
RewriteRule ^$ homepage [L]

Of course, homepage could be any page name that you want to be the anchor page.

27 Mar 2010

A living, breathing Hac

The Hackintosh lives and breathes. For the technically minded, which you probably are if you're reading this, here is the spec so far:

Gigabyte G31M-ES2L v2.0 motherboard (although as this is a Hac, we should call it a logic board)
Intel E6300 2.8 Dual Core (not the older 6300 1.8 c2d) overclocked to 3.15GHz
Onboard network (doesn't work)
Onboard graphics (limited functionality)
2GB DDR2 800MHz RAM
+ other bits and pieces that were lying around.

I've finally got it reasonably stable using iAtkos 7, but as mentioned, no network. Apparently the earlier v1.x board has a different LAN chip that does work.

The display res has only one choice - 1024x768. Not much good, but I'll be putting in a double head card when I have the money as this will be replacing a double-headed G4.

I got the sound working using the Apple HDA kext (and Azalia enabled in the BIOS)
Other options that I can remember are:

Cheesy bootloader (I can't remember what it's called, but it begins with an X and looks like a russian version of cheesy - not Chameleon, anyway). It looks really good at startup, whereas Chameleon looks like some early Suse Linux experiment. It boots quickly, too.
Mostly a random selection of other stuff.

Sleep and restart don't work yet. About this Mac was reporting the CPU correctly, but now it thinks it's 4 GHz, even though I unclocked it back to 2.8.

When I get it fine-tuned a bit more, I'll report in detail which install options I selected.

22 Mar 2010

CakePHP redirect destinations can sometimes be a little unexpected

In CakePHP controllers CRUD methods there is a lot of this as a way of reaching a default page:
$this->redirect(array('action'=>'index'));


It's okay for a small application, but when things start to get larger, like in a CMS, you'll find that the return path can be a little unexpected. To make everything more predictable, I now write this in the action method to which I want to return:
$this->Session->write('LastAdminPage', DS.$this->params['url']['url']);


And this wherever I need to make the return, like in a CRUD method on the controller or on a cancel button in the view:
$this->redirect($this->Session->read('LastAdminPage'));

21 Mar 2010

My new Hac

The time has come to try building a 'Mac' from scratch. We're talking Hackintosh here. With Apple's move to Intel-based computers, several wily people have devised ways of installing the latest Mac operating systems - Leopard and Snow Leopard - on run-of-the-mill PC hardware.

Well, I say run-of-the-mill, but it does need to be reasonably up-to-date. I have acquired a Gigabyte GA-G31M-ES2L motherboard already (for £29) and I'm awaiting delivery of the E6300 dual core processor and 2GB of memory. This will give me a slightly below current spec Mac at a cost of around £120. Okay, I'll be using some stuff I have around already like a case, a hard disk and so on, but with an iMac currently running at around £900 I think it's a pretty good alternative.

I've no idea how stable it'll prove to be, but I'm looking forward to being able to run Ubuntu and (sadly) Windows inside OS X. It will make life a lot easier and my desk a lot less cluttered. It might even perk up the family once the replaced G4 MDD moves down the line (a superb, if noisy, machine).

I'll post more as I build

19 Mar 2010

Yeah, yeah...

...why didn't I build my own blog? After all, CakePHP even comes with a build-a-blog-tutorial. I just don't seem to be able to find the time.

I've just spent the last few months building a Joomla-killer of a CMS. Okay, it's tailor made for our company, but it's very open and flexible. Modules are easy to code and incorporate, page building and navigation is drag and drop and the whole thing hangs together with a modified preorder tree traversal algorithm (MPTT) - Google it. Best of all, it's built with CakePHP. It's easy for designers to learn and easy for programmers to code. Hopefully we'll open source it when we can think of a name for it. That way, more modules will be written and shared. Life needn't be so drupal.

Anyway, back to the yeah yeah, I will, one day, build my own blog. Just not yet.

Fixing Internet Explorer Javascript Errors: line 1 char 1 code 0

I've found that this is usually something header-ish and to do with the actual loading of the js rather than a bug within the script. Today, I've just spent an hour tracking down the problem. Firefox said "problem? what problem?"

The solution: the js (jQuery in this case) was being loaded twice. That kind of thing happens when all the pages on a website are composite and constructed on the fly.

23 Feb 2010

Making CakePHP websites load quicker

All frameworks are guilty of slowing things down owing to the code overheads and additional processing required to perform even simple tasks. Unfortunately, CakePHP seems to attract more criticism than others in this respect. We're talking milliseconds per page, but it all adds up.

Once a CakePHP website is deployed, there are a number of very basic things to do that should cut that time by more than half. Maybe with extra tweaking, you can get that time down even more.

Anyway, let's start with the key things.

Turn off debugging. Easily overlooked, but in my experience when you disable it, you'll have made the biggest improvement - time now about 50% of original load time.

Add gzip compression to .htaccess:
# compress all text & html:
AddOutputFilterByType DEFLATE text/html text/plain text/xml


For CakePHP's ./.htaccess (the one at the very root) this will look like:
# compress all text, html, css and javascript:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css

RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]

this should be good for another 20% - time now about 30% of original load time.