Category Archives: Software

Downgrading Iceweasel on Debian Wheezy

Preamble

By default, Debian Wheezy installs Iceweasel (Firefox) 10.x. This can break a lot of extensions so, for those who would rather stick with version 3.x, this is how I reverted to the older version. Note that there may be alternative, ” official” method, but this is the quick-and-dirty that I came up with.

Disclaimer: this worked for me, your mileage may vary. Use these instructions at your own risk. (If you do come across any issues, please get in touch – especially if you find solutions – so I can amend this article.)

Get The Packages

At the time of writing, the current, stable, version of Debian is Squeeze – which installs Iceweasel 3.x by default. We will, therefore, make use of Squeeze packages:

Download packages appropriate for your architecture, install using dpkg -i, in the order given above. I think this is the correct sequence to solve all dependencies. Other dependencies may be unmet due to different software configurations. Simply note what’s missing from the messages given by dpkg and find the packages through packages.debian.org.

Footnote

Due to the rather onerous process of creating XUL-based extensions (and for other reasons) I am in the process of migrating to the Chromium browser. I went through this exercise because I can’t commit the time to either writing the Chromium extension or fixing the Firefox/Iceweasel one. With Chris Pederick’s Web Developer Toolbar now being available for Chrome/Chromium, my one little extension is the only remaining reason to be using Firefox/Iceweasel as my main browser.

Extensible Metadata for Your CMS

Preamble

I am a metadata enthusiast, especially when it comes to Dublin Core. When it comes to the Web, I don't just want to see metadata for pages, I want to see metadata that conforms to a formal vocabulary (like Dublinc Core.) A quick read of my article Metadata, Meta Tags, Meta What? may help the reader get up to speed on this.

Content Management Systems (CMS) can provide a perfect framework for the creation, maintenance and presentation of metadata. Unfortunately, for most CMS software, this functionality is limited – often to informal, 'legacy,' terms – if it exists at all.

In my ideal world, a CMS would provide a ready-to-use means of associating Dublin Core metadata with all pages and be extensible so that the vocabulary could be extended or extra vocabularies added. Compared with some CMS functionality, this is not something that is difficult to achieve so I can only assume that the general lack of implementation speaks a total lack of interest in metadata on the part of the CMS developers.

Some time ago, I presented a set of notes on how to achieve this to a developer working on the Mambo CMS. This work never came to anything at the time as the project forked shortly thereafter and said developer left the project. Subsequent to this, I started working through my notes to produce an extensible metadata extension for the Drupal CMS and also described a toolkit that could be used to work with other CMS. Due to ill-health and lack of time, neither of these bore fruit.

The only progress I have really made on this to date has been in advising the developer of mojoPortal on my metadata concepts; a Dublin Core implementation for mojoPortal is being worked on at the time of writing.

Now, some three years on, I will try to make amends through this article by describing my concepts for adding an extensible metadata management system to a CMS.

I will attempt to keep this article as technology-neutral as possible by describing only the SQL table schemata and queries required to implement the system. However, it should be borne in mind that I am writing from a MySQL perspective and that changes may be required if working with other database technologies – especially when it comes to stored procedures.

One assumption that I am making, which is key to the whole concept, is that every page in the CMS is identified internally by a unique integer field. In the Drupal CMS, this would be the Node ID (nid.) If some other system is employed, a lookup table may need to be employed to implement my concepts.

The Simple, Inflexible Approach

To add metadata functionality to our CMS, we first need to extend the database schema. We could do this either by adding new fields to the table where we store our page content or to create a new table where we can store our metadata.

Our extended table or new table can have a column for every term. This keeps queries and management very simple – but is highly inflexible as adding terms would require modification of the table schema and the queries that relate to it. I find this approach somewhat distasteful – using a flat and fixed data structure when we have the power of a relational database to work with.

Key Metadata Concepts: Triples, n-Tuples

Metadata are data describing data. In the Web context, metadata are various pieces of data that describe properties of a page or media object.

In its simplest form, a metadata statement comprises three elements, the thing we are talking about, the property we are describing, and the value of that property. This set-of-three may be described as a triple or 3-tuple.

Consider the following example of the 'legacy' description metadata element:


<meta name="description" content="an article about metadata" />

Do you see the three elements of the triple? No; that's confusing, isn't it? This is because we are presenting the metadata on the page we are describing; the name attribute of the meta element tells us the property we are describing, the content attribute the value of that property; the subject – the thing we are talking about – is implied. (Those who deal in the grammar of human languages may wish to compare this with the concept of an imperative sentence, where the subject is implied rather than expressed. The name and content attributes thus form the predicate of that sentence.)

