Wednesday, April 13, 2011

Shito Ryu Itosu Kai

A funny thing happened on the way to the dojo....

As a stereotypical sysadmin (middle aged and overweight) I always hated the thought of exercise for exercise's sake. I did enjoy playing some sports like baseball but I have almost zero athletic talent, so as I got older I was really slowing down - especially since none of it came naturally.

A friend called our family in the fall of 2010 asking if any of our sons would be interested in learning karate. The price was more than reasonable, and the dojo less than 10 minutes from our door. So my wife and I took the older two (6 and 8 at the time) out to watch a class. Not only did our older son think it looked like fun, I was hooked too. We decided we'd both try it together for moral support.

It's not a sport - there's no keeping score. It's not religious, and you might miss the philosophical nature of it entirely if you aren't paying attention, although you'll get it by osmosis if no other way. To me it's about self improvement - both physically and to my surprise mentally too.

I've been at it for about six months now. I haven't lost any weight to speak of, but my balance, flexibility and endurance are all way way way better. I always thought those people that complained about feeling lousy because they missed a workout were either full of it or showing off - now I'm starting to see what they mean. At the end of the night I'm usually physically exhausted, and happy, and the happy part carries through the next day, while the exhausted part doesn't (minus a few achy bits :-)

Completely ignore the movies about martial arts. OK, scratch that. Enjoy the martial arts movies if you're into that stuff - just remember they're as true to life as Middle Earth or WoW is to your neighbourhood. If there are two physical activities that should suit a sysadmin - karate and curling have got to be it. It's not just dumb muscle memory, or fast twitch reflexes. You have to use your head and control your muscles. Technique is king, and brute force a distant pawn at best.

Any karate class worth attending welcomes newbies, expects you to be terrible, and just wants you to respect tradition and try hard. Talent or physical fitness is not required. You owe it to yourself to find one and ask if you can watch one night.

This was a long winded way of introducing the next bunch of posts on kata, which probably still won't make any sense, but hey, it's my blog right? :-)

Tuesday, April 12, 2011

And Now For Something Completely Different

As you can plainly see, tech content here has been pretty few and far between lately.

It's somewhat amusing (or tragic, or both) that I've somehow ended up the admin of a completely MS based domain - PCs, servers, applications and all.

I could bitch and whine and moan and complain (and sometimes I still do, but quietly :-), but I decided I'd be healthier and happier if I took it as a challenge to best rather than a cross to bear. And hey, I got a raise to go along with it, so it's not all bad.

Also on the bright side, what system admin doesn't love playing with new and shiny stuff, and the chance to replace literally everything but the monitors and printers? So hey, I'm trying to be positive, and I do have to admit, not all this MS stuff is terrible. Group policy is kinda cool even - just don't get me started on DFSR :-(

No, I'm not killing the blog - I'm just, um, refocusing :-) I still intend on having tech stuff here, I'm just very busy at the moment. In the mean time I'm throwing up some posts that are more personal memos than information for the world at large about my new found passion - karate. Feel free to blow right by the next couple of posts if that doesn't interest you - or drop me an email to whine if you prefer - I just don't promise to listen :-)

Monday, November 15, 2010

Migrating Email From Apple Mail to Windows Live Mail

Yes, some people really do leave Apple for Microsoft...

This applies only to Apple Mail found in Leopard and Snow Leopard - earlier versions store and handle mail differently.

  1. create mbox2eml.pl, and put it on your $PATH
  2. #!/usr/bin/perl -w

    # Copyright (C) 2009 Josh A. Beam
    #
    # Permission to use, copy, modify, and/or distribute this software for any
    # purpose with or without fee is hereby granted, provided that the above
    # copyright notice and this permission notice appear in all copies.
    #
    # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
    # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
    # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

    # mbox2eml.pl (last modified July 14, 2009)
    # This Perl script creates separate .eml files for each email message in
    # a given mbox file. The .eml files are created in the directory that the
    # script is run from and each file is named according to the position of
    # the message in the mbox file (for example, "1.eml" for the first message).

    use strict;

    # make sure an mbox filename was given
    if($#ARGV != 0) {
    print STDERR "Usage: $0 \n";
    exit(1);
    }

    # open mbox file
    open MBOX, $ARGV[0] or die "Unable to open mbox file\n";

    # loop through each line from mbox file
    my $fileCount = 0;
    my $blankLineCount = 2;
    while(my $line = )
    {
    chomp($line);
    $line =~ s/\r//g;

    # check for the start of a new message
    if($blankLineCount >= 1 && $line =~ /^From /) {
    # open new eml file
    close EML;
    open EML, ">" . ++$fileCount . ".eml";

    print "Saving " . $fileCount . ".eml\r";
    } else {
    # write line to file
    print EML $line . "\n";
    }

    # check for blank lines
    if($line eq "") {
    ++$blankLineCount;
    } else {
    $blankLineCount = 0;
    }
    }

    # close files
    close EML;
    close MBOX;

    print "Saved " . $fileCount . " files\n";

  3. mkdir ~/someFolder
  4. cd ~/Library/Mail
  5. find . -type d -iname '*.mbox' -exec cp -R "{}" ~/someFolder/ \;
  6. cd ~/someFolder
  7. for directory in *.mbox ; do mkdir "${directory}-email" ; done
  8. for directory in *.mbox ; do mbox2eml.pl "${directory}/mbox" ; mv -v *.eml "${directory}-email" ; done
  9. rm -rf *.mbox
  10. Copy someFolder to the Windows computer
  11. Run File -> Import from Windows Live Mail - choose Live Mail format when asked

