Archive for April, 2009

Installing Vista Fonts in Ubuntu

Installing Vista Fonts in Ubuntu

Microsoft’s new ClearType fonts for Vista are great. The fonts include Constantia, Corbel, Calibri, Cambria, Candara and Consolas.

Getting them installed in Ubuntu is a breeze, thanks to a script I found.
To install the Vista ClearType fonts in Ubuntu, you need to install cabextract first. Cabextract is a utility found in the universe repository, so before you run the following command, make sure you have universe enabled in your repository list. Once this is done, install cabextract using:

No Comments

Perl One-Liners

Perl one liners I hate having to search for everytime I need it.

# the always present hello world program
    perl -e 'print "Hello World!\n"'

    # rename in each file name the string aaa by bbb
    ls | perl -ne 'chomp; next unless -e; $o = $_; s/aaa/bbb/; next if -e; rename $o, $_'; 

    # add first and last column in each line of file foo.txt and print it out
    perl -lane 'print $F[0] + $F[-1]' foo.txt

    # print lines 15 to 17 of file foo.txt
    perl -ne 'print if 15 .. 17' foo.txt

    # a second way to print lines 3 to 5 of file foo.txt
    perl -pe 'exit if 3<$. && $.<5' foo.txt

    # change all words "foo"s to "bar"s in every .c file and keep backups
    perl -p -i.bak -e 's/\bfoo\b/bar/g' *.c

    # the same but without backup. Remember the flags: "eat the pie"
    perl -p -i -e 's/foo/bar/g' *.c

    # changes ^M newline characters to newlines
    perl  -p -i -e 's/\012?\015/\n/g'  $1

    # the same but with all files with name filename
    perl -p -i -e  's/foo/bar' `find . -name "filename"`

    # substitution can also be applied to binary files like test.ppm
    perl -p -i -e 's/255/127/g' test.ppm

    # substitute "xyz.math" to "abc.math" in every .html file and keep backups
    perl -p -i.bak -e 's/xyz\.math/abc\.math/g' *.html

    # insert department name after each title and keep backup
    perl -p -i.bak -e 's#<title>#<title>Harvard .: #i' *.html

    # delete first 10 lines in foo.txt and keep backup foo.txt.bak
    perl -i.bak -ne 'print unless 1 .. 10' foo.txt

    # change isolated occurrence of aaa to bbb in each file *.c or *.h
    perl -p -i.bak -e 's{\baaa\b}{bbb}g' *.[ch]

    # reverses lines of file foo.txt and print it
    perl -e 'print reverse <>' foo.txt

    # find palindromes in a dictionary /usr/share/dict/words
    perl -lne 'print if $_ eq reverse' /usr/share/dict/words

    # reverses paragraphs in file foo.txt
    perl -00 -e 'print reverse <>' foo.txt

    # increments all numbers in foo.tx by 1
    perl -pe 's/(\d+)/ 1 + $1 /ge' foo.txt

    # reverses order of characters in each line of foo.txt
    perl -nle 'print scalar reverse $_' foo.txt

    # print lines beween START and END in foo.txt to STDOUT
    perl -ne 'print if /^START$/ .. /^END$/' foo.txt

    # delete lines beween START and END and backup original file
    perl -i.old -ne 'print unless /^START$/ .. /^END$/' foo.txt

    # look for duplicated words in a line
    perl -0777 -ne 'print "$.: doubled $_\n" while /\b(\w+)\b\s+\b\1\b/gi' foo.txt

    # start Perl debugger "stand-alone"
    perl -d -e 42

    # run a Perl program with warnings
    perl -w

    # run a Perl program with debugger
    perl -d

    # Run perl program, check syntax, print warnings
    perl -wc

No Comments

Mysql MLB Pitch FX data

Pitch FX data from 2007 to current.

Please help with bandwidth costs for this download by donating.

