Thursday, December 30, 2004

select random file

This bash script will come in handy with my idea of using habak in a
cron job to update the background to my screen every hour:
------------
#!/bin/bash
DIR=~/wallpaper
nfiles=$(ls -1 $DIR | wc -l | tr -d ' ')
fileno=$(( ($RANDOM % $nfiles) + 1 ))
FILE=$DIR/$(ls -1 $DIR | head -n $fileno | tail -n 1)
echo $FILE
------------

Thanks to Joshua Oreman
(http://lists.freebsd.org/pipermail/freebsd-questions/2003-August/016689.html)
for the script. Also, another possible script is randfile found at
http://www.shelldorado.com/scripts/quickies/randfile

Tuesday, December 28, 2004

WalMart Earth Shoe==garbage footwear

Needed some new shoes two months ago and bought a pair of casual Earth Shoes at WalMart ($26.97). Took a couple of days for the lining to start becoming unstitched. After a couple of weeks the interior heel was completely worn. By now (two months passed) the shoes are flat-soled static generators. I've been psychologically traumatized when I reach for grounded items. Continuous zapping becomes increasingly unpleasant.

Dockers Glacier was the decided replacement. If we had an REI near my place I would've purchased the Dunham Rutland. First day has been pleasant, nice arch support (which was another lacking element of the Earth Shoe). Anyhow, beware the Earth Shoe from WalMart. See it has low price, see it appears gentle on the pocketbook but, lo, it will strike from behind and crush they investment!

Tuesday, December 21, 2004

MySQL Hibernate and Timestamp issues

Long day trying to figure out a problem with passing a null value on a
Hibernate object that corresponds to a Timestamp field in MySQL. You
can't do it because MySQL interprets the null to mean "insert current
time", and so it does. But, in your sql statement you can place '' and
the column will remain null. After looking through the forums the
general suggestion is the DateTime type to get around this issue.
Because we'll be using Oracle in production anyway (both types map to
Date) this is a moot point--we need to update all of our Timestamps to
DateTime and manually set the values per record.

Thursday, December 16, 2004

updated prompt

