Archive for the 'Open Source' Category

Version control for websites

Thursday, December 8th, 2011

By Andrew Smith

I was always a fan of version control, even for binaries like word file for homework. This helps keep a history of stuff that may get deleted or changed, and helps a lot for working using multiple computers.

But I’ve never version controlled a website. Mostly because I never had one I was doing serious development on. In fact several of my websites were made using the Seamonkey editor once, uploaded to the server, and never touched again.

This project is different though, there will be a lot of serious code in it. Why not version control it? I decided to do it.

I had a Subversion repository for the project already, and in there I created a subdirectory for the stuff that will go on the server. On the server I checked out that subdirectory into the root of the webserver, as ‘ostd’. Then I added and committed all the php and css and images. Done!

Now I just have to remember to do commits when I’m done working on a feature or will be away from the project for a few days.

Making a good looking website

Thursday, December 8th, 2011

By Andrew Smith

I am the first to admit that I’m almost completely incapable of making something look good. I’m reasonably good at making things functional and easy to use, but when it comes to looks.. not me.

At first I thought I would start with just plain black and white PHP output, but I felt that was going to be a significant problem when trying to attract interest, even early in the project. Also I wouldn’t want to find out two months in that I should have written a Wordpess skin rather than my own PHP.

So then what to do?

I quickly discounted WordPress. I have several Wodpress installations and the maintenance is a nightmare. New versions come out all the time, most of the time there have been security bugs fixed so an upgrade is required, but constantly upgrading a WordPress installation and making sure that the new version still works was too much.

Then I looked around for website templates. There are actually quite a few websites with free templates on. I chose one from http://www.webtemplateocean.com/ – it’s licenced Creative Commons Attribution, that worked for me.

Then the template (one html file, one CSS, and a bunch of images) needed to PHPified. Basically that means to split the body into three parts – top, body, and bottom. The top and bottom are the same for every page, so they can be printed from PHP functions. The body can be different for every page.

I was quite happy with the result. My index.php has basically nothing in it other than the content of the main page, and the same is true for all the other pages.

I will add a link to the website once it’s a little more cleaned up, in a later post.

Starting a Project

Thursday, December 8th, 2011

By Andrew Smith

I have a long list of ideas. Why have I chosen OSTD? Well – it had to be something I was passionate about, and I am always proud to tell people that my software is translated into 40 languages. I would love to be able to say that with my help hundreds of other software was also translated into many languages.

Then I needed to make a balance between time/patience/skills required and those available. I know what I can do and I know what I can learn but how much time and patience I will have is a more complicated question.

To help me with that I made a list of use cases, which I’ll call ‘features’. With my understanding of the technology – given the list of use cases I could figure out whether this is doable in reasonable time. The feature list also helps when choosing what to do next and how to structure a database.

An overarching concern is – will people be interested in using this service? That question is just as relevant whether it’s an open source project or a commercial venture. I coulnd’t see the answer, so I had to take a leap of faith before finally deciding to go ahead. After all, if it were obvious that it would be a success, then someone would have probably done it already. I’m hoping that a leap of faith is necessary when taking on something new and exciting :)

Project Name

Thursday, December 8th, 2011

By Andrew Smith

OSTD, the Open Source Translation Database – that’s the best I could come up with. The name and the acronym has to be unique enough that I can get to the top of search engine results relatively easily. But there’s so much more to the name.

At first I wanted to get the website a proper domain name, but then I counted how much it would cost and that discouraged me. Between the registration, the dynamic DNS, and the SSL keys I would have to spend over 100 dollars a year on it, which I’m not willing to shell out.

The name has to be memorable and guessable. What would people search for if they wanted a service like mine? If they found it once, would they remember what it was called?

It can’t sound geeky. I have a personal problem with 1337.

It shouldn’t sound too stupid either.

There shouldn’t be conflicts with things like sexually transmitted diseases. Frankly I have no idea why ostd.org exists, my best guess is that std.org was not available. But ostd is different enough from std, so I let that fly for now.

But hey – if you have a better name idea – please share, I’m quite open to changing it at this early stage.