I have imported all the pitch f x data from for 2007, to current date using Fastballs wordpress site.  It is available in a mysql export.  Please let me me know if you have any questions, or issues with this download. Please comment and I will get back with you.  If you are looking for game data please check out the retrosheet database I have made available for download  here.

UPDATE 10/23/2009

I have re-imported everything since 2007 up to today, and have it available for download. I will be removing the pbp.sql files, and only going forward with the pbp2.sql which is the pitchfx with pitch type. I should have this done by the time baseball is over. :( Let me know if you have any questions. I fixed a couple of games that had hit errors where a runner didn’t reach base the system didn’t know what to do with that, so I used a sledge hammer to get rid of the no base runner hit errors. It could also be data import errors but who knows.




Ubuntu 9.04 Converting an ext3 filesystem to ext4

Ubuntu 9.04

Converting an ext3 filesystem to ext4

It is possible to mount both ext3 (and ext2, in kernels 2.6.28 and later) filesystems directly using the ext4 filesystem driver. This will allow you to use many of the in-core performance enhancements such as delayed allocation (delalloc) and multi-block allocation (mballoc), and large inodes if your ext3 filesystem have been formatted with large inodes as is the default with newer versions of e2fsprogs. Simply mounting an ext3 (or ext2) filesystem with a modern (2.6.27+) version of ext4 will not change the on-disk structures, and it is possible to revert to the ext3 (or ext2) driver should there be any problem with ext4.

In addition to the in-core performance enhancements, there are additional features which modify the on-disk format from what ext3 understands, such as extents, which can significantly improve the ext4 filesystem performance, but mean the filesystem cannot be mounted by kernels that do not support ext4. There are additional ext4 features, such as flex_bg and > 16TB filesystem support that can only be enabled at format time via mke2fs.

To change an ext2 filesystem (should you still have one) to ext3 (enabling the journal feature), use the command:

# tune2fs -j /dev/DEV

To enable the ext4 features on an existing ext3 filesystem, use the command:

# tune2fs -O extents,uninit_bg,dir_index /dev/DEV

WARNING: Once you run this command, the filesystem will no longer be mountable using the ext3 filesystem!

After running this command, you MUST run fsck to fix up some on-disk structures that tune2fs has modified:

# e2fsck -fD /dev/DEV

NOTE: by enabling the extents feature new files will be created in extents format, but this will not convert existing files to use extents. Non-extent files can be transparently read and written by Ext4.

WARNING: It is NOT recommended to resize the inodes using resize2fs with e2fsprogs 1.41.0 or later, as this is known to corrupt some filesystems.

No Comments

Ubuntu upgrade from 8.10 to 9.04 Desktop and Server

Upgrading from Ubuntu 8.10 Desktop to Ubuntu 9.04 Desktop

To upgrade from Ubuntu 8.10 on a desktop system, press Alt+F2 and type in “update-manager -d” (without the quotes) into the command box. Update Manager should open up and tell you: New distribution release ’9.04′ is available. Click Upgrade and follow the on-screen instructions.

Upgrading from Ubuntu 8.10 Server to Ubuntu 9.04 Server

To upgrade from Ubuntu 8.10 on a server system: install the update-manager-core package if it is not already installed; edit /etc/update-manager/release-upgrades and set Prompt=normal; launch the upgrade tool with the command sudo do-release-upgrade; and follow the on-screen instructions.

No Comments

Xten X-lite install on Ubuntu 9.04

Installing Xten X-lite on Ubuntu 9.04 Jaunty Jackalope.
Xten X-lite
The other day I was looking for a soft phone on my Ubuntu 9.04 desktop, and am used to X-lite on my windows machines, but have not found a soft phone that i like on Linux yet. Ekiga is to commercial, and Twinkle very basic. So I decided to try the Xten X-lite install on my Ubuntu Jaunty Jackalope desktop. I ran into so issues, and have provided instructions for a Xten X-lite install on Ubuntu 9.04. Please follow my steps closely, and your Xten X-lite Ubuntu 9.04 setup will be completed in no time.

1.) Aquire Xten X-lite from Counterpaths website.