Now, who says we can only present metadata about a page on that page? Nobody. If we are storing this metadata in our CMS, we can present it elsewhere, such as in an external RDF file. Our store of metadata may be used to create a library-catalogue of our entire site.

For this simple case, where our metadata can be represented by triples, we might create a database table like this to accommodate it. (Note that more detailed descriptions of fields will be given for the "real-life"
schema later in this document.)


/*
Metadata is stored here.

subject - unique ID of page we are describing.

term - refers to metaterms.term; we look up metaterms.termname
to find the value that goes in the name attribute of the meta
element.

termvalue - what goes in the content attribute of the meta element.
*/
create table metadata
(
subject int unsigned not null,
term int unsigned not null,
unique index(subject,term),
termvalue text
);

/*
Terms are stored here.
*/
create table metaterms
(
term int unsigned not null auto_increment primary key,
term_name varchar(64)
);

/*
Set up some terms.
*/
insert into metaterms (term_name) values ('description'), ('keywords');

/*
Now create description and keywords records for our page which
has unique ID of 1.
*/
insert into metadata (subject, term, termvalue) values
(1,1,'an article about metadata'),(1,2,'metadata; Dublin Core; blah blah;');

See? All nice and simple for triples.

Dublin Core Complicates the Issue

Let's have a look at a couple of meta elements containing Dublin Core metadata assertions:


<meta name="DC.title" lang="en" content="Extensible Metadata for Your CMS" />
<meta name="DCTERMS.created" scheme="DCTERMS.W3CDTF" content="2009-12-05" />

Our DC.title has an extra property, lang, and DCTERMS.created has an extra
property, scheme. This somewhat complicates matters and means that the triple is no longer capable of holding all the bits we need. We are now moving up in the n-tuple (a triple is a tuple with 3 components, an n-tuple is a tuple with n components) world. Our triple, or 3-tuple, has now become a 6-tuple.

If you are now wondering how I came up with a 6-tuple, let's have a count:

  1. Subject (this page, implied)
  2. Vocabulary – the first part of the name attribute. From our example, this is either DC or DCTERMS.
  3. Term name – the second part of the name attribute.
  4. Scheme
  5. Language
  6. Value of the content attribute.

So, the mysterious extra member of the n-tuple occurs because we are overloading the name attribute of the meta element.

Our database structure just got a bit more complicated. How much more complicated is up to the developer; we can either stand up as purists and use a fully relational model, or we can cheat, simplify things and hope they don't come back to bite us. If we plan things carefully and consider the scenarios in which we are going to use our CMS, hopefully being bitten by the results of Bad Decisions will not be amongst our worries.

The Fully Relational Method

Is actually not quite full relational. I have cheated a little even in this method to make metadata searches a little more efficient. Let's have a look at the new schema of our metadata table:

Metadata Table


create table metadata
(
subject int unsigned not null,
index(subject),
termid int unsigned not null,
index(term),
scheme int unsigned not null,
index(scheme),
lang char(8) not null,
index(lang),
termvalue text,
fulltext(termvalue)
);

Metadata Table Fields

subject
The unique ID of the page in question (eg: nid for Drupal.)
termid
foreign key – refers to the primary key of the metaterms table, described below.
scheme
foreign key – refers to the primary key of the schemes table, described below.
lang
The language of the content of the meta element (eg: EN-US, FR, DE, etc.)
termvalue
The actual value of the content attribute of the meta element.

You will note that this table does not have a field to store the vocabulary. This is not necessary as this may be looked up from the metaterms table.

The columns scheme and lang are designated NOT NULL for purposes of indexing.
As values for these are not always present, we would populate these with
0 (zero) and 'NULL' respectively when no values are given. The
software generating the meta element for the HTML document would skip creation of the respective attributes if these defined null values were found.

Metaterms Table

The metaterms table is where we define all the metadata terms that we can use.


create table metaterms
(
termid int unsigned not null auto_increment primary key,
vocabterm varchar(32) not null,
unique index(vocabterm),
vocab int unsigned,
defscheme int unsigned
);

Metaterms Table Fields

termid
The primary key for this table.
vocabterm
The value of the name attribute of the meta element. It is here that a bit of "cheating" takes place. You will
recall that the name attribute of the meta element is overloaded by combining both vocabulary and term, as in DC.title. The metaterms table would have a field that contains just the term – at least it would if were doing things nicely. For the sake of efficiency, however, the vocabterm field contains the same vocabulary+term value that appears in the name attribute of the meta element. (The alternative would be to look up the vocabulary [the DC part of DC.title] from the vocabs table.)
vocab
foreign key – refers to the primary key of the vocabs table.
defscheme
foreign key – refers to the primary key of the schemes table; this is the default scheme for this term. If we want our system to be flexible, we should
let the user override this on a per-use basis, if they so wish.