OSTD: Open Source Translation Database

Thursday, December 8th, 2011

By Andrew Smith

I have an ideas list, a sort of todo list for when I have time to burn. One of the ideas on my list is a website that can help authors of open source software to translate their software into languages other than english. I have recently agreed to teach part time at Seneca and also I decided to take a break from looking for a full-time job for a couple of months. Which means I have time to burn :)

There are similar strings in many pieces of software, so theoretically if it’s translated in SoftwareA it should be easily translatable in SoftwareB. In practice however this is not the case. It is impractical for a project maintainer to find strings in other software that will look like his own. In fact in most cases it is difficult to even find the pot/po files in existing software because there are so many version control and release systems.

So the core of my idea is a database of existing translations that can be used to automatically translate some strings in new software. The open source maintainer would submit a .pot (template) file and get back partially translated .po files in a bunch of languages.

Over time this website can be expanded to provide general internationalization (i18n) advice, advice for which english strings to pick which the service will translate more easily, a network of translators who may be interested in volunteering to help a particular project, etc.

I’m going to try and record in this blog the issues that come up with designing, building, and marketing this website. That shouldn’t be much of a problem since I don’t have a hope in hell of ever making money from this project, it’s just community service :)

How I almost switched to Ubuntu

Friday, June 24th, 2011

By Andrew Smith

Lat week I got a fancy new printer. I was trying to find something that will work for years and years so I shopped around for a couple of days.

The shopping experience was pretty painful. It’s very difficult to find whether a printer is actually supported in Linux before buying it and trying it out. Still, at the end of the second day I picked an MFC-7860DW – a solid all-in-one with a good feature set and apparently (not clearly though) supported on Linux being a Postscript printer.

On Windows the thing worked pretty much out of the box – pop in CD, have it detect the printer on the network, click install, print. Not on Slackware :)

On Linux I quickly got confused by all the terminology. There on the Brother website for this printer is an LPR driver, a cupswrapper driver (both in rpm/deb formats only), and generic install instructions. Also here and there I found references to brscript, which made me suspect this isn’t actually a real postscript printer.

I extracted the files from the .debs, copied them manually to the destination, and looked at the post-install scripts and ran the commands manually. Printer driver was added successfully to CUPS and I could add the detected network printer, and I could even print a CUPS test page successfully, but nothing else would print. Everything else would come out as pages and pages of garbage.

After many hours of beating my head against the keyboard I installed Ubuntu in a VM and installed the brother deb packages in there and after a minute of fiddling with cups – printing worked, including two-sided (duplex) printing.

This was a particularly busy week for me and I snapped, I could no longer justify spending so much time installing a printer and I figured maybe it’s time to switch to Ubuntu, and I did.

Thankfully though it wasn’t long (less than a week) until I remembered why I was a Slackware user in the first place – it’s conservative, stable, and doesn’t modify upstream packages. Every day I found something in Ubuntu that would drive me crazy. Parts of the screen would be blacked out after resizing certain windows (crazy driver bug maybe, but it worked in Slackware), my USB mass storage phone (with worked in Slackware) would sort of mount when I clicked on it in Thunar but the contents would not be displayed, and the final straw was grub2.

Don’t get me wrong, I’m all for usability and also I appreciate that sometimes something old needs to be dropped so something new and better can take its place. But it seems to me that grub2 doesn’t fit either of those parameters. It is absolutely a monster to configure (just try to change something simple like the boot timeout if you don’t already know how to do it) and doesn’t give me any benefits as far as I can see. On the web someone suggested a GUI program to configure GRUB2 and that’s when I decided to hell with it. If you’re going to require a GUI program to configure a boot loader – you better bloody make sure it’s installed and accessible by default.

So I switched back to Slackware (Ubutnu was on a separate partition of course) and having a little more patience and a fresh mind I just used the generic postscript driver, which worked, which is why I bought a postscript printer in the first place :)

I wrote it up in case someone else will look for info about this printer on Linux, I will extend that guide when I find more about using this printer’s features on Slackware.

The end of an era

Thursday, April 14th, 2011

By Andrew Smith

