PHPNW 2008 - 22nd November
Wednesday, August 6. 2008
The event is aimed at people working with, or wanting to work with, PHP in the north of England. We'll have a selection of sessions, with the technical content intended to be accessible to a whole range of audiences - it will also be multi-track so there's sure to be plenty of material to interest you, whatever your background. We will be having a call for papers for the sessions, and we're hoping that we'll get some good submissions - particularly from senior developers around the area and the wider UK. Whether you're hoping to speak, hoping to learn, looking for a good crowd to mingle with on a Saturday, or you just really like PHP geeks - put 22nd November in your diary and I hope I'll see you there!!
If you have any questions, comments or suggestions about this event, just let me know (I'm not organising the whole thing but I'm helping!), either by leaving a comment or by contacting me directly.
Bubble Wrap Camera Case
Saturday, August 2. 2008
I've made a new case for the camera, using bubble wrap as padding. The inside is microfibre cloth (note to self: don't ever use this again, its too fluffy for words and frays much too easily!) and the outside is crochet with a button fastener.
I started by making the inner microfibre liner with bubble wrap around it:

I then made the crochet outer, using some gorgeous dark turquoise wool I bought in Germany last year and which has been waiting for a project just like this one! Its quite fluffy but that doesn't matter as the bag is lined. I added a button to close it, a carabiner to hang it from, and a place to hook the tripod onto if we are taking that too. Here's the finished product - it looks a bit strange because its empty, since I was using the camera to take the photo!

(there are a few more photos on flickr )
I started by making the inner microfibre liner with bubble wrap around it:

I then made the crochet outer, using some gorgeous dark turquoise wool I bought in Germany last year and which has been waiting for a project just like this one! Its quite fluffy but that doesn't matter as the bag is lined. I added a button to close it, a carabiner to hang it from, and a place to hook the tripod onto if we are taking that too. Here's the finished product - it looks a bit strange because its empty, since I was using the camera to take the photo!

