Does anyone sell CPUs anymore?

November 13th, 2008

I thought I used to know some good places on the web to get hold of affordable components, but I have been totally frustrated in my search for AMD and Intel CPUs today.

I’m putting together a server that will be used to support my endeavours as a freelance web developer. Very soon I will have a server that is hosted in a data centre (rather than my living room), that I can use to host the web projects that I’m working on.

I am considering the Tyan barebone systems for starters, and these seem to be readily available. But after spending a couple of hours on scan, ebuyer and ebay, as well as google shopping and other sites I’ve never visited before, it would seem that I can’t buy any CPUs to put in the damn thing. Have AMD and Intel gone bust without telling me?

Scan don’t even stock 1000 series or 2000 series opterons, although they sell a Tyan barebones that takes dual-core opterons. I’ve had some experience using sun servers and HP servers at my time with Titan Entertainment, but I was hoping to save a few quid building my own. Anyone know any good e-tailers or know why AMD CPUs are so scarce?

htpasswd or htdigest ?

November 7th, 2008

Gotcha! Don’t make the mistake I just made when setting up digest authentication in apache2. Depending on whether you’re using basic or digest authentication, you need to use a different command line tool to generate your passwords. After fifteen minutes of confusion, I realised that I needed htdigest to generate my passwords rather than htpasswd, although this crucial fact is not obvious from a glance at the documenation.

A typical setup for digest authentication is:

<Location /some/url>
      AuthType Digest
      AuthName "realm"
      AuthDigestDomain /some/url
      AuthUserFile /path/to/.htpasswd
      Require valid-user
</Location>

Then use htdigest…

htdigest -c /path/to/.htpasswd realm username

Arranging a list as a grid using CSS

September 27th, 2008

One of the things that I found that CSS doesn’t handle adequately is arranging a layout as a grid.  Back in the day, when you’d have tables nested in tables nested in tables, it was a horiffic mess, but at least I always knew where I was with layout; and the table element seemed to handle different browsers more reliably too. Now we have a situation where the standard ‘correct’ approach will not work in IE, leaving the developer the choice of a hacky-workaround or providing for IE seperately.

Anyway, these days its bad form to use tables for layout, so I went about making a list of tracks on my web application into a grid using the CSS approach.

CSS supports table-like layouts using the display:table, display:table-row, display:table-cell styles. Whereas before you’d have

<table>
  <tr>
    <td>Hello</td>
  </tr>
</table>

Now you can use any element to form your table.

<div style="display:table">
  <div style="display:table-row">
    <div style="display:table-cell">Hello</div>
  </div>
</div>

What I wanted was to display my list of track objects on the screen using a grid, to make the best use of the horizontal space. But, when styles were turned off, I wanted to keep the list structure. I ended up using

<div class="trackgrid">
  <ul>
    <li>Track one<li>
    <li>Track two...</li>
  </ul>
</div>

div .trackgrid
{
  display: table;
}

div .trackgrid ul
{
 display : table-row;
}

.trackgrid ul li
{
  display : table-cell;
  list-display : none;
}

Which gives the desired effect of arranging the list elements horizontally and without the bullet marks. I used the same technique to create a horizonal menubar, and there are several other uses for it.

Exporting mySQL data into sqlite3

September 27th, 2008

When working in ruby on rails 2.0.2 I keep my development database in the default sqlite3 but use mysql for the production database on a seperate test server. I found that after a while of use from my alpha-testers, the test server database for my web app had been filling up with useful, real-life data, that I wanted to use on my development environment. So I needed a way to transfer the data from mySQL (5.0.32) into sqlite3.

I exported the data from mySQL using the mysqldump utility. The mysqldump tool is normally used for backing up mySQL databases, but with a but of cunning can be used to export data into other formats. Firstly, since my sqlite3 development database already exists and can be recreated from the rake migration scripts, I didn’t need any of the SQL statements that modify or create the schema. You can tell mysqldump that with the –no-create-db and –no-create-info arguements to mysqldump:

