This is my personal blog. I also have a professional blog at http://siliconsparrow.com/

17 October 2008

Elastic Tabstops by Nick Gravgaard

Filed under: General — adam @ 5:55 pm

I’ve just been playing with the Elastic Tabstops plugin by Nick Gravgaard. I really like it. I like my code to look neat so when I write a block of code like this:

   $custFirstName = $_REQUEST['cust_first_name'];
   $custLastName = $_REQUEST['cust_last_name'];
   $custEmail = $_REQUEST['cust_email'];
   $custAddr1 = $_REQUEST['cust_addr_1'];
   $custAddr2 = $_REQUEST['cust_addr_2'];

I always try to neaten it up by adding spaces like so:

   $custFirstName = $_REQUEST['cust_first_name'];
   $custLastName  = $_REQUEST['cust_last_name'];
   $custEmail     = $_REQUEST['cust_email'];
   $custAddr1     = $_REQUEST['cust_addr_1'];
   $custAddr2     = $_REQUEST['cust_addr_2'];

Which is a little fiddly but I always do it because like I said, I like my code to look neat.

But now I have a tool which does it automatically. I’m very happy.

It will even handle proportional fonts so I’ve been experimenting with the decadent pleasure of coding in more beautiful type faces and still having everything line up.

Unfortunately it is only for gedit at this time (which is a fine text editor but just a text editor nevertheless). If this were available in Eclipse or MS Dev Studio, I’d be in heaven!


12 October 2008

Windows vs Linux when Changing Motherboards

Filed under: General — adam @ 8:30 pm

My new motherboardWell, here’s an interesting little tidbit. My home box is dual boot with Windows XP SP2 and Linux Ubuntu 8.04. My motherboard has been playing up recently so I got myself a new one, a Gigabyte GA-G31M-S2L. This is a budget board with a pretty plain-vanilla collection of peripherals.

After installing the board I chose to boot up Ubuntu first. I thought I’d probably need to install some drivers for the onboard audio, video and Gigabit Ethernet but no, it just worked! I was amazed. It would seem the days are gone when getting new hardware to work under Linux was a massive chore. I was so stunned I had to write a blog post about it. Even 3D acceleration worked immediately, no mess, no fuss.

Then I tried booting into Windows. Ha ha haha ha. Did it work straight up. Did it hell! I had to spend an hour mucking about with loading drivers and rebooting a million times.

Nowdays we have many cross-platform applications such as Open Office, GIMP, Firefox and so on. Add to this the increasing stability and simplicity of the Gnome desktop, Ubuntu is very much a serious competitor for Windows, not just some time in the future but right now.


3 October 2008

Centering and Scaling an Image on a Web Page

Filed under: General — adam @ 10:34 am

I want a web page which displays a single image. The image is to be scaled so it is as large as possible within the browser but without losing it’s aspect ratio.

I also want it to be centred (or centered if you are American).

After spending literally hours trying to do this with CSS and scads of nested div tags, I have decided it is not possible to do it this way. The alternative was to use Javascript to compute the size and position of the image.

Here is the final code which works on IE and Firefox:

<html>
<head>
<script>
function scaleAndCenter(id)
{
 img = document.getElementById(id);
 img.style.position = "absolute";

 if(img.width / document.body.clientWidth > img.height / document.body.clientHeight)
 {
  img.style.width = "100%";
  img.style.top   = (document.body.clientHeight - img.height) / 2;
 }
 else
 {
  img.style.height = "100%";
  img.style.left   = (document.body.clientWidth - img.width) / 2;
 }
}
</script>
</head>
<body style="margin: 0; background: black;">
<img id="image" src="myimage.jpeg" onload="scaleAndCenter(this.id)" />
</body>
</html>

20 September 2008

Bed Hair

Filed under: General — adam @ 11:09 am

Adam with bed hairI’m not my best first thing in the morning. Some evil person has been taking pictures…


14 July 2008

Gravatar support

Filed under: General — adam @ 10:54 am

Just a quick note that this site now supports Gravatars. So if you make a comment here and are registered over at www.gravatar.com, your picture will appear next to your comment like magic!


30 April 2008

No more advertising

Filed under: General — adam @ 8:36 pm

As you can see, I have removed all the Google ads from this blog.

This blog gets around 1000 page views per day and I’ve been running the ads for about a year and a half now. In all that time Google have not paid me anything. Not a cent! So they are gone.


17 January 2008

Multicomp on Linux

Filed under: General — adam @ 8:59 pm

Hey, Multicomp runs pretty good under Ubuntu using WINE!

multicomp-on-linux.png


15 January 2008

SpamBam – anti spam for WordPress

Filed under: General — adam @ 9:07 am

I’ve been using the excellent WordPress blogging software for a year and a half now and it has been good – except for the comment spam. By the end of 2007 I was getting more than 100 comment spams every day and I was mighty tired of manually deleting them.

Then I found SpamBam by Gareth Hayes. I’ve been running it for two months now and in that time I have received no spam. None. Not a single one.

If that isn’t the best anti-spam plugin ever, I’ll eat my hard drive.


20 November 2007

Thunderbird ate my mail

Filed under: General — adam @ 2:54 pm

If anyone has tried to email me yesterday or today (19/20-Nov-2007), it might be an idea to re-send your email ‘coz I’ve fallen victim to Thunderbird bug #323875

In summary, don’t ever use T-bird’s “Undo Delete Message” function! Under certain circumstances it can destroy a lot of your messages.


12 November 2007

Moving day

Filed under: General — adam @ 10:00 pm

After moving house, I have also had to move my site to a new hosting service. I was previously hosting it from home but now I am on Web City.

Apologies to everyone who has been trying to view this site, it has been down for almost 6 days. I’ve been rather busy packing and moving. Also I thought it more important to get my friend’s and family web sites up first.

Hey, how about that. I finally found an opportunity to do some Slashdot-style hyperlinks!


« Previous PageNext Page »

Powered by WordPress