$ wget

2.) Untar X-lite_install.tar.gz for use.

$ tar -xzvf X-Lite_Install.tar.gz

This will create a xten-xlite directory with a README file, and the xtensoftphone binary.

3.) Install libstdc++5 which is required to run the xtensoftphone binary.

$ sudo apt-get install libstdc++5

4.) Start the Xten X-lite software on Ubuntu 9.04 and configure it for your phone system.

$ xten-xlite/xtensoftphone

I was not very pleased with this version of Xten X-lite for Linux, but I do like the windows version, and I guess I will be sticking to my twinkle soft phone for now.  When Counterpath gets off it’s butt and builds a newer version of the X-lite for Linux I will try to install it again on my Ubuntu 9.04 Desktop. Please let me know if you have any questions or issues with these instructions and feel free to look at some of my other pages. Nvidia 6200 Xorg.conf with Twinview setup Ubuntu 9.04 Juanty Jackalope or Ubuntu 9.04 BIND DNS Caching server


Ubuntu 9.04 BIND DNS Caching server

BIND, for /Berkeley Internet Name Domain, or named, is the most
commonly used DNS server on the Internet, especially on Unix-like
systems, where it is a /de facto/ standard.  I have found many reasons for a BIND DNS Caching server, and a few of them are email servers to prevent the load from spilling onto your dns servers, apache web servers for the same reason, and for my internal home server just so I can clear my BIND DNS caching server when I want.  I especially like having my own BIND DNS caching server when I am working on a clients DNS so once I make the changes I can clear my cache on my DNS server, and test the change. Lets get started on how to install a BIND DNS Caching server on Ubuntu 9.04.

1.) Install BIND 9 and the BIND 9 utils using apt-get for our BIND DNS caching server.

sudo apt-get update
sudo apt-get install bind9 bind9utils

2.) Point your /etc/resolv.conf to the new servers ip address.

vi /etc/resolv.conf
add “nameserver” to the file

3.) Test your BIND DNS caching server.

You should notice a response the “Query time: 18 msec” from the output of the dig command. Once you make note of the response time repeat the dig command and your response time to decrease drastically. Congratulations your BIND DNS caching server is working. For example my second output was “Query time: 2 msec”. A 16 ms increase in DNS queries might not seem like alot, but when you use spamassassin with DNS options turned on you can make 10-30 DNS queries per email. It adds up quickly when your email server receives 4 messages a second.

Other options for your BIND DNS caching server would be to use your ISP’s dns servers as forwarders, but this does not give you the flexibility of clearing your DNS server cache whenever you want.  If you clear your cache you do not clear your ISP’s DNS cache and you will get the same DNS response. 

Note that BIND caches DNS information to RAM and not disk. In most cases this will not be a problem since most machines have plenty of memory and old records are purged from memory after a period of time. However, if you expect your server to get a lot of traffic you may want to periodically flush the cache using the following command.
sudo rndc -s localhost flush

or set the maximum amount of memory to use (in essence forcing overflow data to be deleted before it expires) by setting the max-cache-size option in the configuration file.

No Comments

Ubuntu Iptables Firewall Script for /etc/init.d

I have used alot of diffierent firewall scripts over the years, and I
have fell in love with the following script wriiten by Tero Karvinen It
is a simple Iptables firewall script and it is easy to maintain. Not
alot of variables, and totally customizable. Why would I want anything
else. I have below my mail servers Iptables firewall configuration with
a state hitcount to slow down potential spammers, I have it set for a
mail server that accepts 16 messages a second. That is 1.3 million
emails a day. So the iptables firewall script works. Here is how to
install it.