Thursday, March 25, 2010

Sync Google Contacts to OSX Address Book Without An iPhone

Lifehacker had a quick note pointing out when Apple added their 'sync to Google Contacts' option to OSX 10.5 and 10.6. You had to have an iPhone or iPod touch to use it though.

Shortly after that someone pointed out to them how to hack the ipod plist file to make it think you have one, thus turning the option on.

They didn't point out that if you have had multiple iPods attached to your machine, you'll have multiple entries to choose from when altering the 'Family ID' tag.

I had an entry for my iPod mini, which has long since died and gone to the recyclers. I figured that was the perfect one to change. So I altered the plist with vim, started Address Book and there's the option just like promised. I enabled it, and nothing happened.....

It turns out that syncing to Google in 10.5 is done only when your iPod syncs. (10.6 will do it hourly as well) Then I had a thought. I pulled out my Motorola cell phone which I enabled syncing on previously, and launched iSync.
Tada! When it synced the phone, it synced with Google too.

Tuesday, March 23, 2010

Quick How To - Fix HP 5610 Phantom Paper Jam and Cartridge Jam Errors

Thanks jfasher whoever you are...

http://www.fixya.com/support/t246039-hp_5610_paper_jam_error_clear

The HP 5610 has a clear plastic 'ribbon' above the bar supporing the print heads.
The sensor on the back of the cartridge carriage reads the marks on that ribbon to know when it's moving. It was filthy.

There's a similar clear plastic disc on the end of the paper feed rollers.
You've got to disassemble the printer from the top down, carefully disconnecting the data ribbons as you go to get down there. Cleaned it and blew out the sensor it rotates thru and voila! Phantom paper jam gone to the containment unit :-)

Sunday, February 7, 2010

Quick How-To: Login without a password, Debian/Ubuntu using GDM

Why? (Yes, I know you wanted to ask)
He's three - he can pick his picture from a list, but asking him to remember his password is pushing it a bit I think...

This isn't as easy as you'd think. For the whole dirty story, see this Launchpad entry.

For the quick how to

Make it possible to log in on a console without a password by starting up a terminal and typing:
sudo passwd -d usernameGoesHere

Change the login screen to use a list of users you can click on by going to System -> Administration -> Login Window and after putting in your password select the Local tab. Under Style, pick one of the options that mention a face browser.

Still won't work yet though :-) Last, add 128 (yes, 128) lines to /etc/securetty
It should look like this

# Local X displays
:0
:0.0
:1
:1.0
:2
:2.0
:3
:3.0
and keep going until you hit 63

Hope this helps...

Wednesday, December 16, 2009

Filling in PDF forms using Open Office - Mail Merge Style

We recently changed an HR related supplier at work. As a result, every employee (100+) had to fill in a three page form. The new supplier provided us a non-editable PDF.

As anyone working in a mid-sized company knows, getting 100 people to do the same thing correctly is pretty much an exercise in futility :-)

Now 98% of that form HR knew the answers too - name, address, date of first employment etc. etc. Open Office can do a 'mail merge' from the spreadsheet with that data in it to a document in Writer, but can't import PDF natively.

My first thought was to use the pdf import extension for Open Office. It works ok, but imports the PDF as a Draw document, rather than a Writer document. Draw documents don't do mail merges as far as I can see.

My second thought was to create a Writer document, and use the form as the page background. Turns out setting a page background with an image works ok, but the same image is repeated on every page. Won't work for our multipage document unless we created three documents and somebody played manual collator for a while. Sure as heck something would get scrambled.

What I did in the end was time consuming but worked well.

  1. Convert each page of the pdf form into a tiff or similar high quality image file
  2. Register your spreadsheet or database as a data source.
  3. Start with a new Write document. Hit return enough times to create number of pages you need.
  4. Choose Insert -> Frame.

    1. Make sure it's anchored to the page
    2. Positioned for the entire page
    3. Name it on the Options Tab (optional, but handy)
    4. Set borders to none on the Borders tab
    5. On the Background tab change it to Graphic instead of Color, and browse for your first page image.
    6. Move the image around until it covers the entire page properly
    7. Right click and choose Alignment -> Back
    8. Hit OK
    9. Repeat for each page

  5. Choose View -> Data Sources and highlight your data source so the fields you want are displayed at the top of your window.
  6. Choose Insert -> Frame.

    1. Make sure it's anchored to the page
    2. Make sure auto size is off
    3. Name it on the Options Tab (optional, but handy)
    4. Set borders to none on the Borders tab
    5. Hit OK

  7. Now drag the Heading from the first column of data into that frame
  8. Move the frame to the right spot on the background to fill in the blank
  9. Lather, rinse repeat for each piece of data on each page


