Saturday, February 25, 2012

Launching Linux Fireball

Since late 2011, I've found myself doing a lot more Linux administration than Mac. In light of that, I am launching a new Linux blog that will have a lot of overlap with Command Line Mac.

Mostly for my own convenience, I'll be copying a lot of the Unix/Linux only posts over to the new blog. I'll still be posting here when I run across something interesting in the Mac world, but I expect the other blog to be much more active this year.

Adventures with Airport Express

After the failure of my cable TV/Internet service last month, and the slow response of the cable company, I dumped cable in favor of satellite+DSL. It was an inconvenient process to say the least. When it was done, I needed to connect the satellite DVR to the wireless DSL router to enable additional features.

The DVR had a USB wireless adapter, but because of the location of router, the signal was not quite strong enough to make the connection work. I had a spare Airport Express and my first thought was to use it to extend the DSL router network. Before doing any research, I made manual changes to the Airport Express that rendered it a brick. Doh!

I found a helpful article at Apple Support that let me reset it to factory settings. Then, I finally did the research and found that the plain Express can't be used to extend a 2WIRE wireless router.

The next strategy was to set up a separate wireless network and plug the Airport Express into one of the wired ports on the router. The Airport Express provided a stronger signal that the 2WIRE and allowed me to connect the DVR to the Internet. The only modification I had to make from a basic configuration was to turn off network address translation (NAT) on the Airport Express to avoid a double NAT situation since the 2WIRE also provided NAT. The Airport Express actually detected the problem and made the suggestion when I connected to it with the Airport Utility. Apple really has some very nicely thought out software in their hardware.

Thursday, November 17, 2011

Ruby: Sorting an array with multiple fields

I was working on a project today and needed to make some changes to the way an array on objects was sorted before being displayed on the screen. The main reason I even bothered to post this is to heap a little more praise on Ruby for working the way I expected it to work.

Here was my object (not tied to a database, just created for convenience):
class Force
attr_accessor :id
attr_accessor :last_name
attr_accessor :first_name
attr_accessor :rank
attr_accessor :shift
attr_accessor :promoted_on
attr_accessor :phone
attr_accessor :totalcount
end
I needed to sort an array of these objects by rank ascending, shift ascending, then promoted_on (date) descending.

I sorted them by concatenating the fields together and making the right comparisons. This only works because the first two fields, rank and shift, cannot be empty. Otherwise, a simple concatenation would create undesired results.

Sorting all fields ascending looks like this:
@forces = @forces.sort {|x,y| x.shift + x.rank + x.promoted_on.to_s <=> y.shift + y.rank + y.promoted_on.to_s}
To sort the promoted_on field in descending order, reverse the x,y sides for that field:
@forces = @forces.sort {|x,y| x.shift + x.rank + y.promoted_on.to_s <=> y.shift + y.rank + x.promoted_on.to_s}
No need for a special sort coding block. Ruby FTW!

Thursday, October 6, 2011

Steve Jobs RIP

Steve Jobs RIP

Sunday, September 18, 2011

The Chromium OS experiment

Google's Chromium OS

I downloaded a bootable ISO of the Google Chromium OS release candidate. Then, fired it up in VMware Player and took a look around. It appears to be based on OpenSUSE Linux 11.4. SUSE was one of the distributions I cut my teeth on in the Linux world. I always appreciated the 9 pound manual of documentation that came with it. Very helpful for beginners and a good reference to their tools.

I might have made a mistake when setting up the virtual machine because it complained of low memory right after booting. This could also explain the slow performance I experienced. The desktop itself is clean and appears to be optimized to run the Chrome web browser. There was a local word processing application, but I didn't get far enough to test it out, it was just too slow. I could not find a download link at Google, but I found one at a .eu domain. Maybe it was a pirated or tampered version. I am going to postpone further research until I am sure I have a good distribution.

Updated: Turns out Google doesn't provide an image or download of the OS itself, only the source code and compilation instructions. Also, the OS is based on Ubuntu, despite the build I got from Europe based on SUSE. ZD Net suggested that the running OS would be slow so I maybe I am not missing much at this stage of development. I don't want to pay for a Chromebook just to run Chrome. Another reason to keep this on hold for now.

Wednesday, July 20, 2011

Getting by in Git

Git is the source code management system used for the Linux kernel and many other highly complex projects. It was written by Linux Torvalds after some controversy over the proprietary Bitkeeper program that used to manage the Linux kernel.

I've needed to upgrade my skills recently to use git in place of subversion because that is what my shop decided to use. I've moved all my Rails code into a remote git server and so far, so good.

One improvement is it has fewer "droppings" than subversion. There is no hidden .svn directory in each directory with source code. Only a single .git directory at the root of the project, plus a .gitignore file for files you don't want git to track.

Initialize project tracking
git init

Check out an existing project from remote server
git clone ssh://server/git/project

Add a file for git to track
git add

Add all files from this directory and below for git to track
git add .

Commit all files to local repository
git commit -a -m "message"

Undo changes to a file (re-check out from repository)
git checkout --

Pull files from remote repository and merge with local repository
git pull

Push files to remote repository (must commit first)
git push

Move file or directory to new location
git mv path destination

Remove file or directory from the working tree
git rm path

To create a remote repository from an existing project takes several steps
cd /tmp
git clone --bare /path/to/project (creates a /tmp/project.git directory)
scp project.git to remote server
cd /path/to/project
git remote add origin ssh://server/git/project
git config branch.master.remote origin
git config branch.master.merge refs/heads/master

Thursday, May 26, 2011

LVM basics

I've just spent a few hours with iSCSI SAN disks (EqualLogic) and Linux Logical Volume Manager (LVM). The abstraction is even deeper than that, because Linux at work is running under VMware, so it is really VMware talking to the SAN and presenting a SCSI disk to Linux. Since I only get into the LVM weeds a couple of times a year, I thought it would be helpful to list the steps I took to get usable disk space under Linux starting with the raw disk space.

Step One - create a new partition
Create a new partition with FDISK or PARTED. Mark the partition type hex 8E for LVM. In my case, the SCSI disk appeared as /dev/sdb and the partition using all space became /dev/sdb1. LVM is capable of using a raw device (no partition type), but I stayed in familiar partitioning territory.

Step Two - create LVM physical volume
pvcreate /dev/sdb1

Step Three - create LVM volume group in the physical volume
vgcreate new_volume_group /dev/sdb1

Step Four - create LVM logical volume in the volume group
lvcreate --name new_logical_volume --size 100G new_volume_group

Step Five - create a file system on the logical volume
mkfs -t ext4 /dev/mapper/new_volume_group-new_logical_volume
Note: Linux device mapper automatically creates a symlink to the disk in /dev/mapper using the volume group and logical volume names. If you choose more meaningful names than the example, the name won't look so awful.

Step Six - turn off automatic file system checks (optional)
tune2fs -c 0 /dev/mapper/new_volume_group-new_logical_volume

Step Seven - add mount point in /etc/fstab
Once the mount point is list in fstab, mount it manually and it is ready to use.