Today I wanted to make some yummy apple puff pastry, so I turned my laptop on to put up a recipe and.. the screen blipped and went off. This machine (an IBM x40) was so old that I wasn’t at all surprised. The laptop went with me through school (when I rode bicycles and buses and subways), several jobs (more subways and driving), came with me on planes and Sudbury trips, has been used by my mother for about a year, and for the last year or two has been sitting on my desk, with a monster work laptop squashing it (which was probably what killed the screen).

With little hope and mostly our of boredom I took the keyboard off. To do this I used the skills I acquired in my last career as a computer technician, when for some time I worked for IBM fixing up used laptops. Like many IBM laptops this was a wonderful machine. Not only is it solid like a rock but it’s easy to take apart, and inside, after years of beatings.. it looked like new!

I am telling you I have never seen a used laptop this clean – both literally and in terms of design and construction. I was going to look for loose or damaged cables or mechanical pieces – yeah right! Everything was shiny, orderly, and in its place. Unfortunately I saw the image was still being displayed, just not backlit. Yep, laptops like this we sent straight to the scrap pile because the screen cost more than the rest of the parts put together. I felt a little bad at this point (what a nice computer) but whatever, it lived a good long life.

As a sign of respect for the machine and the engineers who built it I put it back together in preparation for the scrap yard, then I thought of giving it a burial (which obviously wouldn’t work), then I thought of getting it some flowers (I’m not kidding), and then I realised why I had such trouble letting go and I almost cried..

The problem was not letting go of that laptop! The problem was that I wasn’t going to get a replacement laptop, the problem was that those days are over. I have an Android phone which does almost all that the laptop used to do. There is this concept of a laptop dock (check out the Atrix) which would serve for the rest. I’m not going to go buy a new laptop, hell I don’t even want one for free.

This reminded me of the end of my last career. About eight years ago I decided that a computer technician is not a career with a future and I took a leap of faith, going back to school to become a software engineer. It was a good decision and I think it paid off but it has not been long enough, I am not yet ready to switch careers again!

Yes, computers are as common as ever and there is a new world of mobile devices that promises a few more years of prosperity for software engineers like me, but I wonder if I’m already seeing signs that software is becoming a commodity by default.. and then what? Will I end up like one of those guys I was laughing at in school, “maintaining” (pretending to do work on) a Cobol program on an IBM mainframe, but with slightly newer technologies? How ghastly..

And even if there are still going to be new and exciting things to do for software engineers – what about me? Will I be able to learn the new tools, or is my brain over full with things that no longer matter?

Life is sad.. but I guess that’s the cost of progress, older farts like me have to get off their asses and relearn everything or let the next generation take their place. Well, I’m not the type to give up without a fight so bring it on kids :)

CreateProcess for Linux

Thursday, January 20th, 2011

By Andrew Smith

Do you remember the first time someone told you about fork()/exec() for Linux? Do you remember beeing completely confused? I do, and it’s an ongoing pain in the ass for me – every time I want to call something simple without blocking and without worrying about pipes or the structure of exec()/execl()/execlp() parameters, or the return of the fork() call.

Finally I had enough and wrote my own CreateProcess function. It will seem trivial for any Linux C programmer, but in my experience it’s not simple enough. This or something like it should have been part of the standard library, just like printf() is.

Feel free to use it for whatever you want, minding the GPL v2 licence:

/******************************************************************************
*   CreateProcess
*
*   Copyright (C) 2010 Andrew Smith
*
*   This program is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, version 2 of the License only, not
*   any earlier or later version.
*
*   You should have received a copy of the GNU General Public License
*   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/******************************************************************************
*  CreateProcess function: a simple way for Linux/Unix to call programs
* without blocking and without the complications of fork()/exec() which
* normal people shouldn't need to understand :)
*
*  Usage example:

#include "CreateProcess.h"

int main(void)
{
    // Call it like this:
    CreateProcess("ls", "-a -l --sort=size");

    // Or like this:
    CreateProcess("date", NULL);

    // Note that the second call does not wait for the first to finish
    // as system() would

    return 0;
}

* Enjoy!
* - Andrew Smith
*/

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>

