KrisWillis.com

Flower

Archive for the ‘Web Development’ Category

Shorten URLs and post to Twitter with PHP and cURL

I recently had the task of automatically “tweeting” when a new article was posted to one of the websites I had built, it turns out to be a pretty simple operation thanks to both Twitter and Bit.ly providing a straight forward API. An account with Bit.ly does have to be opened to obtain an API key.

I decided to use the built-in cURL functionality of PHP for interacting with the APIs. This code uses some of the JSON functions introduced in PHP 5.2.0 so a recent install of PHP is required as the Bit.ly API responds with a JSON string. On to the code…
(more…)

IE6 Bug: H1 tags with background colours

No IE6I have just noticed an odd bug when viewing a H1 tag with a background colour under IE6 – There is no background colour until the H1 is taken out of view by scrolling it out of the viewport and then bringing it back again. Highlighting the text partially brings in some colour.

One solution for this issue is add relative positioning to the tags CSS class.

Table joins in MySQL with no matches

MySQL LogoI consider my understanding of MySQL around the intermediate level, but when writing table joins in the past I have always used the ‘equi-join’ method:

SELECT t1.*, t2.`name` FROM t1, t2 WHERE t1.n = t2.n;

Now, when a record for t2.n doesn’t exist, a row will not be returned. To solve this problem in the past, I would have executed two separate queries and process the output with PHP – Not the most efficient solution.

(more…)

Recolouring images with PHP

Blue roseAbout a year ago I was working on a project where one of its features allowed the user to upload an image, select a colour on the image with a colour picker tool, then select from a group of colours to replace the picked colour with. I had a somewhat stable build running where it simply replaced the hue of the picked colour – Introducing saturation and value changes invoked a number of ‘random’ glitches and odd colour effects. This feature was subsequently dropped from the project due to it costing too much to continue developing.

Skip forward about a year and I find this script knocking around on a back-up disc, so I decide to put some more development time in purely for my own satisfaction of enhancing it. I have made it work to a nearly passable level, it works nice on images with isolated high contrasting colours. I created a function to create a tiled pop-arty graphic from an inputted image too just for fun. For example, input this and it will spit out this. There is plenty of room for improvement: You can’t convert colours to or from white/black and it replaces all instances of a colour, not a flood-fill effect. So, on to the code… (more…)

Developing for the desktop with web technology

Adobe ApolloApollo is the code name for a cross-operating system runtime being developed by Adobe that allows web developers to use their existing skills to build and deploy Internet applications to the desktop that combine the benefits of web applications – network and user connectivity, rich media content, ease of development, and broad reach – with the strengths of desktop applications – application interactions, local resource access, personal settings, powerful functionality, and rich interactive experiences.

Apollo is currently in alpha with support for HTML, JavaScript and Flash – There is basic support for AJAX with more coming in v1.0 no doubt. The alpha currently is only supported on Windows and OS X although Linux will be supported shortly after the release of 1.0, this has something to do with the latest Flash player not being finished for Linux, or something.

So I guess this works in a similar way to Java in that it’s machine-independent, although less powerful no doubt but with a smaller resource footprint one would hope. This looks like one to keep an eye on. Check it out here.

Running multiple versions of MSIE on Linux

For those of us that are developing web projects on a Linux box that are fed up with jumping over onto a Windows machine to test their code in Internet Explorer there is a nice and easy script called IEs4Linux that makes the process of installing MSIE 5, 5.5 and 6 onto a Linux box a breeze.

Although IEs4Linux doesn’t fully support IE7 yet, there is enough support in their latest beta for testing code on – It pretty much loads up the IE7 rendering engine into an IE6 GUI, although there are still bugs, it should work well enough for testing.

Check out IEs4Linux here.

You are currently browsing the archives for the Web Development category.