
May 15th, 2007 by

Pete
There is a great talk that went up on Google Videos earlier this month called Away with Applications: The Death of Deskop. In it the speaker, Aza Raskin points out that no work is carried out actually using the computers desktop. He also points out the failing of desktop applications, that you frequently need to switch between applications, moving content, to achieve even relatively simple tasks.
I think his points are particularly relevant as we move into an age where many traditional desktop apps are being converted to web applications. I see an increasing trend in web applications of people trying to recreate desktop applications like interfaces in a browser-based setting. Aza urges us to rethink what we know about computer interfaces and to come up with exciting and innovative alternatives.
Traditional applications have had more and more functionality added to them to an extent that they have become “a portmanteau of all possible features”, again it is worrying that many of today’s successful web apps could suffer the same fate. The speaker encourages open APIs and Mash-ups as an alternative and a may to combine applications without having to switch between multiple programs/services.
One of the most interesting parts of the talk for me is when the speaker demos some systems that he’s been developing himself, one is a command-line interface for launching applications that uses almost real language commands and auto-complete. The other is an interesting zoomable desktop, which is much more work orientated than the traditional model, it also centres around the concept of “content as content”.
At nearly an hour and a half the video is quite long but I found it extremely interesting, the speaker also looks a bit like Rick Moranis of “Honey I shrunk the kids” fame, which has got to be a good thing.
# Pete Graham
Posted in Tech, usability, videos |
No Comments »

April 30th, 2007 by

Pete
When I was doing my Computer Science degree our lectures used to make a big deal about making sure you spell Internet with a capital ‘I’, because it’s important and it’s the name of a thing. Apparently it’s now been decided that it should be spelt with a lowercase ‘i’, I wish bloody linguists would make their minds up!
# Pete Graham
Posted in Tech |
2 Comments »

March 29th, 2007 by

Pete
Here's a nifty one liner in PHP which let's you swap 2 variables values.
Much like the PHP XOR swap there's no real reason this is any better than using a temporary variable, but you might be able to impress chicks with it or something.
/* Pete Graham */
Posted in Tech, php, programming |
4 Comments »

March 29th, 2007 by

Pete
If you want to hide certain Navigational Blocks on your Drupal sites forum(s) here’s how to do it:
1. Go to "Administer » Blocks"
2. Click "configure" on the block you want to hide.
3. On Page specific Visibility Settings click the option for "Show if the following PHP code returns TRUE"
4. Enter the following code in the text area:
PHP:
-
if (arg(0) == 'node')
-
{
-
$node = node_load
(array('nid' => arg
(1)));
-
return $node->type != 'forum';
-
}
-
elseif (arg(0) == 'forum')
-
{
-
return false;
-
}
-
else
-
{
-
return true;
-
}
-
?>
This will hide the navigation on the forum hompage, when viewing lists of topics and when viewing individual posts (nodes).
# Pete Graham
Posted in Tech, Website Development, php, drupal |
14 Comments »

March 26th, 2007 by

Pete
I wrote last week about how I’m trying to improve my JavaScript skills. As a small exercise I have written this function for unobtrusively selecting/deselecting checkboxes in a form.
JAVASCRIPT:
-
function selectAll(box)
-
{
-
// get the elements name
-
var id = box.id;
-
var name = /^([a-z]+)(_select_all)$/i.exec(id);
-
-
name = name[1];
-
-
re = new RegExp('^'+name+'_[0-9]+$');
-
-
// get the elements stauts
-
var state = box.checked;
-
-
// get the form element, search "up"
-
var form = box.parentNode;
-
while(form.nodeName.toLowerCase() != "form")
-
{
-
if(!form.parentNode) break;
-
form = form.parentNode;
-
}
-
-
// search through forms children for email_ checkboxes
-
for (i=0;i<form.elements.length;i++)
-
{
-
if (form.elements[i].type=='checkbox')
-
{
-
// Find checkbox for each member of the group:
-
if (re.test(form.elements[i].name))
-
{
-
form.elements[i].checked = state;
-
}
-
}
-
}
-
}
-
-
-
-
// onload stuff
-
window.onload = function()
-
{
-
var email = document.getElementById('email_select_all');
-
-
email.onclick = function(){
-
return selectAll(email);
-
};
-
}
The Javascript will work on a HTML form like this
HTML:
-
-
-
<!-- Select all check box -->
-
<input id="email_select_all" type="checkbox" />
-
-
<!-- list of check boxes -->
-
<input type="checkbox" name="email_1" value="1" />
-
<input type="checkbox" name="email_2" value="1" />
-
<input type="checkbox" name="email_3" value="1" />
-
<input type="checkbox" name="email_4" value="1" />
-
-
<input type="submit" value="Send Message" />
-
</form>
As long at the select all checkbox has an id of "something_select_all" and the checkboxes have id's of "something_"followed by a number then this will work. No inline Javascript is required all the JS can be put in a separate file.
Note: If any Javascript Gurus are reading that have pointers about how I could improve this function then please put your suggestions in the comments.
# Pete Graham
Posted in Tech, javascript, Website Development, unobtrusive |
2 Comments »