1.) Copy the following lines.
# Cleanup old rules # All the time firewall is in a secure, closed state
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables –flush # Flush all rules, but keep policies
iptables –delete-chain
## Workstation Minimal firewall ###
iptables -P FORWARD DROP
iptables -P INPUT DROP
iptables -A INPUT -i lo –source –destination -j ACCEPT
iptables -A INPUT -m state –state “ESTABLISHED,RELATED” -j ACCEPT
iptables -A INPUT -p icmp –icmp-type destination-unreachable -j ACCEPT
iptables -A INPUT -p icmp –icmp-type time-exceeded -j ACCEPT
iptables -A INPUT -p icmp –icmp-type echo-request -j ACCEPT
iptables -A INPUT -p icmp –icmp-type echo-reply -j ACCEPT
####### HOLES ####### Edit holes below, then run this script again
# munin
iptables -A INPUT -p TCP -s –destination-port 4949 -j ACCEPT
# mysql
iptables -A INPUT -p TCP -s –destination-port 3306 -j ACCEPT
# nagios
iptables -A INPUT -p TCP -s –destination-port 5666 -j ACCEPT
# sshd
iptables -A INPUT -p TCP -s –destination-port 22 -j ACCEPT
iptables -A INPUT -p TCP -s –destination-port 22 -j ACCEPT
# smtp
iptables -A INPUT -p TCP –dport 25 -j ACCEPT
iptables -I INPUT -p TCP –dport 25 -i eth0 -m state –state NEW -m recent –set
iptables -I INPUT -p TCP –dport 25 -i eth0 -m state –state NEW -m recent –update –seconds 600 –hitcount 45 -j DROP
# pop
iptables -A INPUT -p TCP -s 0/0 –destination-port 110 -j ACCEPT
# imap
iptables -A INPUT -p TCP -s 0/0 –destination-port 143 -j ACCEPT
# 587
iptables -A INPUT -p TCP -s 0/0 –destination-port 587 -j ACCEPT
##################### Edit above
# iptables -A INPUT -j LOG -m limit –limit 40/minute
iptables -A INPUT -j DROP
# Save
# iptables-save > /etc/sysconfig/iptables
echo “: Done.”#!/bin/sh
2.) Open /etc/init.d/ with your favorite editor.

$ sudo vi /etc/init.d/

3.) Paste script into your editor, and edit the ports to your liking. Make sure your are in insert mode in vi before you paste.

4.) Change permissions to all execute on the file.

$ sudo chmod 744 /etc/init.d/

5.) Start the script

$ sudo /etc/init.d/

6.) Add the script to start-up

$ sudo update-rc.d defaults

Please let me know if you have any questions about this really easy and nice Ubuntu iptables firewall script. Like I said I have tried a bunch and this is the best iptables firewall script I have found.

No Comments

Ubuntu Subinterfaces

I have found myself searching the internet for the correct configuration for Linux subinterfaces.  A subinterface is a division of one physical interface into multiple logical interfaces.  So why would we do that?  I use subinterfaces for hosting multiple SSL sites, DSR returns for localhost for my load balancers, and anything else you would need multiple ips on the same physical interface.  In Ubuntu it is easy to add subinterfaces I have never had to add a temporary subinterface in Ubuntu but I guess I figure it is easier to just add it to the system and restart networking.  Here is how to add a Ubuntu subinterface with ifconfig.

Adding a Ubuntu subinterface without restarting networking.

1. Add the interface and ip with one step

$ sudo ifconfig eth0:0 netmask

2. Turn the ip address up

$ sudo ifconfig eth0:0 up

3.  Check and make sure it is in ifconfig

$ ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:30:48:28:65:2b
inet addr:  Bcast:  Mask:
inet6 addr: fe80::230:48ff:fe28:652b/64 Scope:Link
RX packets:101278725 errors:10 dropped:0 overruns:0 frame:10
TX packets:96594294 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3734515707 (3.7 GB)  TX bytes:1773845088 (1.7 GB)

