Copyright © 2010 The G String. All Rights Reserved. Snowblind by Themes by bavotasan.com. Powered by WordPress.
Archive for September, 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.
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 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.
Continue Reading »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>
Continue Reading »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.
Continue Reading »