See Appendix A for a dataset that can be used to pre-populate this table.>

Vocabs Table

The vocabs table is where we set up master records for the different vocabularies that will use. One of the key functions of this table is to provide the URIs that should be linked in our HTML document <head></head>.
For a full Dublin Core implementation, these would be:

<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />
<link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" />

And here's the schema:


create table vocabs
(
vocab int unsigned not null primary key,
vocabname varchar(8),
vocaburi varchar(128)
);

Vocabs Table Fields

vocab
The primary key for this table.
vocabname
This is the first of the values that are joined in the name attribute
of the meta element – the DC of DC.title or DCTERMS of DCTERMS.created.
vocaburi
URI of the schema for this vocabulary, for instance http://purl.org/dc/elements/1.1/ for the DC vocabulary.

Appendix B provides a dataset that can be used to pre-populate this table.

Schemes Table

The schemes table provides a list of possible values that can be used
in the scheme attribute of the meta element.


create table schemes
(
scheme int unsigned not null auto_increment primary key,
schemename varchar(32) not null,
index(schemename)
);

Schemes Table Fields

scheme
The primary key for this table.
schemename
The actual value that will appear in the scheme attribute of
the meta element.

Appendix C provides a dataset that can be used to pre-populate this table.

Simple/Cheats' Method

If we are prepared to sacrifice flexibility and accept the default scheme in
the metaterms table as being the only that may be used for each term, we can do away with the schemes table altogether and replace the integer column metaterms.scheme with a varchar column containing that default scheme.

Another option would be to abandon the vocabs table and hard-code the links shown in the vocabs table section into the document template. If additional vocabularies were to be added, any corresponding schema links would also need to be added to the template.

SQL Queries

Whilst the database structure described here should provided what is required to implement a metadata repository for a CMS, I will provide some example queries to help get the ball rolling.

Vocabulary Links

select concat('schema.',vocabname), vocaburi from vocabs
where vocaburi is not null and vocaburi!='';

This will provide values ready to put in the rel and href attributes
of link elements. These links could also be added as static text
to the page template, as described in the Simple/Cheats' Method section.

Retrieving Metadata for a Page

Assuming that our page/node ID is 1234:

select t.vocabterm, s.schemename, m.lang, m.termvalue
from metadata m
join metaterms t on t.termid=m.termid
left join schemes s on s.scheme=m.scheme
where m.subject=1234;

This will return values for the meta element attributes name, scheme, lang, and content respectively. As values for scheme and lang may be NULL, creation
of these attributes should be suppressed if no value is returned for them.

Note
that the schemes table is attached with a left join so that a NULL may be
returned if the value of metadata.scheme=0.
(See Metadata Table Fields.)

Further queries may be added to this section if I think of anything
else that might be useful.

Implementation

Here is a toolkit, how it is implemented is the choice of the developer. Here are some pointers that may assist.

It may be sufficient for many to implement on Dublin Core metadata. When this is the case, no provision need be made in the CMS for maintaining the
metaterms, vocabs and schemes tables – the values provided in the appendices should provide all that is needed. If another vocabulary were identified that might be useful to a reasonable number of CMS users, this too could be added to the inserts in the appendices and no provision be made for maintaining it through the CMS.

If a form, or section of form in the CMS page maintenance area is provided for adding/maintaining metadata for pages, some fields could be pre-populated. DC.title could take the existing page title (I cannot see any reasonable situation where these would be different;) DC.identifier – the page URI – could be calculated; DCTERMS.created and DCTERMS.modified could certainly be derived automatically; DC.rights could be taken from a site default; DC.type and DC.format would generally be fixed. And the list goes on. Pre-population of fields would make the task of maintaining metadata less onerous and encourage compliance, which may be an issue in some organisations where provision of metadata is mandated.

Search facilities could be built that could identify lists of documents by author (DC.creator,) creation date, etcetera. I created an experimental metadata repository a while back – some four million pseudo-pages, each with three items of metadata. Searches on unique metadata values all completed under a second, much to my surprise. The repository used nearly the same table schemata (including indexing) presented here, so a powerful search engine would not be hard to implement for a CMS holding very large numbers of pages. I am currently unable to find the search queries I used, but will append them to the SQL Queries section, should I come across them at any point.

Sitemaps and other machine-readable (RDF) views of the repository could be generated – either as the results of search queries, or just dumps of the entire repository.

License

The contents of this document are released under the Creative Commons Attribution 3.0 Unported License. If you make use of the material presented here, I require attribution as a contributor to your work. A link back to this page would be nice, too. Yes, you can use it commercially; if you make heaps of money out of it, I'm rather partial to full-bodied reds. Hint, hint.

