Friday 12 December 2008

Learning Perl

I'm currently reading the book 'Learning Perl' and I have to say its a really well written book. It teaches the Perl language superbly and the exercises at the end of each chapter are detailed enough to give you a chance to try out the concepts learned in the chapter while at the same time being succinct enough to keep the reader interested.

As far as Perl is concerned, I think I may have found my newest scripting language. For someone that does most of their programming in Java and having only tried Ruby briefly, Perl comes as a revelation. That a language can be so optimized, to enable the programmer to translate his thoughts as quickly as possible into code is a powerful concept.

I originally started learning Perl as a part of a project at work. We have to make a program to parse an email and classify it as a 'bounce' or a legitimate reply. Stephen, the guy I work with, wrote a parser from scratch in PHP. I'm hoping to make use of one of the Perl modules available, such as the 'Email' module I found after a quick google search.

The other project I was hoping to make use of Perl for was on my home file server. I have a lot of music files on there and I have a suspicion that a lot of space is wasted because of duplicates. I was thinking of writing a program to scan a directory and make a simple database of every file and its MD5 hash. Then comparing these hashes and giving a report on the suspected duplicate files. This seems like the kind of job that Perl would be perfect for.

Thursday 13 November 2008

Asterisk web GUI doesn't work

After the last post where I thought asterisk was pretty much set up, I was really disappointed to find I couldn't for the life of me get the web gui to work properly. By this time however, I knew all about how to get the zaptel driver configured and running properly, so we went back to the machine we set up following the guide here. After restoring the backup I found that the driver didn't work properly, but that was fixed by just compiling and installing it again. Then going into the asterisk command line, we still didn't have the 'zap' commands. After searching around I finally found that it was due to the asterisk people renaming everything to do with zaptel to DAHDI (Digium Asterisk Hardware Device Interface). So now that we got that working its just a question of getting the correct configurations and the correct rules set up. So, hopefully another day or two should sort it.

Tuesday 11 November 2008

Asterisk on a debian box

The job I'm currently doing at the moment is trying to set up a VoIP/PBX box which sits on the network and basically routes all local calls through the PSTN and routes all international calls through a VoIP provider (kind of like Skype). So the idea is that you save money on international calls by not having to use the telco's network.

So the idea was pretty good, and it seemed that the Asterisk software was pretty mature, but I did run into some problems. The first time I tried setting this up I tried downloading, compiling and installing the zaptel driver and the asterisk software manually. This led to some kind of error where no matter what happened Asterisk could not see the telephone cards. Although, for some reason the web interface working on top of Asterisk could.

But anyway, the way I finally got it working was to download and install the zaptel source code for the drivers from the debian repositories and then compile the driver. Apparently you can't get pre-compiled drivers from the debian repo's. The package itself (zaptel-source) had a dependency on another package called 'module-assistant'. After installing the zaptel-source package through apt, I compiled and installed the package using the command 'm-a a-i zaptel' i.e. 'module-assistant auto-install zaptel'. This managed to install the drivers properly. Then, I installed the asterisk version in the debian repository as well by just running 'apt-get install asterisk'.

Tomorrow, I start configuring the asterisk installation.

Thursday 4 September 2008

W3Schools HTML and XHTML tutorials

I just finished going through the W3Schools' HTML and XHTML tutorials. HTML is one of those things that I know, but have never really been a master in. I guess that has to do with the fact that the only time I was actually taught html was in high school. At university we did get a few snippets here and there (I remember Ulrich teaching us CSS) but in general we didn't learn it.

Going through the tutorials was interesting if only because it gave you a nice idea what can be done with just pure (x)html. There are a lot of things I thought were quite new and novel, part of the web 2.0 thing, that I now realise were around for a while. I also really like the reference section and the link to the W3C validators. I'm gonna try to validate any websites I write against those validators from now on.

Wednesday 3 September 2008

Useful (X)HTML Tags

There are some HTML and XHTML tags which are really useful that I hadn't heard of until recently having a look at the W3Schools tutorial on HTML