This one is a bit more concise
PS1="\n\[\033[35m\]\$(/bin/date)\n\[\033[32m\]\w\n\[\033[1;31m\]\u@\h:
\[\033[1;34m\]\$(/usr/bin/tty | /bin/sed -e 's:/dev/::'):
\[\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g')
files \[\033[1;33m\]\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed
's/total //')b\[\033[0m\] -> \[\033[0m\]"

nifty bash promp

PS1="\n\[\033[35m\]\$(/bin/date)\n\[\033[32m\]\w\n\[\033[1;31m\]\u@\h:
\[\033[1;34m\]\$(/usr/bin/tty | /bin/sed -e 's:/dev/::'):
\[\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g')
files \[\033[1;33m\]\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed
's/total //')b\[\033[0m\] -> \[\033[0m\]"

syncolor.vim

/usr/share/vim/vim64/syntax/syncolor.vim

" Vim syntax support file
" Maintainer: Bram Moolenaar
" Last Change: 2001 Sep 12

" This file sets up the default methods for highlighting.
" It is loaded from "synload.vim" and from Vim for ":syntax reset".
" Also used from init_highlight().

if !exists("syntax_cmd") || syntax_cmd == "on"
" ":syntax on" works like in Vim 5.7: set colors but keep links
command -nargs=* SynColor hi
command -nargs=* SynLink hi link
else
if syntax_cmd == "enable"
" ":syntax enable" keeps any existing colors
command -nargs=* SynColor hi def
command -nargs=* SynLink hi def link
elseif syntax_cmd == "reset"
" ":syntax reset" resets all colors to the default
command -nargs=* SynColor hi
command -nargs=* SynLink hi! link
else
" User defined syncolor file has already set the colors.
finish
endif
endif

" Many terminals can only use six different colors (plus black and white).
" Therefore the number of colors used is kept low. It doesn't look nice with
" too many colors anyway.
" Careful with "cterm=bold", it changes the color to bright for some terminals.
" There are two sets of defaults: for a dark and a light background.
if &background == "dark"
SynColor Comment term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE
gui=NONE guifg=#80a0ff guibg=NONE
SynColor Constant term=underline cterm=NONE ctermfg=Magenta
ctermbg=NONE gui=NONE guifg=#ffa0a0 guibg=NONE
SynColor Special term=bold cterm=NONE ctermfg=LightCyan ctermbg=NONE
gui=NONE guifg=Orange guibg=NONE
SynColor Identifier term=underline cterm=bold ctermfg=Cyan
ctermbg=NONE gui=NONE guifg=#40ffff guibg=NONE
SynColor Statement term=bold cterm=NONE ctermfg=Yellow ctermbg=NONE
gui=bold guifg=#ffff60 guibg=NONE
SynColor PreProc term=underline cterm=NONE ctermfg=LightBlue
ctermbg=NONE gui=NONE guifg=#ff80ff guibg=NONE
SynColor Type term=underline cterm=NONE ctermfg=LightGreen
ctermbg=NONE gui=bold guifg=#60ff60 guibg=NONE
SynColor Underlined term=underline cterm=underline ctermfg=LightBlue
gui=underline guifg=#80a0ff
SynColor Ignore term=NONE cterm=NONE ctermfg=black ctermbg=NONE
gui=NONE guifg=bg guibg=NONE
else
SynColor Comment term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE
gui=NONE guifg=Blue guibg=NONE
SynColor Constant term=underline cterm=NONE ctermfg=LightYellow
ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE
SynColor Special term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE
gui=NONE guifg=SlateBlue guibg=NONE
SynColor Identifier term=underline cterm=NONE ctermfg=DarkCyan
ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE
SynColor Statement term=bold cterm=NONE ctermfg=Brown ctermbg=NONE
gui=bold guifg=Brown guibg=NONE
SynColor PreProc term=underline cterm=NONE ctermfg=DarkMagenta
ctermbg=NONE gui=NONE guifg=Purple guibg=NONE
SynColor Type term=underline cterm=NONE ctermfg=DarkGreen
ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE
SynColor Underlined term=underline cterm=underline
ctermfg=DarkMagenta gui=underline guifg=SlateBlue
SynColor Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE
gui=NONE guifg=bg guibg=NONE
endif
SynColor Error term=reverse cterm=NONE ctermfg=White ctermbg=Red
gui=NONE guifg=White guibg=Red
SynColor Todo term=standout cterm=NONE ctermfg=Black ctermbg=Red
gui=NONE guifg=Blue guibg=Yellow

" Common groups that link to default highlighting.
" You can specify other highlighting easily.
SynLink String Constant
SynLink Character Constant
SynLink Number Constant
SynLink Boolean Constant
SynLink Float Number
SynLink Function Identifier
SynLink Conditional Statement
SynLink Repeat Statement
SynLink Label Statement
SynLink Operator Statement
SynLink Keyword Statement
SynLink Exception Statement
SynLink Include PreProc
SynLink Define PreProc
SynLink Macro PreProc
SynLink PreCondit PreProc
SynLink StorageClass Type
SynLink Structure Type
SynLink Typedef Type
SynLink Tag Special
SynLink SpecialChar Special
SynLink Delimiter Special
SynLink SpecialComment Special
SynLink Debug Special

delcommand SynColor
delcommand SynLink

ls colors

# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
#
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
#
# $Header: /var/cvsroot/gentoo-x86/sys-apps/coreutils/files/DIR_COLORS,v
1.3 2004/06/30 15:13:00 vapier Exp $

# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR tty

# Extra command line options for ls go here.
# Basically these ones are:
# -F = show '/' for dirs, '*' for executables, etc.
# -T 0 = don't trust tab spacing when formatting ls output.
OPTIONS -F -T 0

# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM linux-c
TERM mach-color
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM xterm
TERM xterm-color
TERM xterm-debian
TERM color-xterm
TERM color_xterm
TERM rxvt
TERM screen
TERM screen-w
TERM vt100
TERM dtterm
TERM ansi
TERM Eterm

# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 37 # global default, although everything should be something.
FILE 37 # normal file
DIR 01;36 # directory
LINK 01;33 #symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointer to.)
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 01;05;37;41 # orphaned syminks
MISSING 01;05;37;41 # ... and the files they point to

# This is for files with execute permission:
EXEC 01;32

# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')

.cmd 01;32 # executables (bright green)
.exe 01;32
.com 01;32
.btm 01;32
.bat 01;32
.sh 01;32
.csh 01;32

.tar 01;31 # archives or compressed (bright red)
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z 01;31
.Z 01;31
.gz 01;31
.bz2 01;31
.bz 01;31
.tbz2 01;31
.tz 01;31
.deb 01;31
.rpm 01;31
.rar 01;31
.ace 01;31
.zoo 01;31
.cpio 01;31

.jpg 01;35 # image formats
.jpeg 01;35
.gif 01;35
.bmp 01;35
.ppm 01;35
.tga 01;35
.xbm 01;35
.xpm 01;35
.tif 01;35
.tiff 01;35
.png 01;35
.mng 01;35
.xcf 01;35
.pcx 01;35
.mpg 01;35
.mpeg 01;35
.m2v 01;35 # MPEG-2 Video only
.avi 01;35
.mkv 01;35 # Matroska (http://matroska.org/)
.ogm 01;35 # Ogg Media File
.mp4 01;35 # "Offical" container for MPEG-4
.m4v 01;35 # MPEG-4 Video only
.mp4v 01;35 # MPEG-4 Video only
.mov 01;35 # Quicktime (http://developer.apple.com/qa/qtw/qtw99.html)
.qt 01;35 # Quicktime (http://developer.apple.com/qa/qtw/qtw99.html)
.wmv 01;35 # Windows Media Video
.asf 01;35 # Advanced Systems Format (contains Windows Media Video)
.rm 01;35 # Real Media
.rmvb 01;35 # Real Media Variable Bitrate
.flc 01;35 # AutoDesk Animator
.fli 01;35 # AutoDesk Animator
.gl 01;35
.dl 01;35

.pdf 00;32 # Document files
.ps 00;32
.txt 00;32
.log 00;32
.tex 00;32
.doc 00;32

.mp3 00;36 # Audio files
.wav 00;36
.mid 00;36
.midi 00;36
.au 00;36
.ogg 00;36

Wednesday, December 15, 2004

Jedit macros

Thanks to Scalex in the JEdit community forums, I wrote a bunch of auto completion macros based upon some code he posted. I've saved each of these snippets my ~/.jedit/macros/.bsh and then associated each one as a short cut. That is, to initiate the bracket completion I assigned it to the "[" key as a shortcut. These are really basic and I plan to make updates (especially to the LOG one) as
I have time. For now they work and it's rather slick.

for auto quotes in JEdit:
-------------
buffer_mode = buffer.getMode().toString();
if (buffer_mode.equals("java")
||buffer_mode.equals("xml")
||buffer_mode.equals("html")) {
textArea.setSelectedText("\"\"");
textArea.goToPrevCharacter(false);
} else {
textArea.setSelectedText("\"");
}
-------------
for auto brackets:
-------------
buffer_mode = buffer.getMode().toString();
if (buffer_mode.equals("java")) {
textArea.setSelectedText("{");
textArea.insertEnterAndIndent();
textArea.setSelectedText("}");
textArea.shiftIndentLeft();
textArea.goToPrevLine(false);
textArea.goToEndOfWhiteSpace(false);
textArea.insertEnterAndIndent();

} else{
textArea.setSelectedText("{");
}
--------------
for auto parenthesis:
--------------
buffer_mode = buffer.getMode().toString();
if (buffer_mode.equals("java")) {
textArea.setSelectedText("()");
textArea.goToPrevCharacter(false);
} else {
textArea.setSelectedText("(");
}
--------------
for auto LOG debug statements:
--------------
textArea.setSelectedText("if(LOG.isDebugEnabled()){");
textArea.insertEnterAndIndent();
textArea.setSelectedText("LOG.debug()");
textArea.goToEndOfWhiteSpace(false);
textArea.setSelectedText(";");
textArea.insertEnterAndIndent();
textArea.setSelectedText("}");
textArea.shiftIndentLeft();
--------------

mysql startup script

Created this script as "mysql" in /etc/init.d and then executed
"rc-update add mysql default"
-------------
#!/sbin/runscript

start () {
ebegin "Starting mysqld..."
/usr/local/share/mysql/mysql.server start
eend ${?}
}

stop () {
ebegin "Stopping mysqld..."
/usr/local/share/mysql/mysql.server stop
eend ${?}
}
-------------

emerge rpm

In the course of getting the Lexmark T632 working on the new Gentoo box we followed the previous post I made a couple months back. There were a couple of things I failed to include the first time. Turns out that to get rpm properly working it requires db3. This can be obtained by emerging openldap (which is something else we needed anyway). Also, the Lexmark installation won't work if you don't have CUPS emerged.

Tuesday, December 14, 2004

mysql #2

To get the manually-built mysql to startup at boot a script file (that basically wraps the mysql.server script) is required in /etc/init.d. I'll include the script in a future post...

mysql 4.1.3

Needed to get MySQL 4.1.3 working on the new Gentoo laptop and we
downloaded the binary distribution. But it croaked immediately upon
startup with a signal 11. Rather lengthy bug threads didn't provide us
with much information so we simply downloaded the source and built it.
That did it, mysqld_safe now works.

xorg 6.8.0-r3

Installing Gentoo on another Dell D800. Had a slight issue with the Keyboard driver in the xorg.conf. The xorg.conf that I have didn't work on the new version (my version was 6.7.0-r1 compared to 6.8.0-r3). Slight tweaking and we had it working with the "kbd"
driver rather than "Keyboard".

Monday, December 13, 2004

himem needed for laptop memory upgrade

Just received two 1G DIMMs for the old D800 and what to my surprise to see that cat /proc/meminfo only shows 900MB! That was my old amount. Hmmmmm...no good. Turns out, thanks to bcowan on #gentoo, that "himem" needs to be set to 4GB in the linux kernel config or else 900MB is the max recognizable. Easy solution and I'm now cruising with 2026MB. Beautiful.

Thursday, December 09, 2004

Biometrics and linux

Interested in this topic but I haven't found much yet (little effort here) other than the BioAPI that NIST released earlier. This http://librenix.com/?inode=3912 got me thinking...