If you do make use of this material in your project, I'd love to hear from you and link to your project from this page.

Appendices

Appendix A

Values for the metaterms table.

insert into metaterms (vocabterm,vocab,defscheme) values
('DC.contributor','1',''),
('DC.coverage','1',''),
('DC.creator','1',''),
('DC.date','1','18'),
('DC.description','1',''),
('DC.format','1','4'),
('DC.identifier','1','17'),
('DC.language','1','13'),
('DC.publisher','1',''),
('DC.relation','1',''),
('DC.rights','1',''),
('DC.source','1',''),
('DC.subject','1',''),
('DC.title','1',''),
('DC.type','1','2'),
('DCTERMS.abstract','2',''),
('DCTERMS.accessRights','2',''),
('DCTERMS.accrualMethod','2',''),
('DCTERMS.accrualPeriodicity','2',''),
('DCTERMS.accrualPolicy','2',''),
('DCTERMS.alternative','2',''),
('DCTERMS.audience','2',''),
('DCTERMS.available','2',''),
('DCTERMS.bibliographicCitation','2',''),
('DCTERMS.conformsTo','2',''),
('DCTERMS.created','2','18'),
('DCTERMS.dateAccepted','2',''),
('DCTERMS.dateCopyrighted','2',''),
('DCTERMS.dateSubmitted','2',''),
('DCTERMS.educationLevel','2',''),
('DCTERMS.extent','2',''),
('DCTERMS.hasFormat','2',''),
('DCTERMS.hasPart','2',''),
('DCTERMS.hasVersion','2',''),
('DCTERMS.instructionalMethod','2',''),
('DCTERMS.isFormatOf','2',''),
('DCTERMS.isPartOf','2',''),
('DCTERMS.isReferencedBy','2',''),
('DCTERMS.isReplacedBy','2',''),
('DCTERMS.issued','2',''),
('DCTERMS.isVersionOf','2',''),
('DCTERMS.license','2','17'),
('DCTERMS.mediator','2',''),
('DCTERMS.medium','2',''),
('DCTERMS.modified','2','18'),
('DCTERMS.provenance','2',''),
('DCTERMS.references','2',''),
('DCTERMS.replaces','2',''),
('DCTERMS.requires','2',''),
('DCTERMS.rightsHolder','2',''),
('DCTERMS.spatial','2',''),
('DCTERMS.tableOfContents','2',''),
('DCTERMS.temporal','2',''),
('DCTERMS.valid','2',''),
('HTML.title','3',''),
('HTML.doctype','3',''),
('OTHER.description','4',''),
('OTHER.keywords','4',''),
('OTHER.author','4',''),
('OTHER.copyright','4',''),
('OTHER.generator','4','');

Appendix B

Values for the vocabs table.

insert into vocabs values
('1','DC','http://purl.org/dc/elements/1.1/'),
('2','DCTERMS','http://purl.org/dc/terms/'),
('3','HTML',NULL),
('4','OTHER',NULL);

Note the inclusion of vocabs HTML and OTHER. I have provided these so that our metadata repository can store the title and doctype of the HTML document (vocab=HTML,) and various 'legacy' metadata terms (vocab=OTHER,) if so required. If these are excluded, the corresponding entries should also be excluded from the end of the insert in Appendix A,
above.

Appendix C

Values for the schemes table.

insert into schemes (schemename) values
('Box'), ('DCMIType'), ('DDC'), ('IMT'),
('ISO3166'), ('ISO639-2'), ('LCC'), ('LCSH'),
('MESH'), ('NLM'), ('Period'), ('Point'),
('RFC1766'), ('RFC3066'), ('TGN'), ('UDC'),
('URI'), ('W3CDTF');

TinyURL for this page: http://tinyurl.com/ybgr2ds

Base Conversions in MySQL

Allow me to present dec2base() and base2dec(), a pair of MySQL stored procedures for converting to/from denary and other number bases. The examples below are for Base 53. Just add or remove characters from t_digits to change.

If you are curious about my choice of Base 53, it is because I have tried to minimise the use of similar-looking characters, to reduce transcription errors.

This code is based on an example in PL/SQL that I found on the JavaConfessions blog.

The reason for using varbinary() instead of varchar() for t_digits is that base2dec() will produce incorrect results due to case-insensitive matches on varchar().


drop procedure if exists dec2base;
delimiter //
create procedure dec2base(n int unsigned)
begin
declare t_modulo int unsigned;
declare t_int int unsigned;
declare t_val varchar(256);
declare t_char char(1);
declare t_digits varbinary(256);
declare t_base int unsigned;

