I’ve been spending most of my free time learning Java. My goal is to master the basics enough to obtain an SCJP. I picked up a copy of Head First Java 2nd Edition, and have been very impressed with it so far. The first nine chapters have been fun to read, and quite informative. The book recommends I attempt to explain what I’m learning, as the process will help the concepts stick to my brain. I will attempt to post my learning experience here.
Learning Java with Head First Java
July 1st, 2008Windows PowerShell Execution Policies
May 28th, 2008Windows Powershell sets its Execution Policy to Restricted by default, which states that PowerShell can only be used in interactive mode (no scripts will run.) Use the Get-ExecutionPolicy cmdlet to check which execution policy is currently in-force.
$ Get-ExecutionPolicy
The following execution policy definitions are from Microsoft’s website:
- Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
- AllSigned – Only scripts signed by a trusted publisher can be run.
- RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
- Unrestricted – No restrictions; all Windows PowerShell scripts can be run.
To change the execution policy, use Set-ExecutionPolicy. The following will enable you to execute all PowerShell scripts.
$ Set-ExecutionPolicy Unrestricted
2008 Jamis Nova Pro
May 27th, 2008
Friday I purchased a 54cm 2008 Jamis Nova Pro from The Bike Shop in Houghton. I’ve been shopping for an all-purpose bicycle since March, and believe the Nova Pro best suits my wants and needs. I plan to ride to work, and attempt at least one cyclo-cross race in the fall.
The Nova Pro has the following attractive selling points:
- Carbon Fork
- Carbon fiber seat stays
- Fender capable
- Comfortable geometry
- Weight: 21 lbs
- Full overview and specifications
The Bike Shop threw in caged pedals, a water bottle, bottle holder, a free tune-up after 30 days, free “adjustments” for the lifespan of the bike, and 15% off MSRP.
Update: I wrote a brief 2008 Jamis Nova Pro Review.
Windows PowerShell - Recursively delete files and directories modified more than ‘n’ days ago.
May 22nd, 2008I was recently tasked with writing a script that recursively deletes files and directories modified more than ‘n’ days ago - here’s the kicker - using Windows. Many people have accomplished this with long VB Scripts. I was hoping for a much cleaner solution, and decided to try Windows PowerShell . I am quite impressed with Windows Powershell’s capabilities.
The following script recursively deletes files and directories modified more than 16 days ago.
# prune.ps1
$sticky = (Get-date).AddDays(-16)
$backupDir = "B:\backup"
echo "Recursively deleting files and directories written before $sticky"
Get-ChildItem $backupDir -Recurse | Where-Object { $_.LastWriteTime -lt $sticky } | Remove-Item -Recurse
Note that you can change Remove-Item -Recurse to Remove-Item -Whatif to “pretend” to delete files, and display potential deletes on STDOUT. You can also specify Remove-Item -Confirm.
I created a scheduled task that runs a .bat file containing the following:
powershell.exe c:\scripts\prune.ps1 >> c:\scripts\logs\prune.log
To watch and or view the output of the script, specify the -noexit switch on the command line.
powershell.exe -noexit c:\scripts\prune.ps1
How to install NVIDIA drivers with Fedora 9
May 20th, 2008Update: The current (173.14.09) stable NVIDIA driver works with Fedora 9. The following information is outdated and kept for archival purposes.
The latest stable NVIDIA drivers will not install when using the version of X.org that is distributed with Fedora 9. I was able to use NVIDIA’s beta 172.08 display drivers after a few manipulations.
Version 172.08 does not support ABI, so I placed the following in /usr/bin/startx
defaultserverargs="-ignoreABI"
I also commented the following from /etc/X11/xorg.conf
# Load "glx"
Fedora 9 and NVIDIA Drivers x86_64 Instructions
Download the appropriate beta driver
$ wget http://us.download.nvidia.com/XFree86/
Linux-x86_64/173.08/NVIDIA-Linux-x86_64-173.08-pkg2.run
Run the installer
$ sh NVIDIA-Linux-x86_64-173.08-pkg2.run
Edit /usr/bin/startx (for runlevel 3 users) and add the following:
defaultserverargs="-ignoreABI"
Edit /etc/X11/xorg.conf and comment the following:
# Load "glx"
Upgrade to Fedora 9
May 16th, 2008I upgraded my primary workstation to Fedora 9 this week. Although the upgrade was mostly uneventful, I did struggle with a few annoyances.
The latest revision of openbox lacks a specific functionality that’s vital to my coherent work flow. It lacks the ability to hold down the left mouse button on the title bar, and use the scroll wheel to migrate the currently held window to the next or previous desktop. It was easy to roll back to a previous version from the Fedora Core 6 Extras repository.
Another annoyance is that konsole removed the –noxft switch in their latest revision, this allowed me to prevent my terminals from having anti-aliased fonts. I use the font Terminus (highly recommended, by the way) within my terminals, and having that anti-aliased is just unacceptable. I could just disable anti-aliasing across all applications, but then my browser and mail client would look terrible. I was able to solve this issue with ~/.fonts.conf.
The last issue I had was with pulseaudio. Sound was very soft, even with the speakers and alsamixer set to 100%. I removed alsa-plugins-pulseaudio, and things started functioning normally.
I tried KDE again this week, and was dissapointed (as usual.) It was quite sluggish, and seemed very kludged together. Maybe someone will develop a feature-full window manager that doesn’t require big iron to run before I’m a gray-beard. They would then have to convince me that it is indeed better to have all that eye candy, yeah right.
Software raid 1 - Failing and recovering a disk
April 29th, 2008A software raid group disk failed in one of my servers yesterday.
The kernel was spewing SCSI errors:
kernel: ata2: status=0xd0 { Busy }
kernel: SCSI error : return code = 0×8000002
# mdadm --display /dev/md0
# mdadm --display /dev/md1
both reported a failed disk sdb*
The procedure to rebuild the md groups is as follows:
Replace bad disk (sdb in this scenario.) Note that if you do not bring down the server to replace the disk, be sure to “remove” the disk from the raid groups using mdadm.
# mdadm --remove /dev/md0 /dev/sdb0
# mdadm --remove /dev/md1 /dev/sdb1
Read the good disk’s partition table (sda in this scenario.)
# fdisk -l /dev/sda
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 19457 156183930 fd Linux raid autodetect
Install identical partition table on newly replaced disk. Create partitions that start and end on the same listed cylinders and are of type “fd.” Be sure to set the boot flag, and don’t forget to write the changes.
# fdisk /dev/sdb
Add partitions back to the appropriate raid groups.
# mdadm --add /dev/md0 /dev/sdb0
# mdadm --add /dev/md1 /dev/sdb1
Ensure the raid groups are rebuilding properly.
# mdadm --display /dev/md0
# mdadm --display /dev/md1
Steelhead count: 0
April 22nd, 2008
Friday night, good friends arrived with fishing gear in anticipation of our annual expedition. After a night of celebration (and not much sleep) we woke at 04:45 and drove to the Huron river in Skanee, MI. This was our first time fishing this popular area, so we were surprised to see the abundance of other fishermen. The weather was decent, but the water temperature was still too cold for the fish to “run” in full force. Although our party was fruitless, we saw five Steelhead caught over the weekend. With the rising water temperature, I expect the fish to be more prevalent by this weekend. I plan to try my luck at least once more.
Searching and executing with find(1)
April 17th, 2008This afternoon I was faced with searching a directory tree for large files that have rotated within the last 24 hours - a symptom of a problem we were experiencing with a service.
Here’s what I put together quickly:
# find -iname name-\*.log -mtime 0 -exec du -sh {} \;
Explanation of the switches (from the find man page):
-iname pattern
Base of file name (the path with the leading directories removed) matches case insensitive shell pattern pattern
-mtime n
data was last modified n*24 hours ago.
-exec command {} \;
run the specified command on the matched files
It’s not complex (and probably not post-worthy,) but someone may find it helpful.
SIGMA BC 1606L DTS
April 15th, 2008In preparation for the bicycle purchase, I ordered a SIGMA BC 1606L DTS bike computer. I haven’t opened it yet, but it looks quite neat. I look forward to obsessing over my speed and distance, and will probably buy the add-on cadence monitor. No bike-shopping updates yet, I’ll be test-riding James’s 2006 Trek 1500 tomorrow after work.