March 22nd, 2007 by

Pete
Here are 3 different ways to perform a DB select when you want to specify two or more values for a field.
1. Use th OR operator
SQL:
-
SELECT * FROM people
-
WHERE (first_name = 'pete'
-
OR first_name = 'paul');
2. Use a Regular Expression
SQL:
-
SELECT * FROM people
-
WHERE first_name ~'^pete|paul$';
3. Use an array
SQL:
-
SELECT * FROM people
-
WHERE first_name = ANY('{pete,paul}');
Note: These should all work in PostgreSQL, I suspect the SQL may need altering for 2 and 3 to work with MySQL.
# Pete Graham
Posted in Tech, regular expressions, database, sql |
No Comments »

March 22nd, 2007 by

Pete
If you need to remove elements from an array that have a particular value(s) here’s a neat way of doing it without any looping:
PHP:
-
// our initial array
-
$arr =
Array("blue",
"green",
"red",
"yellow",
"green",
"orange",
"yellow",
"indigo",
"red");
-
-
-
// remove the elements who's values are yellow or red
-
-
-
-
// optionally you could reindex the array
-
-
This is the output from the code above:
Array ( [0] => blue [1] => green [2] => red [3] => yellow [4] => green [5] => orange [6] => yellow [7] => indigo [8] => red )
Array ( [0] => blue [1] => green [4] => green [5] => orange [7] => indigo )
Array ( [0] => blue [1] => green [2] => green [3] => orange [4] => indigo )
Pete Graham xXx
Posted in Tech, php, arrays, programming |
11 Comments »

March 21st, 2007 by

Pete
There’s an Urban Myth that Bill Gates is so rich that if he was to drop a $1000 bill on the ground, it's just not worth his time to bend over and pick it up. Now it is true that he wouldn’t pick it up, however the real reason for this is he was wedgied multiple times as a child and now has a phobia of picking things of the floor.

- FACT: In the hilarious 1990s comedy Bill and Ted wedgieing a person is referred to as giving someone a Melvin
- FACT: You can escape the Grim Reaper by Melvining him!
The Wikipedia Wedgie page is well worth reading.
# Pete Graham
Posted in Tech, Bill Gates, wedgie |
No Comments »

March 20th, 2007 by

Pete
I started work in web development in 2004 at this point in time JavaScript was hugely unpopular in terms of web trends, this is probably because it was mostly used for annoying pop-ups, animations and whole list of other horrendous Internet crimes. I can recall having a King Herod style culling of all JavaScript from the TCAT website, my first main project.
Recently due to the popularity of AJAX web applications JavaScript’s popularity seems to have exploded again! I’ve had to brush up on my JavaScript skills for some of the User Interface work on phuser.com. Whenever I do JavaScript development I never feel as comfortable as I do with PHP or CSS. It’s definitely the weakest weapon in my web-dev arsenal.
I think it’s time to put my JavaScript prejudices behind me and get my hands dirty with some serious JS development. Now I’m not a JavaScript novice, I’ve got a few DHTML tricks up my sleeve I learnt back in the day. However I rarely write my own JavaScript, if I need a function I’ll look for one someone else has written.
When I’ve needed to learn about Javascript in the past I’ve always find it surprisingly hard to find good quality decent resources (compared to other Web technologies). I shall be posting links to any JavaScript articles/tutorials that I find particularly useful on this blog.
Articles
# Pete Graham
Posted in Tech, javascript, Website Development, usability |
3 Comments »

March 19th, 2007 by

Pete
People seem to love my lists. Here is one of my favourite electrical connections:
- Scart Socket
- USB Port
- 3.5mm Stereo jack
- Double phono
- 2.5mm Stereo jack
- Parallel port
- Ethernet
- PS/2

/* Pete Graham */
Posted in Tech, scart, electrical connections |
2 Comments »