set t_digits='23456789abcdefghjkmnpqrstuvwxyABCDEFGHJKLMNPQRSTUVWXY';
set t_base=length(t_digits);

if (n=0) then
select 0;
else
set t_int=n;
set t_val='';

theLoop: loop
if (t_int=0) then
leave theLoop;
end if;
set t_modulo = t_int % t_base;
set t_char = substr(t_digits, t_modulo+1, 1);
set t_val = concat(t_char,t_val);
set t_int = floor(t_int/t_base);
end loop;

select t_val as base_value;

end if;
end;
//
delimiter ;

drop procedure if exists base2dec;
delimiter //
create procedure base2dec(c varbinary(256))
begin
declare t_iterator int unsigned;
declare t_length int unsigned;
declare t_char char(1);
declare t_int int unsigned;
declare t_retval int unsigned default 0;
declare t_mult int unsigned default 1;
declare t_convval varbinary(256);
declare t_digits varbinary(256);
declare t_base int unsigned;

set t_digits='23456789abcdefghjkmnpqrstuvwxyABCDEFGHJKLMNPQRSTUVWXY';
set t_base=length(t_digits);

set t_convval=c;
set t_length=length(t_convval);
set t_iterator=t_length;

theLoop: loop
if (t_iterator=0) then
leave theLoop;
end if;
set t_char = substr(t_convval,t_iterator,1);
set t_int = instr(t_digits,t_char)-1;
set t_retval = t_retval + (t_int * t_mult);
set t_mult = t_mult * t_base;
set t_iterator = t_iterator -1;
end loop;

select t_retval as decimal_value;

end;
//
delimiter ;

In and Out of SVG

SVG

Preamble

I have been looking at SVG for some time now. Why? Because it is an open (non-proprietary) format and because it is a W3C recommendation. I like to use open standards as much as possible in my work (and would like everyone else to do the same) so SVG has always looked attractive compared to the likes of Adobe Flash and the emerging <canvas> element of HTML5. Best of all, SVG has inherent the means to be made accessible.

SVG forms the core of some visualisation tools that I am producing for a client for their Tribal Tool-Kit. The work in which I am engaged at the moment has raised some issues. This article describes those issues and how I am addressing them and constitutes "stuff I wish I had known when I started" as well as an aide-memoire for the next time I come across them. Hopefully others will benefit from this and not have to spend quite so many hours staring at Google as I did.

SVG Not The End Format

Whilst I would love to be able to render data as SVG and leave it at that, there are reasons why this cannot always be so. There's a little graphic on this page that says "SVG". It's not an SVG file though, it's a PNG. (I created it as SVG – the original is here.) Why is this? Because Internet Explorer, almost alone of modern web browsers, does not support SVG. Developers Brad Neuberg (Google Inc.) et al are working on svgweb, in an attempt to rectify this situation. However, as svgweb is only in the alpha stage of development and because I am wary of being an early-adopter (especially when my clients are concerned,) I will continue to convert SVG for the web to PNG.

My current project has PDF as an end-format.  Rather conveniently, SVG can be converted to both PNG and PDF using the same tool, rasterizer, which comes as part of the Apache Batik toolkit.  I should note at this point that the export tools that I am discussing need to run on a web server; they are not desktop applications. (They can, however, be run from a command prompt. I work on Linux, but the majority of the tools that I am discussing are available cross-platform.)

Converting an SVG file to PNG is as simple as installing Batik and running:

rasterizer foo.svg

…to produce foo.png. To convert to PDF, we need to do a bit more typing:

rasterizer -m application/pdf foo.svg

…to produce foo.pdf.

Easy, isn't it?  The current project, however, produces 7 SVG files but requires 1 PDF document as the end product.  I thought that this might complicate matters but thanks to a nice little application called pdftk, all we need to do is to convert the 7 SVG files to PDF (I'll call these doc1.pdf … doc7.pdf) and then run:

pdftk doc1.pdf doc2.pdf doc3.pdf doc4.pdf doc5.pdf doc6.pdf doc7.pdf cat output mydoc.pdf

…where mydoc.pdf is a concatenation of doc1.pdf … doc7.pdf.

Caveat

This may sound easy – and it is. The caveat, however, is the fact that it isn't necessarily quick.  If you are rasterizing SVG on a a web server, assume that this process will have to run asynchronously and notify the end user that they may have to wait a bit.

Oh, and if anyone feels that there is something wrong about creating PDFs with a tool called 'rasterizer' when PDF isn't a raster format, yes, it's weird. Ignore it; it's just a name.

The Branding Problem

