Some Useful Scripts

Posted on August 13, 2010 | Stephen

I am always searching for some simple scripts to make my life easier. Here are a few that I have used.

This script removes the spaces from file names and directories. It replaces them with the underscore "_". It must be run several times due to the changes in `find` when a directory name has changed.


#!/bin/sh
find . -name '* *' | while read file;
do
target=`echo "$file" | sed 's/ /_/g'`;
echo "Renaming '$file' to '$target'";
mv "$file" "$target";
done;


This script I have used to concatenate large numbers of ascii text files. It adds a column for the file name so the final output file has a reference back to the original file.


#!/bin/sh
for i in `ls *.[Rr][Ss][Ff]`
do
awk '{print "\"" FILENAME "\"\t" "\"xxx\"" "\t" $0}' $i >> outfile.txt
done

Fixing FreeBSD 8.0 HD

Posted on August 03, 2010 | Stephen

I had a mental lapse the other day and hit the reboot button while the system was loading. What an idiot! After rebooting the system, it would shutdown after 15-20 minutes of uptime. There were cases of excessive sync numbers and the partitions were flagged as "not properly unmounted". After some searches on the 'net, I remembered that for fsck to repair the damage, I would have to run it on unmounted partitions. This solved the problem.

Ripping Music with FreeBSD

Posted on April 02, 2010 | Stephen

Now that I have a larger hard drive, I figured it was time to rip my CD collection. I am running FreeBSD 8.0 on and AMD 64 X2 CPU. I looked on the internet for possible KDE programs to make ripping look pretty, but I found some issues with the programs Audex and KcD. Neither program recognized my CD player even though I configured the program to look at the correct device. There is something missing in my knowledge of KDE (so what else is new?). After a trip through the audio ports, I settled on and old favorite and a new twist--cdparanoia and abcde. I knew that for my favorite Jazz CDs and other special music I wanted a lossless format as my archive format. I chose flac for these archive files and setup the audio/flac port along with audio/lame and audio/vorbis-tools. Most of the popular music I just rip as mp3 or ogg to save space. Once I set the abcde.conf file, all rips were filed to my liking and the CD information look-up filled in the album name, artist and track name/number. Two of the finer applications for KDE with regard to music are Amarok and JuK. JuK allows me to adjust the mp3 tags very easily and it sorts the music into neat and clean play lists. Amarok has better audio handling, but it lask the ease of editing the mp3 tags. Between the two, I use them evenly.

FreeBSD 8.0

Posted on March 11, 2010 | Stephen

I finally got around to updating my system to FreeBSD 8.0 after scraping together some money to buy my first SATA HDD (500GB for ~$60.00). Prior to this upgrade, I was running FreeBSD 6.3 from two 40 GB HDD attached to the single ATA port on the Gigabyte GA-MA78GPM-DS2H motherboard. Plugging in the SATA HDD freed the ATA port for my ATA CD drives. Eventually I will replace the CD drives with SATA CD drives, but at the moment the system is working well. Next, I will create a custom kernel. Followed by the real fun--installing my favorite ports.

My first port will be IceWM. I use IceWM as my primary WM; I only need to switch to the larger "complete" WM like KDE4 when I have M$ files to work with. The next ports I will install are Firefox and lynx_ssl. When I have questions, I need internet answers. I will also install some of these: R, mplayer, ProFTP, OpenSSH, last.fm, KDE games (gotta have some fun), EBoard to play chess on FICS, maybe Crafty, Freeciv, xmame or sdlmame, possibly PennMUSH for goofing off and writing silly code, and some other stuff. I used to load Apache, but I don't keep my website at home.

Most importantly, with this motherboard's USB 2.0 I finally got my Western Digital 160GB USB external hard drive to mount. It took a lot of internet searching, but I finally found the missing links. When I plug it in to mount, it shows up on ugen2.2. First I had to disable USB Legacy support in the BIOS and then mount the drive with the following command:

>mount_msdosfs -o large /dev/da0s1 /mnt

R, gfortran, lapack and mpfr

Posted on March 01, 2010 | Stephen

I have been trying to update to R-2.9.2 (R-Project) on my FreeBSD 6.2 system and ran into the problem of loading lang/gfortran. It was looking for shared library "gmp.7", which is available through math/libgmp4, but it loaded lib/libgmp.so.8 which is not recognized as "gmp.7". I symbolically linked lib/libgmp.so.8 to lib/libgmp.so.7 and it passed the requirement. After that linked allowed the system to keep making gfortran the math/mpfr also had a linking problem that I fixed the same way.

I got most of it to work, but when I try to install R, it still craps out on gfortran. I can't quite get gfortran to install completely.

I made sure that my gcc* was gcc4.4 and that /usr/bin/gcc was linked to /usr/local/bin/gcc44. I also rebuilt math/lapack and then rebuilt math/blas. Finally, I deinstalled R (I was try to avoid this until I had a completed "make") and executed "make install clean" That finally make a complete build and usable R program. I don't know if I had to deinstall or link the correct gcc. Somehow, it just worked.

For Eterm, I had to link /usr/local/lib/libImlib2.so.5 to /usr/local/lib/libImlib2.so.3 so that it would work.

GiB GB MiB MB bit Byte

Posted on October 25, 2009 | Stephen

one byte 1 B = 8 bit

one kibibit 1 Kibit = 210 bit = 1,024 bit
one kilobit 1 kbit = 103 bit = 1,000 bit

one mebibyte 1 MiB = 220 B = 1,048,576 B
one megabyte 1 MB = 106 B = 1,000,000 B

one gibibyte 1 GiB = 230 B = 1,073,741,824 B
one gigabyte 1 GB = 109 B = 1,000,000,000 B

NTLDR is missing

Posted on September 24, 2009 | Stephen

I have recently transfered my HDs from my old MB to my new MB and now the Windows 2000 partition will not boot. I have a dual boot system that boots into FreeBSD but not into the Windows. I get this error: NTLDR is missing.

GA-MA78GPM-DS2H Motherboard

Posted on September 22, 2009 | Stephen

I recently switched from an ABIT KX7-333 socket A MB to the Gigabyte GA-MA78GPM-DS2H MB that supports 64 bit processors.

Nickel Rockets

Posted on April 23, 2009 | Stephen

I was going to write this up, but the following link did a very good job.

http://www.ductape.net/~spy007/nickel.html

Air Cannon Physics

Posted on April 21, 2009 | Stephen

My suggestion is to take the experimental route for this. Measure values of muzzle velocity against pressure and then find the relation between the two so you have a method to predict the muzzle velocity based on the pressure. Ideally you should use something that can directly measure the muzzle velocity, if not you'll need to do calculations to take air resistance into account in the values you do measure (like how far the projectile goes).