The <pre> tag defines preformatted text (i.e. text which preserves spaces, new lines etc..) This can be useful if you have some text whose properties you want to keep
for int i = 0 to 10
print i
next i
The computer tags
Then we have a whole bunch of tags dedicated to displaying computer code and related artifacts. Tags like code (for computer code), kbd (for keyboard input), tt (for teletype text), samp (for sample text) and var (for computer variables. As far as I can tell, all of these, with the exception of the var tag, simply output the text in a monospace font while preserving the formatting (new lines and spaces). The var tag outputs slightly larger text which is bold and italic.

The address tag
The <address> tag is used to display addresses, such as the following

Donald Duck
BOX 555
Disneyland
USA

Actually I don't know why I put this one in the 'useful' category, I haven't really seen it used much at all and it doesn't seem too useful to me anyway, but you never know when it could come in useful

The abbreviations and acronyms tags
I really liked these tags and in fact it's a shame they don't get used more often. Especially in the Computer Science/IT fields. I can't remember the amount of times I've been reading an article, tutorial, job description and had to google a acronym or abbreviation in order to figure out what's being talked about.
e.g. <abbr>
UN

e.g. <acronym>
WWW
As you can see, they're kind of like the 'alt' tag of an image or a link.

The bdo (bi-directional override) tag
This has to be the coolest, least used feature of html. Essentially this tag allows you to display text backwards. By putting some text between <bdo dir="rtl"> and the closing bdo tag, the text is reversed.

This text should display backwards.1234567890

Saturday 16 August 2008

Multi Boot Linux and OpenSolaris

In this post I'll describe how I set up my laptop to be a multi boot environment with OpenSolaris, Ubuntu, Fedora and OpenSUSE.

UPDATE: This guide was created when almost all Linux distro's were using GRUB as their boot loader. Recently there has been a big move to GRUB2 and the following article needs to be updated.

First of all we need to know some things

1. You can only have up to 4 primary partitions on a hard drive
2. A linux swap partition has the same identifying code as a Solaris partition. This means that linux systems will see the partition as a swap partition. It also means that in order to install OpenSolaris any linux swap partitions should come after the Solaris partition.
3. Due to using ZFS, OpenSolaris uses a modified version of GRUB.

Preparing Partitions:
The way I set up my partitions is as follows


The first partition is very small and will be used at boot time to show a menu selecting which OS to boot. The second partition is the OpenSolaris partition, its being recognised as a swap partition by gparted. Then we have one large extended partition, which holds a partition for swap and then seperate partitions for each flavour of linux. The 20Gb partition at the end of the extended partition holds data which needs to be accessible by all OS's and I have left some free space on the extended partition, in case the data partition needs to grow or I feel like adding another OS.

After setting up the disk like this, go ahead and install OpenSolaris on the second partition. Solaris will write to the MBR (Master Boot Record) of the drive and point it to the grub install on its partition. Next install Ubuntu and make sure that when it comes to the partitioner stage of the install choose to do a manual setup. Choose to use the smaller swap partition on the extended partition as the swap, do not use the OpenSolaris partition as swap. Also use the first ext3 partition on the extended partition as the root partition i.e. '/'. Also you must specify to the Ubuntu install to install grub to the root partition, not to alter the MBR. At this point when you reboot your computer you will still only get the OpenSolaris grub menu, because we haven't altered the MBR.

Next we have to pop in a linux live cd, copy over the /boot/grub directory from the Ubuntu partition onto the first partition on the disk, modify the menu.lst file and then set up the MBR to point to it. This is called setting up a dedicated grub partition and is described better here. For the Linux partitions I used the 'configfile' directive in grub's menu.lst, however because grub can't see the OpenSolaris partition, for the OpenSolaris entry you have to use the 'chainloader' directive i.e.

title OpenSolaris 2008.05
rootnoverify (hd0,3)

chainloader +


Installing Fedora and OpenSUSE, we follow the install, making sure that we install them to the correct partitions, and specify that they shouldn't use the OpenSolaris partition as swap, but instead use the other one and that they don't install grub to the disk MBR, but only install it to the local partition. Then we have to modify the menu.lst file on the dedicated grub partition to point to the new OS's we've just installed.

And that's it. We now have a multi boot computer consisting of OpenSolaris and three different flavours of linux.

Monday 28 July 2008

Update - 4 months later

So I was looking at the post I made about 4 moths ago here, talking about my plan to become a decent web developer. Here's the situation at the moment:

Step 1: Wiring up my house. Still not done, however becoming more possible now that my boss offered me the use of the company account to order components (ethernet cables & accessories) for practically wholesale prices.

Step 2: Domain name. Got one, from dyndns.org. Website can be found at srdan.ath.cx

Step 3: Learning about webservers, file servers, ssh servers, nfs servers, ftp servers, proxies etc... Going quite well. Work is helping in this respect, have had to rebuild a webserver recently as well as set up dhcp, dns, samba servers.

Step 4: Install software for the management of my server. Going quite well also. Getting some good experience from work. Just learned about a nifty tool called Mandriva Directory Server as well as tools like Webmin and ISPConfig.

Step 5: Installing existing CMSs' and understanding how they work. Not as much done on this front. Haven't really coded in php in a while or had a look at any source code for a while.

Step 6: Learn Cascading Style Sheets. Not much done on this front either, should really put more effort in.

Step 7: Learn Javascript. Nope

Step 8: Learn XHTML. Nothing

Step 9: Learn AJAX. Nada

So, overall could be better, but could be worse as well. I'm learning the most at my work and that's a good thing, to be paid as you're learning. Hopefully the second two thirds of the year will see me take on more web based technologies. I'm also looking to get a .NET server running under linux, it should be possible using Mondo. The best part obviously being that it's free :)

Sunday 27 July 2008

Random Links

http://antitrust.slated.org/www.iowaconsumercase.org/011607/3000/PX03020.pdf

http://www.osnews.com/story/17689/Bill-Gates-on-Making-ACPI-Not-Work-with-Linux/

http://howflow.com/tricks/medion_md_98300_fan_control

http://blogs.zdnet.com/perlow/?p=9190

Wednesday 25 June 2008

Upgraded RAM on laptop

Now, I have 1GB of RAM, which is more than enough to run a full desktop as well as Apache, MySQL, PHP etc…. on Linux of course. The system really hums now. I tried opening up Firefox, along with all of the open office applications, word processor, spreadsheet, presentation and database. Then I started using the Apache install on my laptop by running my local Joomla install and the memory didn’t go above 40%. All of this for $13NZD and a generic 512 RAM module from your local computer shop.

Monday 16 June 2008

Link to home server

Just added a link to my home server blog on this blog. Eventually I want to transfer all of my post to that blog. The link is http://srdan.ath.cx/wordpress/. I set up a computer at my house as a web server after I found out my modem/router supported Dynamic DNS and got an account with DynDns.org.

Wednesday 23 April 2008

DNS

Just finished reading the section on 'DNS' from 'Linux System Administration' by Tom Adelstein and Bill Lubanovic from O'Reilly press. They tried to present a complex topic in a straight forward manner, but I think generally they failed.

Anyways, I'm reading the book partly because of my new job as a Linux sysadmin for a small company called Primesoft. I'm gonna have to replace a Linux box which currently acts as a firewall/router not to mention god knows what other services it provides. But still it should be a good experience.

On the other hand I figured out finally how to get multi boot linux to work properly. I set up my laptop with two different versions of Ubuntu and I finally installed Fedora. My impressions of Fedora were good to start off with, while it was installing. The Anaconda installer is a really well polished piece of work. But upon logging in I wasn't so impressed. For example I couldn't find the Fedora version of Synaptic. I'm sure there must be one, anyway it just shows how important Synaptic is to Ubuntu.

Thursday 27 March 2008

My new laptop - Acer Aspire 4315 Review

I needed a simple, cheap laptop that I could take to university so that I could work on stuff there and not have to hope and pray that there'll be enough working computers for me when I get to university.


The Requirements
The requirements for my laptop weren't great. All it had to do was have WiFi (802.11 b/g) and be powerful enough to run a simple development web server (LAMP). The other requirement and the most important one was that it had to be cheap. After looking on the Laptop section of PriceSpy I came upon the Acer 4315 going for $699NZD (plus a $99 cash back offer from Acer) which was the same price as the Asus EEE (after the cash back). The laptop came preloaded with Ubuntu 7.10, which was great for me, since I probably would have installed it anyway. So it was a tough decision, whether to go for extreme portability and just a really cool little gadget or to go for a rather standard (if a little old laptop).

I made up my mind when Dick Smith had a computer sale and discounted their laptops by 10% lowering the before cashback price of the Acer to $630NZD. So one Saturday I went down to the store and brought it home.


You get what you paid for
For $630 you don't get a laptop bag or any other extras. Just the laptop and the power cord. Although the salesman offered a upgrade package including more ram, a bag and something else (usb mouse??) for $99 which i declined. Other than the laptop and the power cord there was also the warranty booklet from Acer, a pamphlet on how to put in the battery and turn on the laptop and two instructional bits of paper.

Two bits of paper
The first piece of paper starts off by thanking you on purchasing the computer loaded with Ubuntu, followed by a blurb about linux and Ubuntu in general that sounds like it came from the Ubuntu marketing department.


Near the bottm of the page a section titled "Some system limitations" informs the users that the E key, Wireless key, modem and microphone are all disabled "due to limitations of Linux". (The E key I'm guessing launches some kind of Acer software package that came with the laptop and the wireless key enables/disables the wireless card). It would have been more accurate of Acer to say that the E key is disabled because their developers put out software only designed to run on Windows. The wireless key does work, but in an interesting way. When connected and you push the wireless button it will disable the wireless card, but in such a way that the network manager app doesn't know that the device has been shut down, so the interface is still active and it tries to connect, but ends up failing. Pressing the wireless button again and telling the network manager to connect to the network again seems to work for me. The microphone doesn't work at all. The modem I haven't tried, but I don't really need an analog modem with my laptop anyway.

The other side of the first bit of paper tells you how to set up an account once the computer is turned on. It basically consists of selecting your language, time zone, keyboard layout and your name, username and password. It also tells you how to create a regular user account once you log in.

The second bit of paper tells you how to connect to a wireless network on one side and on the other it gives a detailed list of how to install the automatix dvd and playback codecs.


About the Ubuntu installation
  • The laptop came with Ubuntu Gutsy 7.10 32-bit installed
  • The main partition is ext2, not the usual ext3. Leading to a faster system, albeit a less secure one for your data. (ext2 does not have journaling)
  • The swap partition is not encased in a linux extended partition but is directly mapped onto the hard drive and has a size of ~4GB
  • The computer name is set to ASUS
  • The Atheros wireless driver is enabled from first boot

The Cashback
In order to get the cash back offer it turns out you have to go to acer's website and register which model you bought, where and when. Registering was easy, but on the website the folks at Acer try to get you to abandon your cash back offer and instead use the money to buy their extended warranty, with the website claiming that the average laptop service costs $328. I just skipped this part and asked for the money. It turns out that in order to get your cashback you have to send in the barcode from the box the laptop came in, along with your receipt to an address in Australia, within 30 days or no deal. Not to mention the fact that if you don't register on the website within 14 days of your purchase you can also forget it. But the best part is in their terms when they say to allow up to 8 weeks after they receive the request to receive the cash. Seems like a bit of a double standard to me, them giving you only 4 weeks to send your barcode and receipt in, but allowing themselves up to 8 weeks to send you your money. So it seems it'll be sometime in June when I get my money back, a nice little birthday present for me :)


Issues I have with the laptop
  • microphone doesn't work
  • suspend doesn't work
  • specialised buttons on side don't work (wireless button works but not fully)
  • screen flickers when plugging/unnplugging the power cord
  • to disable the touchpad while writing you have to press the 'function' button and one of the F keys.
  • the latch at the front makes it sometimes tricky to open the laptop, requiring you to use your nail. But I do like having a latch.
All in all, I'm quite pleased with my first laptop. I wanted something basic for a bargain price and I found it. The lack of a microphone is a shame, but I can't remember the last time I used a microphone anyway and the lack of suspend was to be expected. I have yet to install the webserver software so it'll be interesting to see how well it runs. I'm also liking the rough plastic finish on the outside of the laptop, it gives it quite a solid look. The mousepad also feels quite good, compared to some other laptops I've had a go with. Another good point is the fast boot time, which feels even faster than my desktop computer. This is most likely due to the decision to use the 32-bit version of Ubuntu and to use the ext2 file system as opposed to the slower ext3.

Wednesday 19 March 2008

Bookmark overload

I just updated my links section of the blog. As you can see it is now huge. The story behind this is that I'm trying to clear out my bookmarks in firefox and I thought the best way to do so would be to post the links on my website and then have a post for each site (or several sites) explaining what the site is about and if it's any good. So hopefully more to come later.

Tuesday 18 March 2008

So there's only web development...

So, after talking to a friend of mine he came up with a statement that I believe sums up the New Zealand IT industry pretty well. "Its all web development". The industry here contains a few large companies, which hire some CS/SE graduates, but the vast majority will find themselves after university working on some aspect of developing essentially web pages.

For someone who doesn't particularly enjoy web development, this is a rather bitter pill to swallow, learning that if you want to work in any other aspect of IT, you should probably move to Australia/UK/America.

What's even more disappointing is that during my 5 and a half years at university, there was hardly any emphasis placed on web development. I think in total there were 2 courses that dealt with any kind of web development. This leaves a large gap in my education, as people that are hiring are looking for experience with CSS, Javascript, AJAX, technologies which the university does not teach at all, and PHP/ASP.NET, MySQL/MSSQL which the university does a poor job of teaching. In fact looking at the curriculum the only thing that the Computer Science degree seems to prepare you for is more Computer Science.

So anyway... It's no use bitching about the past now. If I'm doomed to become a web developer then I might as well become the best fucking web developer this side of the equator. But this is going to involve a lot of learning. The type of learning I dread and generally avoid. Learning by yourself, in your own spare time. Having to force yourself to read another chapter after coming home from work tired and worn out from your shitty job. The really hard kind of learning... fuck.

But I do in fact have a plan. And having a plan keeps me from having a total nervous breakdown, something which I've been really close to this last month.

My plan essentially involves learning everything about web technology, from the ground up, from setting up a LAMP server to AJAX. This is an ambitious goal for me, one which might take over a year or more to complete as I don't know how much time I will be able to commit to my "2nd education". But I do know roughly what it will involve.

Step 1: Wiring up my house. That is to say put in ethernet cables connecting the bedrooms of the house, the living room and the garage. This will allow me to put my de facto webserver (old HP pentium 4 my girlfriend was going to throw out) into the garage and to have it running full time. This computer is a mixture of web server and storage server (after adding a 320GB HDD) and will serve files to the internet and to the different devices around the house (in the future I could have a separate machine as a file server and a webserver) This should also give me experience on how to set up a network for a SOHO (Small Office Home Office).

Step 2: Domain Name. Opening an account with a dynamic dns provider and setting up a domain name. Probably going to use dyndns.com as it seems to be quite popular.

Step 3: Learning about webservers, file servers, ssh servers, nfs servers, ftp servers, proxies etc... Because I want my web/storage server to be universally accessible it needs to be able to serve files across a wide range of protocols. For each of the types of server I need to
  1. Install the software
  2. Configure the software i.e. get it to do what I want securely
Luckily I have found a resource that deals with these issues and a lot more. The resource being www.linuxhomenetworking.com. The website is well written, easy to read and up to date. It's also free.

[NOTE: I should mention now that I intend to use only OSS software as a part of this education, for reasons which I will probably write about later]

Step 4: Install software for the management of my server. This includes things like Webmin, MySQL Administrator, PHPMyAdmin and perhaps some software to configure Apache (is there a decent GUI frontend for Apache or does it come down to editing config files?)

Step 5: Installing existing CMSs' and understanding how they work. Looking at software such as Joomla!, Drupal, Wordpress, Blogger (is the blogger source code available?), Silverstripe (Go NZ!) etc... and looking at how they are made, paying particular attention to how they handle extensibility (add-ons, extensions) and theming. However for the basic ideas on how to create a CMS I'll probably start with php-mysql-tutorial.com. It should be interesting to see how much difference in the designs of these CMSs' there is and the benefits/disadvantages of each approach.

Step 6: Learn Cascading Style Sheets. I have a real love/hate relationship with CSS. That is to say I f***ing hate CSS. As far as I'm concerned, CSS is a great idea (separation of content and presentation), implemented in a totally illogical, counter-intuitive, overly complex way. But to be fair, that's what I thought of a lot of programming languages I learned until I "got" them. So maybe sometime in the future I will really love CSS, but I wouldn't bet money on it. I'm probably gonna go with the tutorials from W3Schools or failing that get a book from the university library on CSS.

Step 7: Learn Javascript. Again, I feel like I'm 10 years behind the learning curve with this one, but thanks to university (and my own lack of interest in web development) this is another area which I have hardly any experience with. With this one I'm gonna follow the W3Schools tutorials and if needed get a book from the uni library.

Step 8: Learn XHTML. Another one from W3Schools. Basically need to learn along with Javascript to be able to understand AJAX in step 9.

Step 9: Learn AJAX. Start with W3Schools tutorial on AJAX, then can move on to other examples on the internet. There's so many on the web that the biggest problem learning is going to be information overload. A book might be useful as well.

So then the question arises as to what to do with all of this new web development knowledge and the server sitting in my garage. The thing to do I guess would be to make a website to showcase my talents which could be a point of reference for people seeking examples of my skills/knowledge.

Also the idea of creating a photo gallery CMS based on the work I did with LaPhotographie is an idea I've had for a while. Such a system would, of course be open source and perhaps some day take off and become more than a pet project.

And the possibility of turning the setup in my garage into a web hosting company is there as well.

So there you go, that's my plan. It helps me to keep busy and ignore the fact that I'll probably end up doing web development for a long, long time.

Friday 29 February 2008

Nuff said

Ubuntu's new website http://brainstorm.ubuntu.com/. Best idea ever. Nuff said.