pid_t CreateProcess(const char* command, const char* parametersIn)
{
    const int maxNumArgs = 1024;
    const char* args[maxNumArgs];
    char* parameters = NULL;

    memset(args, 0, (sizeof(char*) * maxNumArgs));
    args[0] = command;

    if(parametersIn != NULL)
    {
        parameters = strdup(parametersIn);
        int strLen = strlen(parameters);

        int numParameters = 1;
        bool expectNextParam = true;
        int i;
        for(i = 0; i < strLen; i++)
        {
            if(parameters[i] == ' ' || parameters[i] == '\t' ||
               parameters[i] == '\n')
            {
                expectNextParam = true;
                parameters[i] = '\0';
            }
            else if(expectNextParam)
            {
                args[numParameters] = &(parameters[i]);
                numParameters++;
                expectNextParam = false;
            }
        }
    }

    pid_t pid = fork();
    if(pid == 0)
    {
        execvp(command, (char**)args);
        _exit(1);
    }

    if(parameters != NULL)
        free(parameters);

    return pid;
}

Two years of uptime

Sunday, January 9th, 2011

By Andrew Smith

Check this out:

andrew@littlesvr:~$ uptime
00:20:16 up 730 days, 15:13,  1 user,  load average: 0.57, 0.22, 0.11

At 4AM this morning it was 730 days, that’s exactly two years!

The server would have been up for about 6 years if I didn’t decide once to upgrade the hardware, once to upgrade Slackware, and once to be hacked :) Ok that last one wasn’t a conscious decision, and it may happen again since I haven’t ever figured out what the vulnerability was.

Yeah, this little box has been running for this long, and yes, it does have spiderwebs on it. I didn’t take them off when I saw them because that is so cool and since I have no fans they really don’t cause any trouble.

The server is sitting on a UPS that I bought years ago. Today I tested it by cutting the power, expecting that it will die immediately. I was pleasantly surprised to see that the server (and DSL modem and hub) were still on after the 5 minute battery test. I didn’t want to test it for longer than that because I remember the spec for the UPS said 8 minutes, and I wonder if maybe a year from now I’ll be celebrating a 3-year uptime anniversary :)

Maybe in a year or two I’ll replace it with a faster, fancier, even smaller Arm box like one of those Chris Tyler is playing with. But for now I have no need.

Unfortunately my Slackware upgrade came with an Apache upgrade which means the log formats are different between the two periods, so I can’t say how much data has been transferred, but this webaliser screenshot will give you an idea of what’s typical:

(for the observant ones: legrand-sw is the workstation where I ran webaliser on the littlesvr logs)

That’s roughly 240GB of data uploaded per year (caching is on by default), and 9600 unique visitors per year.

I think it’s pretty good for a tiny hobby web server on a residential ADSL connection serving hobby content :)

And of course this is not just a web server but also my email server, which I don’t have stats for but it’s the only email I really use. With any luck it will also become an LDAP server, if I can set it up so that it’s compatible with Thunderbird and easily updateable.

Long live Slackware!

What’s digital broadcasting got to do with animated images?

Friday, January 7th, 2011

By Andrew Smith

I just finished my master’s so I’m allowed to quote Wikipedia again :)

In 2008 WorldDMB adopted APNG as a backward compatible extension to enable animation as part of the MOT SlideShow user application for Digital Radio. “APNG 1.0 Specification – Animated Portable Network Graphics” is included as normative Annex A in the ETSI standard TS 101 499 V2.2.1 (2008-07). In 2010 Commercial Radio Broadcasters in Sydney began to include APNG animations in DAB+ digital radio broadcasts. These APNG animations are carried by the “MOT slideshow” application which accompanies the audio services. It is expected that other cities in Australia will follow in early 2011.

That’s noteworthy because as far as I know they are the first real users of APNG. Mozilla has been using it for a long time and there are several decent applications that work with APNGs, but there has not to date been a solid creator of Animated PNGs.

I don’t know what a DAB+ digital radio broadcast is (and I don’t really care), but this is really cool!