When you choose 'Print' it will ask you if you want the blanks filled in, and away you go!

I haven't posted any screenshots - Let me know if you think you need them and I can create some.

Hope this helps somebody!

Tuesday, December 1, 2009

Installing a Samsung SCX-4521F in Linux - Ubuntu Hardy Heron actually

I've seen a lot of comments across the web about this particular printer and getting it and the scanning working in Ubuntu.

It was easy for me - here's my simple checklist
Note I'm using a USB interface.


  1. Get the Samsung Unified Driver version 3
  2. Install it via tar xvzf SamsungXXX.tar.gz && cd cdroot/Linux && sudo ./install.sh. I did it without using X at all, I gather there's a little GUI that doesn't ask anything text install doesn't.
  3. Curse Samsung for putting the freaking icon on your desktop and the root of your applications menu without asking
  4. Clean up the crap you just cursed about.UPDATE forgot to mention the specifics - /bin/Desktop /bin/.gnome-desktop /usr/sbin/Desktop /usr/sbin/.gnome-desktop Yes, that install script has some bugs in it!
  5. Try a test page. Samsung 'helpfully' decided to make the new printer the default, so lpr favourite.pdf should work fine.
  6. Try scanimage -L and see if you can see the printer. If not (bet you can't) try sudo scanimage -L. If that works, it's a permissions problem.
  7. Add all the appropriate users to the lp group. e.g. sudo addgroup joeUser lp. The installer says it's doing something like this, but whatever it does doesn't work. Ubuntu has the handy scanner group as well, but the lp group ends up owning /dev/usb/0. Rather than muck about with updated udev rules, I just added the users to both the scanner and lp groups and it works fine.
  8. Log out of that terminal session and start a new one. A terminal doesn't pick up updated group membership until it logs in the next time. Dunno whether that applies to the 'GUI' users and group tool or not. Let me know....
  9. Use scanimage -L to see if sane can see the scanner.

Wednesday, November 25, 2009

Large Drives and USB Enclosures

OK, this is definitely a talk to the rubber ducky kind of post.

I have an old Mandrake box that various clients send their backups to overnight. I hook up an external USB drive and run a script that basically rsyncs the various backups to the external drive to be taken off-site. Been doing it this way for a while now.

I've upgraded the size of the drive in the external enclosure a couple of times, 160G to 320G to 1TB recently. When I first got the 1TB enclosure, I partitioned it with an iMac, then remembered I couldn't format ext3 with the Mac, so I connected it to a linux box and formatted it, but left the partitioning alone. Turns out the iMac partitioned it GPT. I only realized this after I'd been using it for a couple of days. This is in the logs.
kernel: /dev/scsi/host39/bus0/target0/lun0:<4> Warning: Disk has a valid GPT signature but invalid PMBR.
kernel: Assuming this disk is *not* a GPT disk anymore.

It was working, I didn't have a handy spot to move the large amount of data on the disk to, and fixing it seemed like it would probably destroy data, so I left it for a bit. I tested restoring data from the drive to be sure, and everything was working fine.

A couple of weeks later, during a really busy spell, I noticed the daily rsync jobs turned deadly slow. Instead of 6MB/s I'm getting 300k or less. Almost like it was swapping to USB1.1 instead of 2.

I twiddled with it for a bit, and since it was somewhat intermittent I tried replacing the USB controller (it's an add on card) in the server. Over the next couple of days I tried another USB enclosure, another USB cable, and copying files from different server. The problem kind of came and went, so no one change seemed to be the fix.

Since this is the off-site backup, I had started using another (smaller) drive to copy the recent information to - this setup was working fine. I bought another 1TB drive and enclosure, both different brands than the existing units, partitioned and formatted it correctly from a linux box, and started using it. It was running fine at full speed. When I had time I started copying the older archive info that was only on the first TB drive over as well.

Now this morning that new drive started running slow....

The only thing that makes any sense at all to be at this point is some problem with USB enclosures and large drives - e.g. once it gets past 650meg or so they start having problems? But the two enclosures are completely different chipsets - one has IDE + SATA, the other is SATA only. It can't be that widespread an issue can it?

OK, so now I've typed all this out, the ducky still hasn't said anything...

Anybody else want to comment?

Wednesday, November 18, 2009

Finding OSX Aliases in a SMB/CIFS Share

Just a quick follow up to my previous post.

In case it wasn't obvious - if you want to find all those OSX alias files it's just a simple

grep -r XSym /path/to/smbshare/on/server


Updated:

If I had more of them I'd hack up a script to pull the path info out of them and create the symlinks automatically....


This is really hacky, but you can make symlinks out of alias files with it.
If a dragon appears and demands a dumptruck for a four-wheeler, don't blame it on me!


read NAME && LINK=$(tail -n 2 $NAME | head -n 1) && rm -v $NAME && ln -sv "$LINK" "$NAME"

Samba Unix Extensions and Following Symlinks with OSX Leopard and Ubuntu Hardy

Sorry for that title - just trying to help the Google bot help the future.

So here's the problem. When we upgraded the bulk of the Macs at work to Leopard, symlinks on the Samba share quit working. They still worked in Windows, and on Hardy clients, but not Leopard.

If you created an 'alias' in Leopard, then the Macs could follow it, but the Linux boxes not.

Lots of people have the same or similar issues -
A B C D E F

Turns out Leopard is the first OSX client to support Unix extensions in CIFS.
So the client ends up trying to follow symlinks *locally* rather than on the server. 'Dumber' clients like Windows or Gnome Nautilus smb:// don't do Unix extensions, so the server resolves the symlinks for you.

The 'fix' is to set 'unix extensions = no' globally in the smb.conf file.
Now the OSX clients won't get the unix info either, and the server will go back to resolving symlinks for them.

The drawback to this fix as I understand it is that SMB with unix extensions on is a complete replacement for NFS in that the full range of unix permissions can be provided to unix clients - it's not limited anymore. You would need some external system to keep UID/GIDs syncronized, but NFS has that issue too.

What I still don't understand is how to get symlinks to resolve to the correct spot on the server when unix extensions *is* on. E.G. if I was using a 'smart' linux client (like mount.cifs and the /etc/fstab file?) how do I get symlinks to work? Comments appreciated, as I've spent too much time on this issue at the moment anyway.

Brian

PS - I also found out that when you create an 'alias' in OSX on a SMB share, the file it creates is actually in Minchell and French format - see this page that talks about creating symlinks on Windows servers. That's what OSX does on a linux server as well. Weird the linux client doesn't follow it!

Monday, September 14, 2009

Adding Java apps to the Motorola K1m For Free

I've got a Motorola K1m running on the President's Choice Financial pay as you go program. (It's resold Bell Mobility services) Cheap and reliable!

It has a built in browser that works ok for some things, but won't cooperate with the identi.ca microblog I post to.

I tripped over an interesting pair of applications that looked like they might work from the Substance Of Code blog. Mobidentica and Twim. Now how the heck can I install those on my phone? It's a somewhat locked down system. :-)

Turns out the latest version of Bitpim (1.06) for Leopard will actually talk to my phone. I'd tried with earlier versions and had no luck, but this time I was able to get a working connection.

Since Bitpim won't automatically discover the phone, what I found to work was this - use a USB cable, plug it in, and under preferences you'll have to manually specify the K1m and pick a COM port. Go for the one marked 'modem' - in my case it was /dev/cu.usbmodem5d11

Now, under the 'View' menu turn on the 'View File System' option. Pick the new 'File System' entry on the left side of the main window pane and start twisting the little triangles next to the '/' entry. Confusingly only files show in the next column, sub directories only appear under the '/' entry AFTER you twist the triangle. Harder to explain than do - just try it.

Navigate to /brew/mod/jbed/preinstall Don't worry about the hacky looking path, that's really what's already there. Right click in the last column and 'add files' to add the .jad and .jar files you download from the Substance Of Code site. You'll see the progress on the bottom right as it uploads the files to your phone. Quit Bitpim, and start Java on your phone. It will discover and compile the programs, quit Java and then restart on it's own. Now your application is available along with the sample games etc.

See this post for most of the info I've just provided here.

I'm sure this will apply to other Java phone applications too. I'll be keeping an eye out for more possibilities! Hope that helps someone.

Brian

Friday, September 4, 2009

Opening up an Intel iMac 17"

I just replaced the hard drive on a 17" Intel iMac. (Last one before the grey and black models). It's amazing how unfriendly it is to disassemble compared to the iMac G5. If this is your first time disassembling stuff, don't start with this model iMac. :-) If doing stuff like this is normal for you then don't be scared of it, just be careful.

What isn't clear from the pictures and movies I saw on the internet is how to release the casing around the iSight camera. One video I saw said "shake it and it'll come loose". Ummm... NO.

Here's the picture you need to see.




The two top clips are actually spring loaded hooks. Lift the thick part of the metal and they unhook.

FYI
Brian

Friday, August 28, 2009

Apple PowerBook G4 400MHz xorg.conf Debian Lenny

More of a self note so I can find it again someday...

If you aren't getting X with a default Debian Lenny install on a 400MHz Apple PowerBook G4 Titanium ATI Rage Mobility 128 M6 (got all that Google?)

Try this xorg.conf - the 'Modes' section and the UseModes line are the additions I think - I kept tweaking it until it stopped being broken so other things might not quite be standard...

# xorg.conf (X.Org X Window System server configuration file)
Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "XkbRules" "xorg"
Option "XkbModel" "macintosh"
Option "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
EndSection

Section "Device"
Identifier "Configured Video Device"
Driver "radeon"
BusID "PCI:0:16:0"
EndSection
Section "Modes"
Identifier "Modes0"
Modeline "1152x768" 64.994 1152 1178 1314 1472 768 771 777 806 +HSync +VSync
EndSection

Section "Monitor"
Identifier "Configured Monitor"
UseModes "Modes0"
EndSection

Section "Screen"
Identifier "Default Screen"
Device "Configured Video Device"
Monitor "Configured Monitor"
EndSection

Thursday, March 19, 2009

A (long) day in the life of a sysadmin....

Now sit right back and you'll hear a tale...

[digression]
Isn't it criminal that Baywatch is the first link in Google on that phrase?
Goes to demonstrate that they just aren't that great at search, just better
than the alternatives!
[end digression]


I was looking at my daily logs. You do that too right? It's very helpful to keep you ahead of the game and knowing what's going on rather than playing catch up all the time. On the other hand it can be pretty darned tedious. I use logwatch of course to make it bearable.

Lately I've been rolling out Ubuntu Hardy desktop boxes. I remarked to myself that since I'm monitoring the drive space using Nagios, the disk space report on every log file was filler I really didn't need to be looking at. And hey, I like fortune as much as the next guy, but once you've seen a dozen or so you really don't need anymore for the day. Why not turn that stuff off?

Now I knew that logwatch configuration seems to be a bit, well, baroque,

but hey, I can handle it right?
[that's called foreshadowing]

Heck - I'd even seen an article about managing your log files that mentioned logwatch on my RSS reader. Let's do this!

[The road to hell...]


==> man logwatch
==> view /usr/share/doc/logwatch/README
==> view /usr/share/doc/logwatch/HOWTO-Customize-LogWatch

OK, the default files are in /usr/share/logwatch, and the system local ones go in /etc/logwatch.
Let's go look.
==> cd /etc/logwatch
poke around
It's empty. Five folders, no conf files. Folders with .conf in their name though! Weird, but true. Lets go check out /usr/share/logwatch
[poke around]
Ok, the stuff is all here - and reading the docs at /usr/share/doc/logwatch tells me that these are the defaults, and stuff put in /etc overrides them. Since logwatch is used on more than just Linux, it seems a bit different, but obviously flexible. Let's peruse the logwatch.conf file - it's well commented.
# You can also disable certain services (when specifying all)
Service = "-zz-network" # Prevents execution of zz-network service, which
# prints useful network configuration info.
Service = "-zz-sys" # Prevents execution of zz-sys service, which
# prints useful system configuration info.

Look - they've disabled two services 'zz-network' and 'zz-sys' by default. I wonder what they do?
[Cue the music - the abyss opens]

Well, it says they are useful - lets use them!
A nifty feature of logwatch is you can just keep running it over and over again from the commandline with different options and see what the output will look like. Once you get it tuned up, you adjust the conf file to match and cron takes it from there.
==> sudo logwatch --print
#### Logwatch 7.3.6 (05/19/07) ##
Processing Initiated: Thu Mar 19 14:52:42 2009

[snip 172 lines of detail I see waay too often as it is....]

==> sudo logwatch --print --service 'zz-network'

[snip interesting network info]

OK, so that one's interesting. What about zz-sys?
==> sudo logwatch --print --service 'zz-sys'
---- System Configuration Begin ---
No Sys::CPU module installed.
To install, execute the command:
perl -MCPAN -e 'install Sys::CPU'
No Sys::MemInfo module installed.
To install, execute the command:
perl -MCPAN -e 'install Sys::MemInfo'

Huh, missing modules. Perhaps that's why it's disabled. Let's just make sure
==> cd /usr/share/logwatch/scripts/services
==> ./zz-sys
No Sys::CPU module installed.
No Sys::MemInfo module installed.

OK. Let's install those missing modules. Now, I don't have anything against CPAN, but since these are a bunch of pretty much identical machines that need to be kept that way, keeping to the repositories, or at least .deb files is definately the right way to go.
==> sudo aptitude search meminfo
p python-meminfo-total

Close, but no cigar. Try again.
==> sudo aptitude search perl

[snip snip snip]

No! - don't do that! 1500 lines of stuff...
==> sudo aptitude search perl | grep mem

[snip 8 lines - nothing we want]

OK. So we need to make our own debs. This Debian Admin article is perfect.

Step one - Head over to CPAN and download the source. Their seach box makes it easy to find the links.
==> wget http://search.cpan.org/CPAN/authors/id/B/BU/BURAK/Sys-Info-0.69_07.tar.gz
==> wget http://search.cpan.org/CPAN/authors/id/S/SC/SCRESTO/Sys-MemInfo-0.91.tar.gz

Step two - install dh-make-perl
==> sudo aptitude install dh-make-perl
Need to get 5813kB of archives. After unpacking 21.3MB will be used.
Do you want to continue? [Y/n/?] y

Wow - 32 packages of dependencies! Well, that's what apt is for right? Go!
[hundreds of lines scroll by while I go grab coffee. That's a mistake...]

Building tag database... Done

OK - next step
==> tar xvzf Sys-Info-0.69_07.tar.gz
==> tar xvzf Sys-MemInfo-0.91.tar.gz
==> dh-make-perl Sys-Info-0.69_07
Searching for Sys::Info::Driver::OSID package using apt-file.
E: The cache directory is empty. You need to run 'apt-file update' first.
Searching for Sys::Info::Base package using apt-file.
E: The cache directory is empty. You need to run 'apt-file update' first.
Needs the following modules for which there are no debian packages available
- Sys::Info::Driver::OSID
- Sys::Info::Base

Now I was just plain dumb. I missed the point of the apt-file update message altogether by reading it as apt-get update.

OK, so I need a couple of dependencies too. Man, would be nice if these were in the repositories.
[Have you hugged a packager today? If not, did you buy one beer? or at least say thanks? Just wondering.....]

==> wget http://search.cpan.org/CPAN/authors/id/B/BU/BURAK/Sys-Info-Base-0.69_06.tar.gz
==> tar xvzf Sys-Info-Base-0.69_06.tar.gz
==> dh-make-perl Sys-Info-Base-0.69_06
Done

OK, now we're cooking.
==> wget http://search.cpan.org/CPAN/authors/id/B/BU/BURAK/Sys-Info-Driver-Linux-0.69_06.tar.gz
==> tar xvzf Sys-Info-Driver-Linux-0.69_06.tar.gz
==> dh-make-perl Sys-Info-Driver-Linux-0.69_06

[snip - still ignoring the message]

Needs the following modules for which there are no debian packages available
- Unix::Processors
- Sys::Info::Base
- Linux::Distribution

Grrr..... Sigh.
==> wget http://search.cpan.org/CPAN/authors/id/W/WS/WSNYDER/Unix-Processors-2.040.tgz
==> tar xvzf Unix-Processors-2.040.tgz
==> dh-make-perl Unix-Processors-2.040

[snip including copyright warning. Glad I'm not a packager that has to worry about these things for everybody else]

Done
==> wget http://search.cpan.org/CPAN/authors/id/K/KE/KERBERUS/Linux-Distribution-0.14.tar.gz
==> tar xvzf Linux-Distribution-0.14.tar.gz
==> dh-make-perl Linux-Distribution-0.14
Done

OK, now to make a deb!
==> cd Linux-Distribution-0.14
==> debuild
The program 'debuild' is currently not installed. You can install it by typing:
sudo apt-get install devscripts
-bash: debuild: command not found
==> sudo aptitude install debuild

[Yep - stupid again. Dunno what the heck I was thinking....]

Couldn't find package "debuild". However, the following packages contain "debuild" in their name:
pdebuild
==> sudo aptitude install pdebuild
Need to get 150MB of archives. After unpacking 312MB will be used.

Yikes - hundreds of depencies and many megabytes of Java looking stuff! Wha?
==> debuild
The program 'debuild' is currently not installed. You can install it by typing:
sudo apt-get install devscripts
-bash: debuild: command not found

[face-palm]

==> sudo aptitude install devscripts
Building tag database... Done
==> debuild
This package has a Debian revision number but there does not seem to be an appropriate original tar file or .orig directory in the parent directory;
(expected liblinux-distribution-perl_0.14.orig.tar.gz or Linux-Distribution-0.14.orig)
continue anyway? (y/n) y

[snippage]
gpg: [stdin]: clearsign failed: secret key not available
debsign: gpg error occurred! Aborting....
debuild: fatal error at line 1174:
running debsign failed

I don't need it signed. How do I disable that?
==> man debuild

Hey - right here in the examples it talks about binary only. Bet it needs the key to sign the code right?
==> debuild -i -us -uc -b
dpkg-deb: building package `liblinux-distribution-perl' in `../liblinux-distribution-perl_0.14-1_all.deb'.

Yea! A deb! Finally. Now to do the rest of 'em!
==> cd Unix-Processors-2.040/
==> debuild -i -us -uc -b
dpkg-deb: building package `libunix-processors-perl' in `../libunix-processors-perl_2.040-1_i386.deb'.
==> cd Sys-Info-Driver-Linux-0.69_06/
==> debuild
- ERROR: Test::Sys::Info is not installed
- ERROR: Unix::Processors is not installed
- ERROR: Linux::Distribution is not installed
- ERROR: Sys::Info::Base is not installed

OK, gotta install these in the right order too!
==> sudo dpkg --install lib*deb
Setting up liblinux-distribution-perl (0.14-1) ...
Setting up libunix-processors-perl (2.040-1) ...
==> dh-make-perl Sys-Info-Driver-Linux-0.69_06
E: The cache directory is empty. You need to run 'apt-file update' first.
The directory Sys-Info-Driver-Linux-0.69_06/debian is already present and I won't overwrite it: remove it yourself.

Now I read the darned message....
==> rm -rf Sys-Info-Driver-Linux-0.69_06/debian/
==> sudo apt-file update
Can't get ftp://ftp.mondorescue.org/ubuntu/dists/8.04/Contents-i386.gz

Huh? Oh, ya, that's an extra repository, won't matter for this.
==> dh-make-perl Sys-Info-Driver-Linux-0.69_06
Needs the following modules for which there are no debian packages available
- Unix::Processors
- Sys::Info::Base
- Linux::Distribution
==> cd Sys-Info-Driver-Linux-0.69_06/
==> debuild -i -us -uc -b
- ERROR: Test::Sys::Info is not installed
==> wget http://search.cpan.org/CPAN/authors/id/B/BU/BURAK/Test-Sys-Info-0.13.tar.gz
==> tar xvzf Test-Sys-Info-0.13.tar.gz
==> dh-make-perl Test-Sys-Info-0.13
Done
==> cd Test-Sys-Info-0.13/
==> debuild
gpg: [stdin]: clearsign failed: secret key not available

Bah - idiot!
==> debuild -i -us -uc -b
dpkg-deb: building package `libtest-sys-info-perl' in `../libtest-sys-info-perl_0.13-1_all.deb'.
==> sudo dpkg --install libtest-sys-info-perl_0.13-1_all.deb
==> cd Sys-Info-Driver-Linux-0.69_06/
==> debuild -i -us -uc -b
pkg-deb: building package `libsys-info-driver-linux-perl' in `../libsys-info-driver-linux-perl_0.69-06-1_all.deb'.
==> sudo dpkg --install libsys-info-driver-linux-perl_0.69-06-1_all.deb
==> dh-make-perl Sys-MemInfo
Cannot find a description for the package: use the --desc switch

Hey, new errors. What fun! At least it's a helpful errror. Let's try...
==> dh-make-perl --desc Sys-MemInfo Sys-MemInfo
Done
==> cd Sys-MemInfo/
==> debuild -i -us -uc -b
dpkg-deb: building package `libsys-meminfo-perl' in `../libsys-meminfo-perl_0.91-1_i386.deb'.
==> sudo dpkg --install libsys-meminfo-perl_0.91-1_i386.deb
Setting up libsys-meminfo-perl (0.91-1) ...

OK - this is IT. The moment of truth! Drumroll please!
==> ./zz-sys
No Sys::CPU module installed. To install, execute the command:
perl -MCPAN -e 'install Sys::CPU'
Memory: 495 MB
Machine: i686
Release: Linux 2.6.24-22-generic

Long pause. Quiet wimpering....
==> sudo aptitude search perl | grep cpu
p libsys-cpu-perl - Sys::CPU Perl module for getting CPU infor

Yes Virginia, there is a Santa Claus.

==> sudo aptitude install libsys-cpu-perl
Building tag database... Done


==> ./zz-sys
CPU: 1 Intel(R) Pentium(R) 4 CPU 2.40GHz at 2392MHz
Memory: 495 MB
Machine: i686
Release: Linux 2.6.24-22-generic

Four lines of output.
[And I still haven't gotten it into the logwatch.conf]

Somedays you're the windshield............

Wednesday, February 25, 2009

Thanks to datainadequate's comment on an earlier post, I've got another book to take a look at - Dive Into Python. I did see mention of it before, but the tag line saying it was 'for experienced programmers' scared me off without looking at it further. What the heck, I'm game this time around.

Also of note, I'm hoping to have current versions of both O'Reilly books Learning Python and Programming Python in my posses ion soon, so once my eyes quit glazing over from the information overload I'll try and post some further reviews of how I think they all stack up.

Maybe I should have been a librarian :-) I wonder if librarians that like too read too much end up like cooks that like to eat too much....

Sunday, February 22, 2009

Stop Vim From Creating Backup Files of bzr_log entries during commit

Here's a handy tip from Paul Brannan. I pulled this from a Launchpad bug report.

I use Vim as my default $EDITOR. When I commit a change using bzr, it opens Vim up and lets me type my comments in.

Unfortunately after I save and edit, it leaves behind a bzr_log backup file with a ~ in that directory too. I want Vim to make those backup files normally, but not when doing bzr commits.

Paul to the rescue:

I solved this with:

~/.vimrc:
filetype on
filetype plugin on

~/.vim/ftplugin/bzr.vim:
set nobackup

(See - it pays to read bug reports! Now go check out all the other ones and let me know the good parts ok?)

Thursday, February 19, 2009

Python - The Never Ending Journey Of A Thousand Miles

Inch by Inch, Row by.... wait a minute, this is Python not Inchworm. Well, whatever.

Note, if you aren't a Monty Python fan it's hard to do the community suggested Python jokes, so you're stuck with my lame stuff instead. Joke writers cost money you know (and I'm free, err.. you know what I mean).

As I mentioned previously, I began learning Python by starting with 'A Byte of Python'. I'm enjoying it, and learning. Eventually I hit some example code showing how objects inherit class local variables, but objects don't share variables among themselves (downwards, not sideways).

The example made sense, and proved his point, but when I ran it on my machine it kicked out a Warning I didn't understand. So, I took my code and the warning message over to the Python IRC channel and they kicked it around a little bit - end result was they didn't like the example that much. They explained the problem to me, and I understood why the warning was there, but I didn't come up with a good way to refactor it so it didn't happen again.

During the conversation, someone suggested looking at Think Python. Turns out that one's available online under a free license as well. Off I went to take a gander.

It's quite good too. I like the way it talks about how to program, as well as how to program in Python. It assumes you have a decent knowledge of geometry and some trig which doesn't suit me all that well (I'd love to go back and enroll in those high school advanced math courses I never took). As I'm going along it has started using a 'turtle' program written in tk. It's kinda interesting to play with, but not my particular cup of tea. All in all it's enough of a contrast to the Byte of Python book I'm going to use both going forward.

I was also given a copy of the 1999 version of Learning Python from O'Reilly. Now I normally like and use O'Reilly books all the time, but this one seems a bit dangerous for a newbie to to use. It covers Python up to version v1.5, and while I don't know how much has changed since then, even a quick flip through shows me the style is different than I've been exposed to so far, and I don't want to start out learning depreciated ideas and syntax styles. Unless somebody tells me different, I'll just keep it around as reference material.

There was another interesting tidbit came out of that IRC channel discussion. At one point I indicated I was starting to get a feel for the syntax, but not the terminology Python users. A poster (sorry! didn't record who you were!) emphasised that getting the terminology right is important! His point was that you have to be able to think about your problems accurately and concisely, and to do that, you have to grok the terminology properly. Fuzzy logic leads to fuzzy programs. I wish I could quote him/her verbatim - it was much more compelling there than I can make it sound now.

Object orientated programming is starting to make more sense as a concept, but I still don't know how to design programs that use the concept properly. Breaking a problem down as a series of steps, then writing code that completes the steps is a logical way to program that that comes naturally to me (and most others I bet). OO doesn't seem to apply to that style properly, but I'm just not sure what to replace it with yet. Pointers welcome.

Completing the exercises (not slavishly, but doing them a little bit my way) has been helpful - picking up common syntax errors etc and getting my head back in programming space. Committing to bzr and pushing to launchpad working very well - just need to improve quality of my comments and get more consistent timing on my commits.


I have to say that the quantity and quality of information combined with the friendly to the newbie atmosphere I'm finding all over the 'Net is really encouraging me that Python truely is a great language to learn and use all the time! Let's keep it rollin'

Wednesday, February 4, 2009

A Space In The Right Place Saves Nine

Experienced programmers please set down any hot liquids before proceeding. The following comments are from a beginning programmer, and as such, will likely promote laughter among those who know better. That's why I'm writing this - you guys just can't regress all the way back to this level of ignorance easily :-)

The one thing everybody knows about Python is that whitespace is significant, and it's really a pain. OK, so now that I can do 'Hello World' in three - count 'em three! - different scripting languages, what do I think about Python syntax?

I just don't see why everybody thinks it's hard. To me, it's a breath of fresh air! So far, the only time I've seen that white space matters is leading whitespace to set off a block of statements.
There's no 'end' to that block except the ending of the indentation. OK, so it's something to keep in mind. On the other hand, bash's use the $ when you assign the value and not when you use it is a lot more confusing. And don't get me started on Perl. When to use a ( vs a { vs a [ is a lot harder to figure out, and $ or % or @ for variables ain't exactly simple either. Yes, Perl logically hangs together, and I get the fact that you should know which symbol to use when based on what you are trying to do, and what kind of data you are storing. I even appreciate the fact that it's a form of error checking - because if you use the wrong symbol because of a logical error it'll catch it for you.

On the other hand, in Python a variable is a variable regardless of the contents. The programmer has to keep it straight in his head rather than the syntax enforcing it. It might make things more error prone, but it sure makes it easier to read. The lack of end of line characters in particular is refreshing, unlike bash's 'you might want to use a semi-colon here - or not...

So, if you were thinking that counting spaces was a necessary evil in Python, forget it, and just try it out and see what you think!

Sunday, February 1, 2009

How's It Going?

When we last saw our brave hero, he'd just emerged victorious from his struggle over the dog pack of FLOSS project hosting choices, but the looming battle against the three headed dog of Python, Bazaar and Object Orientated Programming was yet to begin.... Will he survive to see another day?

Sorry - Rocket Robin Hood flashback. Thanks Teletoon Retro....

Just a quick update on where I'm at. I've set up a project on Launchpad. That was a straightforward click n' drool kinda thing. Just fill in the blanks where required. I spent some very constructive time reading the documentation. It's got lots of information on all the various Launchpad features (and there are quite a few) but I was most struck by the amount of 'why' as well as 'how' in the information. Since I've not been exposed to project management per se before, it was good for me to see how the website was designed around a project flow, rather than the other way around, and expose me to the common steps most projects go through.

I had already registered my GPG key when I signed the code of conduct earlier, so I just had to create and upload an ssh key for use with bazaar. It took me a bit of twiddling to get that working, mainly because I wanted a separate launchpad key from my regular ssh key. My regular key is already used in too darned many places. The twiddling was purely self inflicted - launchpad was working perfectly all along :-)

Next up, I went looking for some docs to get me started on learning Python. A quick inquiry in the (newly created) Python group on identi.ca pointed me at 'A Byte of Python'. Turns out it's licensed CC and available for download.

As I work my way through the examples, I've been creating the them in GVim. Another bit of Googling followed with an identi.ca query found me some pointers for using Python in Vim. As I've created each example and tested them, I've committed them to a +junk repository and pushed it up to Launchpad. This post by Paul Hummer made getting that all set up painless and simple.

Are you seeing a trend here? I'm using Linux, SSH, GPG, GVim, Identi.ca, Python, A Bite of Python, and a blog posting by a Launchpad dev. All of it FLOSS. All of it no charge. All of it quality information and tools - downloaded off the internet by nothing more than the sweat of my little pinkies. It's just amazing when you sit back and think about it. It's downright flippin' awesome in fact.

Thank you one and all that made this happen, and continue to make it happen. Hopefully I can do my little part too, and keep the steamroller rolling.