The PDF document that I am creating from that bunch of SVG files is a report. It needs to be branded with logos. Fair enough. You just go to the graphic designer that created the logos and ask for them in SVG format. Possible, if they were created with the likes of Adobe Illustrator. More likely, this is not the case.  Odds are that you will end up with a raster format such as TIFF or – if you are especially lucky – with encapsulated PostScript (EPS.)  Let's deal with the raster formats first.

We can put an external image into our SVG easily enough:

<image xlink:href="http://www.smiffysplace.com/img/png.svg"/>

If we were odd enough to want to put a rasterization of an SVG file into another SVG file, that is.

When rendered, this all looks OK – until we try zooming in on the image. Those parts that are pure SVG will scale and scale and scale – and still be as sharp as at 1:1 magnification. The raster graphics, however, will become horribly pixellated and very 8-bit looking. (That's a joke for those who used to have Sinclair, Commodore, Atari and the like home computers.)

If there is no choice but to use raster graphics, the trick is to start with an image larger than you require and scale it down using the width and height attributes of the image element.  Doing this means that you should not start to see pixelisation until you have zoomed past the original size of the raster graphic.  For example, if the raster graphic is 200×200 pixels and we size it to 50×50 pixels in the SVG, it should look fine until we magnify the SVG beyond 400%.

But we're lucky enough to have EPS. Why's that lucky? What's so great about PostScript? What's good here is that we can convert to SVG without loss. Once we have our logo as SVG, we can just pop it in the <defs></defs> section of our SVG, job done.

To convert EPS to SVG, the first thing we need to do is to download and install the Open Source Desktop Publishing  (DTP) package, Scribus. Then:

  1. Start Scribus.
  2. When a dialogue pops up, select the tab 'Open Existing Document'.
  3. In the file selector, change File type to: PostScript(*.ps *.PS *.eps *.EPS)
  4. Select your EPS file, then OK.
  5. Scribus will prompt you for a file name for its native format. Put in something appropriate or just accept its suggestion.
  6. Remove any unwanted bits in the document now showing.
  7. From the File menu, select Export, then Save Page as SVG.

You will now have an SVG file with your desired logo in it. There's a fair chance that you have a little logo sitting all alone in the corner of a big SVG. If this is the case, change the height, width and viewbox attributes of the SVG element to suit. Tip: if you don't know what size to use, rasterize the SVG, open the resulting PNG in an image editor such as the GIMP, where you will be able to see/measure the part of the image you want.

Update

I thought I had a working TIFF to SVG technique, which I posted here briefly, which used Open Office Draw as a step to creating an EPS. However, whilst this appeared to work, I found that the SVG file created had an embedded PNG of the original image in it! I will continue my research and post any updates here.

Notable Mention

There is one Open Source SVG tool that I did not use for this project but is worth a mention: Inkscape. I appreciate that not everyone likes to create their SVG by hand, as I do, so Inkscape makes a good tool for an introduction to the wonderful world of vector graphics.

Conclusion

There is generally more than one way to do a job. What I have described in this article is how I export from and import to SVG.  Google Is Your Friend – have a look for alternatives and see what you can learn in the process. (Anyone trying to concatenate PDFs using GhostScript should be warned, however, that it trashes embedded raster graphics.)

Have fun with your SVG!

Dear Oracle…

Dear Oracle Management

Allow me to congratulate you on your prospective purchase of Sun Microsystems (regulators willing.)  The potential synergy of your business methods and Sun's products is quite awesome.

Another thing that would be quite awesome would be if you were to allow the use of your database and tools under the same FOSS terms as Solaris, MySQL, Java, Glassfish, and friends.  As a small, independent, developer I would love to integrate your products that have, to date, been outside of the financial reach of both myself and my clients. In doing so, I would be able to help increase your market penetration.

I hope that the acquisition goes smoothly for you.

Sincerely yours

A. Developer

Smiffy’s Random Tech Tips

Preamble

(Listen carefully, I shall say this only once!)

Every now and then I feel a need to communicate various little technical tips that stem from my work or stuff that I observe on the web.  They rarely get written up because they tend to be too short to justify an article on Smiffy’s Place and, now that I am using Twitter, too long to fit into a silly 140 character limit, even when written in Newspeak and with ridiculous abbreviations.

Today I decided to start making collections of these as draft articles, publishing those articles when I felt that I had enough to make it worth anyone’s while to read them.

The number of tips per article is something on which I am, as yet, undecided.  Somewhere between 3 and 10 sounds sensible to me, so I may well just stick at that.

The First Tips

(X)HTML authoring – the Joy of Comments

Add comments to the end of block-level elements with IDs so that you can see what you are closing and pick up any orphaned </div>s, etcetera, that are stopping your code from validating.  (This can also apply to classed elements.)

This can also help other people working on the same project keep track of what you are doing, say you are writing backend code and someone else is doing the styling.  (Documenting your IDs and classes can save others on the project much frustration and puzzlement.)

Unless you have a specific reason to retain them, comments may be removed easily using regular expressions or other pattern patching. Note that superfluous comments can contribute to the overall weight of a page and thus slow down your site for visitors and also eat into your bandwidth.

Hardware repairs, modifications – Use a Camera

Where hardware can be anything from laptops to washing machines to cars to X-Wing Fighters.

In addition to the tools that you would use regularly, have a digital camera on hand and photograph every stage of disassembly, especially if you do not have a manual.

I recently had cause to disassemble our wheelbarrow so that it could be stripped of its defective powdercoat and painted.  There was a gap of a couple of months between the disassembly and the painting/reassembly.  Without the photographs that I took, I would probably have a very strange-looking wheelbarrow now.

The “use a camera” tip can also extend to excavations.  If you are building or renovating a house (shed, office, bat cave, whatever,) photograph all trenches where pipes and cables run, from several angles.  This can be very helpful in the event of any future excavations, fencing work, etcetera.

Don’t forget to file your images where you can find them again (tagging with Picasa can be useful,) and make sure that they are backed up.

Pressure pumps – the Peril of Snails

This one’s a bit obscure – mainly applies to rural Australia.

If you have an outside electric pump on rainwater (or other) service which has not been run for a while, remove the fan cowl (with power disconnected!) before operation to check for infestation of white snails.  These may or may not cause the pump to jam, but should be removed anyway.  Also check that the pump is primed and any inlet valves are on before starting.  And put the fan cowl back.

JavaScript – JSLint

If you are working with large chunks of JavaScript (ECMAScript,) you may wish to consider validation using JSLint.  You may also wish to consider checking that you are using good programming practices: always declare your variables, comment your code, don’t try coding when you are too drunk, etcetera.

Conclusion

There you go, just a little taster.  More will follow, sometime.

TinyURL for this article: http://tinyurl.com/d3jdqb

follow-u-tron

Automating #followfriday

This little programme allows me to manage a list of people that I follow on Twitter whom I feel that others might also to follow as well. When invoked without any parameters, it will draw a random name from the list and post a #followfriday message to Twitter.

The idea is that I just maintain the list and have this running on a cron job every Friday. Picks are random so the same person may be picked more than once in a row.

Thanks to @elpie for reminding me of what day Friday is in cron-speak!

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License. Use it at your own risk, don’t blame me if it eats your computer, causes a Global Economic Meltdown (too late, someone’s already done that, thanks GWB,) etcetera.

The Code

Several attempts were made to copy and paste the code into this article; TinyMCE stuffed up the formatting every time, eating a load of essential backslashes. Rather than convert the whole thing to HTML entities by hand, I’ve given up and have just posted it in my files section.

Usage

Adding Members

follow-u-tron.pl @user1 @user2 @user3

Deleting Members

follow-u-tron.pl -@user2

Note that you can add and delete in the same command.

Listing Members

follow-u-tron list

Posting to Twitter

follow-u-tron

This may be put into a cron job.

Ada Lovelace Day – Women in Technology Whom I Admire

It starts thus:

“I will publish a blog post on Tuesday 24th March about a woman in technology whom I admire but only if 1,000 other people will do the same.”

this being from coffee.geek.nz

I am fully aware that the technical sector – whether it be IT, engineering or medicine (which I consider technical) – has always been very much a “boys’ club” and am embarassed to be a part of such a misogynistic industry.

Whilst I admire what Ada did (writing programmes without a computer is no mean feat), I would like on this occasion to recognise 3 women of my own acquaintance. They may not be Big Names, but they are just some of those that I can name whom I consider worthy of respect:

  • Leah MACLEAN. Leah is a technology veteran, having worked for Telstra, Australia’s national telco. Leah now provides technology services and understanding to her clientelle (primarily women in small business) as Working Solo.
  • Liddy NEVILE. Liddy Nevile is an Adjunct Associate Professor in the Advanced Computing Research Centre at La Trobe University. I know Liddy as the drive behind OzeWAI web accessibility conference and a member of the Dublin Core Metadata Initiative.
  • Lynne POPE – head honcho of the Mambo CMS project and another technology veteran. A serious Mover and Shaker in Open Source software development.

There are others that I could mention of my personal acquaintance and of no less merit, all just going about their jobs despite the frequent discrimnation that they face. (They not only have to be good at their jobs but also able to survive being Eaten By Trolls.)

Please, let’s just shed the obnoxious attitudes that make the technical world a hostile one for women and rid ourselves of any stupid ideas of women being less able in this – or any other – field.

And yes, I know that this article is over a month early but, by writing it now, at least I know that it will get written.

Shortened URI for this page for Twitter users and the like: http://tinyurl.com/bqmjzk

Here is a list of Ada Lovelace Day posts from others: http://ada.pint.org.uk/

The Solstice Clock – Part 3

schematic of solstice clock prototype
Solstice Clock Schematic

Solstice Clock Circuit Design

In part 1 and part 2 of this series, I started to describe my concept of a Solstice Clock and some of the design parameters. This post is just a brief note to present the circuit schematic for the clock motor driver and the corresponding circuit board layout.

Minor Changes

I have made a minor change to the circuit as described in the previous article. The circuit now includes an 8-way DIP switch rather than a 4-way one. The reason for this is to provide a means by which the length of the pulses driving the clock motor may be controlled. Too short a pulse and the clock may not tick or – even worse – tick intermittently. Too long a pulse and excessive power is consumed. Whilst I do not see the solenoid or microcontroller getting burned out, a reduction in battery life would occur.

In a production environment where only one type of clock mechanism is being used, it is possible to find a pulse length that works with all members of a batch of mechanisms and set the pulse length in the firmware. For prototypes however, especially when different mechanisms may be used, the ability to change the pulse length without re-programming would appear to be most appropriate.

Board Layout

Solstice Clock Board Layout

The image of the board layout presented here is – theoretically – 1:1 scale. It is on my computer but I have no idea how other web browsers may mangle it. For those in doubt, it has about the same footprint as a box of regular safety matches. Before you say "whoopee, isn't it small?" I would advise that this is just the controller board. Somewhere in the back of the clock we need to fit in a pair of AA cells to power the thing. These may be either in two single holders (might make it easier to fit in) or together in a side-by-side holder.

The Solstice Clock – Part 2

Preamble

In Part 1 of this series, I outlined my concept of a Solstice Clock. Since writing the original article, I have modified a regular quartz clock and have estimated the requirements to drive it.

Simplification

My original drive circuit was rather complex – excessively so. Having now reconsidered the requirements (for instance, removing the facility to set the time via a serial data connection) and calculated the drive requirements of the clock solenoid, I have found that a minimal implementation of a Solstice Clock could consist of no more than a microcontroller, timing components a couple of BAT54S dual diodes (protection for the 2 port pins connected to the solenoid) and that's about it.

This more minimal system would use less power (runs on a pair of AA cells – the original would have required 4 or 5) and also fit into far less space than the original. The latter consideration could be important if there is little space in the back of the clock for modifications.

Choosing a Chip

Whilst the very minimal version could be implemented with an Atmel ATTiny45 – making for a very small circuit board – I have decided to make my prototype with a little more flexibility which requires more than the 8 pins of the ATTiny45 and have thus selected the ATTiny2313V. The 'V' is significant – this lower-powered version of the device can operate right down to 1.8V with a clock frequency of less than 4MHz or 2.7V with clock frequencies all the way up to 10MHz.

After playing around with a spreadsheet, I checked some crystal values to see what gives the most accurate results. Actually, it wasn't quite that way – I first looked on eBay for cheap job-lots of crystals in the 3Mhz to <5Mhz range and then ran those through the spreadsheet to find the ones most suitable. I now have batches of 4.9152MHz and 3.579545MHz crystals to play with. There is a trade-off between the time resolution that I can obtain and power consumption; the higher the clock frequency, the better the resolution, but the higher the power drain.

More than just the Tropical Year

My original plan, when I was thinking of controlling the clock through a serial interface, was to be able to vary the 'tick' rate to allow for differing year lengths. Whilst I am now using a mean Tropical Year (so a fixed length), I realised that it would take little effort to provide other mean periods that the clock could operate on. The final list is this:

  • 1 Tropical Year
  • 1 Synodic (Lunar) Month
  • 12 Synodic Months
  • 13 Synodic Months

These 4 periods would be selectable by two positions of a 4-bit DIP switch. This leaves me with 1 switch to control stop/run and another switch reserved for future use.

Setting Up

I have discovered – somewhat to my annoyance – that most quartz clocks provide a means of setting the hour and minute hands, but not one for setting the position of the second hand. As this hand is representing far more substantial periods of time in my slowed-down clock, I have decided to provide the means of setting this hand through the electronics. The stop/run switch will be set to stop, then a push-button held down until the second hand is at the appropriate position. The hour and minute hands would then be adjusted by the regular twiddler on the back and the stop/run switch set to run when ready.

Moving On

In the next article of this series are presented the circuit schematic and board layout of the Solstice Clock prototype.