mysqldump --no-create-db --no-create-info yourdatabase

Secondly, mysqldump uses its comma-seperated INSERT feature for brevity. However, sqlite doesn’t like this, so I wanted it to use a sepereate INSERT statement for each row. This is done with the –extended-insert=0 option

mysqldump --no-create-db --no-create-info --extended-insert=0 yourdatabase

Lastly, I wanted to ignore any of the comments or locking statements and output only those INSERT statements into a file. I did this using grep and piping the output:

mysqldump --no-create-db --no-create-info --extended-insert=0 yourdatabase | grep 'INSERT'

you can then redirect this output into a file

mysqldump --no-create-db --no-create-info --extended-insert=0 yourdatabase | grep 'INSERT' > yourdatabase.sql

The one problem that I found with this output was that sqlite3 handles escape characters differently from mySQL, so I had to manually replace any instances of \’ with ” using my text editor.

This yourdatabase.sql file then contains a load of INSERT statements. Since I didn’t need the data in my development database anymore, I decided that the easiest thing to do would be to just delete the db/development.sqlite3 database and use rake to rebuild the schema, to leave me a clean, empty database. This avoids problems such as clashing primary key entries.

rm db/development.sqlite3
rake db:create
rake db:migrate

Finally, to import my data into sqlite3 I used the .read command in the interactive command-line tool

.read yourdatabase.sql

I’m back…

September 26th, 2008

I suppose that its a bit egotistical to search one’s own name in Google, but I’m pleased to say that I’m back to the #1 spot for the UK google listings, beating off some stiff competition from the Dan Garland construction company, Oklahoma. Admittedly, I have been a bit reclusive recently, but I hope that this puts to bed the argument of which is the most relevant Dan Garland website on the Internet.

Using name based virtual hosting with apache2 and SSL

September 24th, 2008

One of the things I found when getting my Wordpress installation going was that I wanted to run a seperate subdomain for it, whilst keeping my secure server that I use for developing websites running SSL on port 443.

Normally, to set up virtual hosting, I would add something like this in my site’s config file:

<VirtualHost *>

But to keep the hosts listening on the right ports, you need to add the port number to the wildcard:

<VirtualHost *:80>

Trouble was, when you use the NameVirtualHost directive in apache2, you can’t mix the port numbers.

The solution was found on Friend’s of Bart http://fob.po8.org/comment/reply/289

Simply use

NameVirtualHost *:80

NameVirtualHost *:443

Both in your apache2.conf file. Then in each of your site’s config file, use the explicit port number on the VirtualHost directive:

<VirtualHost *:80>

<VirtualHost *:443>

First of all…

September 24th, 2008

I suppose that each of these so-called blogs has an entirely useless post by way of introduction, and in the case of the ‘G-string’, this is it.

My name is Dan Garland, I’m a musician and web entrepreneur, and I enjoy spending time creating things. I’ve had a website since I was a youngster, with a Geocities site containing jokes and other things. When the term blog first became an ordinary word, I couldn’t understand what the fuss was all about- after all, a blog is simply a website that you update more often, without an FTP client and text editor. So in my stubbornness I decided that rather than starting a blog using one of the free tools out there, that I’d write my own blog tool and use that. This mistake, which I have repeated many times, is the main characteristic in a Java developer, namely, to build a generic solution to imagined problems rather than addressing the issue at hand. In the end, I have decided to just give up and use Wordpress.

Perhaps I might elaborate on the title. I have taken the first letter of my surname, G, and combined it with String, because String is a common class of object-orientated computer languages, and when you combine them you get an important part of a guitar, and a type of pants.

I aim to use this blog to log difficulties and voice complaints about my experiences in developing websites, mainly because I am now unemployed and free to persue works of my own choosing. I have several truly award-winning ideas for web projects, the development of which I shall be charting in these pages.

Please feel free to join this blog and correct any mistakes I make.