(there are a few more photos on flickr )
Accessing Incoming PUT Data from PHP
Wednesday, July 30. 2008
Recently I started writing a REST service. I began in the usual way, writing a php script, calling it with a GET request, accessing the variables using the PHP superglobal variable $_GET. I wrote code to handle a POST request and used the variables I found in $_POST. Then I tried to write a PUT request.
PHP doesn't have a built-in way to do this, and at first I was a little confused as to how I could reach this information. It turns out that this can be read from the incoming stream to PHP, php://input.
The above line provided me with a query string similar to what you might see on the URL with a GET request. key/value pairs separated by question marks. I was rescued from attempting to parse this monster with a regex by someone pointing out to me that parse_str() is intended for this purpose (seriously, I write a lot of PHP, I don't know how I miss these things but its always fun when I do "discover" them) - it takes a query string and parses out the variables. Look out for a major health warning on str_parse() - by default it will create all the variables all over your local scope!! Pass in the second parameter though and it will put them in there as an associatvive array instead - I'd strongly recommend this approach and I've used it here with my $post_vars variable.
This loads the variable $post_vars with the associative array of variables just like you'd expect to see from a GET request.
Its a bit of a contrived example but it shows use of the REQUEST_METHOD setting from the $_SERVER variable to figure out when we need to grab the post vars. Firstly, here's the script:
if($_SERVER['REQUEST_METHOD'] == 'GET') {
echo "this is a get request\n";
echo $_GET['fruit']." is the fruit\n";
echo "I want ".$_GET['quantity']." of them\n\n";
} elseif($_SERVER['REQUEST_METHOD'] == 'PUT') {
echo "this is a put request\n";
parse_str(file_get_contents("php://input"),$post_vars);
echo $post_vars['fruit']." is the fruit\n";
echo "I want ".$post_vars['quantity']." of them\n\n";
}
And here's what happened when I request the same script using two different HTTP verbs. I'm using cURL to show the example simply because I think it shows it best.
Via GET:
curl "http://localhost/rest_fruit.php?quantity=2&fruit=plum"
this is a get request
plum is the fruit
I want 2 of them
Via PUT:
curl -X PUT http://localhost/rest_fruit.php -d fruit=orange -d quantity=4
this is a put request
orange is the fruit
I want 4 of them
Purists will tell me that I shouldn't be returning data from a PUT request, and they'd be right! But this does show how to access the incoming variables and detect which verb was being used. If you're going to write a REST service then the correct naming of resources and the correct response to each resource being accessed in various ways is really important, but its a story I'll save for another day. If you use this, or perhaps you access the variables another way, then do post a comment - there aren't a lot of resources available on this topic for PHP.
PHP doesn't have a built-in way to do this, and at first I was a little confused as to how I could reach this information. It turns out that this can be read from the incoming stream to PHP, php://input.
The above line provided me with a query string similar to what you might see on the URL with a GET request. key/value pairs separated by question marks. I was rescued from attempting to parse this monster with a regex by someone pointing out to me that parse_str() is intended for this purpose (seriously, I write a lot of PHP, I don't know how I miss these things but its always fun when I do "discover" them) - it takes a query string and parses out the variables. Look out for a major health warning on str_parse() - by default it will create all the variables all over your local scope!! Pass in the second parameter though and it will put them in there as an associatvive array instead - I'd strongly recommend this approach and I've used it here with my $post_vars variable.
This loads the variable $post_vars with the associative array of variables just like you'd expect to see from a GET request.
Simple Example
Its a bit of a contrived example but it shows use of the REQUEST_METHOD setting from the $_SERVER variable to figure out when we need to grab the post vars. Firstly, here's the script:
if($_SERVER['REQUEST_METHOD'] == 'GET') {
echo "this is a get request\n";
echo $_GET['fruit']." is the fruit\n";
echo "I want ".$_GET['quantity']." of them\n\n";
} elseif($_SERVER['REQUEST_METHOD'] == 'PUT') {
echo "this is a put request\n";
parse_str(file_get_contents("php://input"),$post_vars);
echo $post_vars['fruit']." is the fruit\n";
echo "I want ".$post_vars['quantity']." of them\n\n";
}
And here's what happened when I request the same script using two different HTTP verbs. I'm using cURL to show the example simply because I think it shows it best.
Via GET:
curl "http://localhost/rest_fruit.php?quantity=2&fruit=plum"
this is a get request
plum is the fruit
I want 2 of them
Via PUT:
curl -X PUT http://localhost/rest_fruit.php -d fruit=orange -d quantity=4
this is a put request
orange is the fruit
I want 4 of them
Purists will tell me that I shouldn't be returning data from a PUT request, and they'd be right! But this does show how to access the incoming variables and detect which verb was being used. If you're going to write a REST service then the correct naming of resources and the correct response to each resource being accessed in various ways is really important, but its a story I'll save for another day. If you use this, or perhaps you access the variables another way, then do post a comment - there aren't a lot of resources available on this topic for PHP.
Flickr Plugin Weirdness
Tuesday, July 29. 2008
I am an increasingly avid flickr user and have a growing collection of photos on my flickr account. It seems daft to upload photos twice all the time so I tried the flickr plugin for serendipity (my bloggling platform) but I couldn't get my account to connect correctly. In the box labelled "flickr username" I added my flickr username, "lornajane", which appears in my photos URL. However the plugin seemed to think my photos should then be at a URL:
Eventually I tried another flickr plugin on another site and got identical behaviour - at which point I logged a support ticket with Flickr to ask what I was doing wrong. It turns out that "username" in this case means this label here:

Never noticed that before, and its certainly not how I refer to myself, so I'm a bit confused - but hey my plugin is working! I hope this helps someone (probably me, next time I try to plug flickr in to something else) confused by flickr seeming to think you have the wrong username!
http://www.flickr.com/photos/64718621@N00/which they obviously weren't. I played around with this for a while, also trying my yahoo user id and getting nowhere.
Eventually I tried another flickr plugin on another site and got identical behaviour - at which point I logged a support ticket with Flickr to ask what I was doing wrong. It turns out that "username" in this case means this label here:

Never noticed that before, and its certainly not how I refer to myself, so I'm a bit confused - but hey my plugin is working! I hope this helps someone (probably me, next time I try to plug flickr in to something else) confused by flickr seeming to think you have the wrong username!
Ibuildings Seminar, Leeds
Friday, July 25. 2008
I'm happy to announce that Ibuildings is venturing north of the Watford Gap - and the next event will be in Leeds, on the 9th September, the full details are at http://www.ibuildings.com/events/leeds. The main tutorial session will cover source control with Subversion, including advanced concepts such as merging and repository structures. We'll also look at deployment strategies for different types of software development processes and tools that can be helpful in this area. I'm delivering the main tutorial at this event, and if that wasn't enough incentive, I'm also bringing the nabaztag as my glamourous assistant!
We'll be running events in a lot of other areas of the UK as well, so if you can't make this one then watch out for more announcements or tell us where we should be running the next one! If you have any queries about any of these events then feel free to contact me, I hope I'll see some of you in Leeds in September.
Announcing the Leeds Girl Geek Dinner
Tuesday, July 22. 2008
Once upon a time there was a girl geek called Sarah Blow, and she wanted to hang out with her girl friends and geek out at the same time (and who wouldn't?). So she founded the phenomenon of the Girl Geek Dinner in London. Well this great idea has spread and spread around the world and eventually to the North of England - first to Manchester (next event, this Friday 25th July!) and eventually to Leeds.
So I'm pleased to announce that, on Wednesday 13th August there will be the first Leeds Girl Geek Dinner!! Tickets are £10 and if you needed any further encouragement, I'm one of the speakers for the evening. If you're going, or have any questions, leave a comment below - and I'll see you there!
So I'm pleased to announce that, on Wednesday 13th August there will be the first Leeds Girl Geek Dinner!! Tickets are £10 and if you needed any further encouragement, I'm one of the speakers for the evening. If you're going, or have any questions, leave a comment below - and I'll see you there!
Posted by LornaJane
in tech
at
14:09
| Comments (2)
| Trackbacks (0)
Defined tags for this entry: #leedsgirlgeek, tech
« previous page
(Page 3 of 59, totaling 353 entries)
» next page

Comments
Wed, 27.08.2008 10:19
If it’s anything like the Asus that I have, then it should b e relatively easy to put Ubuntu on it, like I’ve done with m ine. Put installer on to a bootable USB stick…
Wed, 27.08.2008 08:50
It should be possible to automatically close down the wifi c onnection and unload the kernel module on hibernate. Look a t the scripts in /etc/apm/suspend.d for example. /etc/de fault/acpi-support might also have some options to get you s omewhere. I put my normal ethernet driver module (e100 [...]
Tue, 26.08.2008 14:56
Vid: Thanks for dropping by, I’m very pleased to hear you fo und this useful.
Tue, 26.08.2008 14:54
dotjay: Shared offices are OK, but I do like the peace and quiet of not sharing I must say. I get a bit loopy though i f I stay home for too long! The offline time trick is a goo d one – I like to at least turn off the monitor and use a pe n sometimes.
Mon, 25.08.2008 20:00
I’m so glad that you settled into telecommuting so well. As you know, I’ve been working for myself and/or telecommuting for the last five years. I’ve never really had the experienc e of a shared office, but I do use Skype a lot, sometimes ta lking with work mates for hours at a time. The trick i [...]
Sun, 24.08.2008 23:25
Lorna, Great post, found this via Chris’s blog, more tool s in my toolset now :). Thanks
Sat, 23.08.2008 20:46
shaun: I didn’t anticipate problems, I just didn’t think it worked in that way – but I’m completely happy to be told oth erwise :) Don’t be surprised that curl lets you do weird an d wonderful things, lots of tools are like that and it allow s you to use them in ways that the original author had [...]
Sat, 23.08.2008 10:21
ok, I’ve been experimenting with this, ‘switch’ing on the RE QUEST_METHOD to implement post, get, put, delete for a db r esource; so far I’ve not had problems using $SERVER[‘QUERY STRING’] and parse_str()... what problems do you anticipate? (I’m not sending files, everything fits in the string [...]
Fri, 22.08.2008 09:20
The main conference site is now live, and the call for paper s is open – see http://conference.phpnw.org.uk/phpnw08/