Archive for 'code'

Building POST data manually

July 20th, 2009 – 7:50 pm
Filed as: code, iphone

After spending quite a while trying to figure this out I’m posting it as a reminder in future

POST http://example.com/upload.php HTTP/1.1
User-Agent: Photo Uploader (foobar/1.0.0)
Content-Type: multipart/form-data; boundary=AaB03x
Content-Length: xxxx

–AaB03x
Content-Disposition: form-data; name=”foo”
Content-Type: text/plain; charset=utf-8

12345
–AaB03x
Content-Disposition: form-data; name=”Filename”
Content-Type: text/plain; charset=utf-8

image1.jpg
–AaB03x
Content-Disposition: form-data; name=”MimeType”
Content-Type: text/plain; charset=utf-8

image/jpeg
–AaB03x
Content-Disposition: form-data; name=”ImageData”;
filename=”image1.jpg”
Content-Type: image/jpeg
Content-Transfer-Encoding: binary

–AaB03x–

addthis_url = ‘http%3A%2F%2Fwww.c3b.co.uk%2F%3Fp%3D70′;
[...]

Alternative method for opening Smarty templates with HTML syntax highlighting in gedit

December 16th, 2008 – 11:41 am
Filed as: code, ubuntu

Here is an update to a previous post regarding how to get gedit to recognise Smarty template *.tpl files. I’ve found that gedit prefers to use the mime type to decide what type of file it is and therefore what syntax highlighting to apply.
After a little investigation I found that most of my .tpl files [...]

YouTube GData API returning error 400 when uploading a video

May 14th, 2008 – 11:03 am
Filed as: code

I’ve been battling with the YouTube API for the last 2 days now and found the single line of code that has been preventing me from generating a form upload token.
I was following the example code at http://code.google.com/apis/youtube/developers_guide_php.html#UploadingVideos and kept receiving “Expected response code 200, got 400″ when calling the getFormUploadToken function. HTTP error code [...]

Smarty template syntax highlighting with gedit

May 2nd, 2008 – 5:04 pm
Filed as: code, ubuntu

Update: I have posted an alternative way to do the same thing this post describes, the alternative way should be more reliable. See it here http://www.c3b.co.uk/2008/12/16/alternative-method-for-opening-smarty-templates-with-html-syntax-highlighting-in-gedit/
I’ve started using gedit as my code editor after a couple of niggles with bluefish and wanted my smarty templates (*.tpl) to use the same syntax highlighting as HTML. Not [...]

I’ve finally embraced CSS

February 29th, 2008 – 5:41 pm
Filed as: code

I’ve been putting together sites for years but never really taken the time to learn CSS properly and sticking with table based structure for far too long, finally I have built my first site using nothing but CSS and div tags for layout. It’s probably not perfect but it works and that’s the main thing [...]

<fb:share-button /> useless error message

February 26th, 2008 – 3:41 pm
Filed as: code

It seems the <fb:share-button> control has 1 error message:
There was an error trying to share this content.
Sorry, the content owner’s privacy settings don’t allow you to share
this content.
The actual reason for this error message was that the href of the target_url link was blank. It turns out this can happen if you mistype target_url too.

[...]