eth0:0    Link encap:Ethernet  HWaddr 00:30:48:28:65:2b
inet addr:  Bcast:  Mask:

4. Remember the subinterface is gone unless you add it to /etc/network/interfaces.

Adding a Ubuntu subinterface permanently.

Now that you have added the subinterface without restarting networking, and or rebooting we need to add the ip address to the configuration file on Ubuntu so the new ip address will be on the system when you do some upgrades and need to reboot

1.  Open the /etc/network/interfaces file with your favorite editor

$ sudo vi /etc/network/interfaces

2. Add the following lines below your physical interface to create the subinterface on reboot.

auto eth0:0
iface eth0:0 inet static

3. You can always add more Ubuntu subinterfaces by changing eth0:0 to eth0:1 and eth0:2 and so on.

Here is  and example of my complete /etc/network/interfaces file with Ubuntu subinterfaces.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static

auto eth0:0
iface eth0:0 inet static


Nvidia 6200 Xorg.conf with Twinview setup Ubuntu 9.04 Juanty Jackalope

I had some issues setting up the Nvidia 6200 xorg.conf with Twinview since I went from 7.10 Gutsy Gibbon to 9.04 Jaunty Jackalope alpha 6. My previous video card lost a fan over the weekend while I was gone, and overheated. I purchased the Nvidia 6200 AGP card cause I thought I would have not issues setup up my xorg.conf twinview. I remember when I installed 7.10 Gutsy Gibbon on my work desktop, and I had no issues once I installed the Nvidia drivers using apt-get install nvidia-kernel-common. Going into this install I thought it was going to be a breeze to configure the Nvidia 6200 xorg twinview. I was wrong, and am just putting up my xorg.conf, and creating a place for you all to ask some questions about my Nvidia 6200 xorg.conf Twinview setup. I love Nvidia, xorg, and twinview, and I know you will also. So good luck configuring your twin monitors with your Nvidia 6200. Below is my /etc/X11/xorg.conf please feel free to take what you like, and bitch about what I did wrong.

$ cat /etc/X11/xorg.conf
Section “Monitor”
Identifier “Monitor0″
VendorName “Unknown”
ModelName “Samsung SyncMaster”
HorizSync 30.0 – 81.0
VertRefresh 56.0 – 75.0
Option “DPMS”
# HorizSync source: edid, VertRefresh source: edid

Section “Screen”
Identifier “Screen0″
Device “Device0″
Monitor “Monitor0″
Option “TwinView” “1″
Option “TwinViewXineramaInfoOrder” “CRT-0″
Option “metamodes” “CRT-0: 1280×1024 +0+0, CRT-1: nvidia-auto-select +1280+0; CRT-0: 1280×1024 +0+0, CRT-1: 1280×1024 +1280+0; CRT-0: 1024×768 +0+0, CRT-1: 1024×768 +1024+0; CRT-0: 1024×768 +0+0, CRT-1: NULL”
DefaultDepth 24
SubSection “Display”
Depth 24

Section “Module”
Load “dbe”
Load “extmod”
Load “type1″
Load “freetype”
Load “glx”

Section “InputDevice”
Identifier “Mouse0″
Driver “mouse”
Option “Protocol” “auto”
Option “Device” “/dev/psaux”
Option “Emulate3Buttons” “no”
Option “ZAxisMapping” “4 5″

Section “InputDevice”
Identifier “Keyboard0″
Driver “kbd”
# generated from default

Section “ServerLayout”
Identifier “Layout0″
Screen 0 “Screen0″ 0 0
InputDevice “Keyboard0″ “CoreKeyboard”
InputDevice “Mouse0″ “CorePointer”

Section “Device”
Identifier “Device0″
VendorName “NVIDIA Corporation”
BoardName “GeForce 6200″
Driver “nvidia”
Option “NoLogo” “True”

Section “ServerFlags”
Option “Xinerama” “0″