hack of the day

08/25/2001
Default key repeat rates are always too slow.
sudo echo "keyboard.repeat.del1=200" >> /etc/wsconsctl.conf
sudo echo "keyboard.repeat.deln=50" >> /etc/wsconsctl.conf
echo "xset r rate 200 50" >> $HOME/.xsession

01/14/2002
Finally using cvs to manage my HTML source and rsync to keep a synchronized backup of my web page on my home network.

  • Make sure you're running OpenBSD (duh!).
  • Install rsync from the ports tree (/usr/ports/net/rsync).
  • Create a CVS repository:
    env CVSROOT=$HOME/cvs cvs init
    
  • Download cvsroot.tar.gz and untar it from $HOME/cvs/CVSROOT.
  • Import your homepage sources:
    cd /path/to/homepage/sources
    env CVSROOT=$HOME/cvs cvs import -m 'Initial import' ModuleName YourName YourName_YYYY-MMM-DD
    
    where ModuleName is a CVS module name you must assign to your sources. I recommend simply "html".

  • Now update the rsync command in $HOME/cvs/CVSROOT/loginfo with the appropriate source and destination directories for your homepage sources. This will cause your local source to be synced with your remote homepage files on every commit. Change the -m aaron to -m user@host to have CVS log messages mailed to you. All log messages will accumulate into $HOME/cvs/CVSROOT/ChangeLog.
  • 02/07/2002
    Some friends and I occasionally play Reaction Quake 3. Since we're spread around the continent now, we also keep in touch via IRC. I wanted public messages on our IRC channel to be broadcast to any current game players. Using ethereal (which happens to have a Quake III Arena decoder), I captured some traffic and discovered how simple the protocol is. So simple, in fact, I easily combined printf(1) and nc(1) to achieve my goal:
    /on -public "* #channel *" /exec printf "\\777\\777\\777\\777rcon p4ssw0rd say \\"<$0 $1> $2-\\"" | nc -w 1 -u quake.server.com >/dev/null 2>&1
    

    05/04/2002
    Setup Samba between my Windows XP box and main OpenBSD workstation.

  • Make sure you're running OpenBSD (duh!).
  • Install samba from the ports tree (/usr/ports/net/samba).
  • Edit configuration files so required daemons will start at boot-time:
    sudo echo smbd=YES >> /etc/rc.conf.local
    sudo echo nmbd=YES >> /etc/rc.conf.local
    
    and add the following lines to /etc/rc.local:
    if [ -f /etc/samba/smb.conf ]; then
    	if [ X"${smbd}" = X"YES" -a -x /usr/local/libexec/smbd ]; then
    		echo -n ' smbd';    /usr/local/libexec/smbd -D
    	fi
    	if [ X"${nmbd}" = X"YES" -a -x /usr/local/libexec/nmbd ]; then
    		echo -n ' nmbd';    /usr/local/libexec/nmbd -D
    	fi
    fi
    

  • Add a shared user:
    sudo useradd -c 'Shared User' -d /home/shared -p shared -s /sbin/nologin shared
    

  • Tell samba about the shared user:
    smbpasswd -a shared
    

  • Now create a usable /etc/samba/smb.conf configuration file. Here's an example:
    server string = Barrington
    workgroup = SHARED
    encrypt passwords = yes
    interfaces = 192.168.0.251/32
    dns proxy = no
    
    # A publicly accessible directory, but read only, except for people in
    # the "staff" group
    [mp3]
       comment = MP3 Share
       path = /home/shared/mp3
       public = yes
       writable = no
       printable = no
    

  • Start samba:
    sudo /usr/local/libexec/smbd -D
    sudo /usr/local/libexec/nmbd -D
    

  • In Windows XP, go to Control Panel -> System -> Computer Name and click on the Change... button. Make sure Workgroup is selected and enter "SHARED" into the text field.
  • Finally, to access the new share, open Windows Explorer, click on My Network Places, then click View Workgroup Computers. You should see your OpenBSD box in the list. If it's not there, wait a few minutes, and try refresh.
  • 12/27/2002
    Compile Mozilla 1.2.1 for OpenBSD 3.2-current.

  • Install OpenBSD i386 snapshot from 12/26/2002 or later (for gcc/propolice bugfix).

  • Download Mozilla source from ftp://ftp.mozilla.org/pub/mozilla/releases/mozilla1.2.1/src/mozilla-source-1.2.1.tar.gz and untar into your homedir.

  • Apply the following patch to the sources:
    --- mozilla/security/nss/lib/freebl/unix_rand.c.orig    Fri Dec 27 14:19:38 2002
    +++ mozilla/security/nss/lib/freebl/unix_rand.c Fri Dec 27 13:48:36 2002
    @@ -78,7 +78,7 @@
     }
     
     #if defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(FREEBSD) \
    -    || defined(NETBSD) || defined(NTO) || defined(DARWIN)
    +    || defined(NETBSD) || defined(NTO) || defined(DARWIN) || defined(OPENBSD)
     #include 
     
     #define getdtablesize() sysconf(_SC_OPEN_MAX)
    

  • Place the following into mozilla/.mozconfig:
    # sh
    # Build configuration script
    #
    # See http://www.mozilla.org/build/unix.html for build instructions.
    #
    
    #ac_add_options --enable-svg
    # Options for 'configure' (same as command-line options).
    ac_add_options --disable-mailnews
    ac_add_options --disable-accessibility
    ac_add_options --enable-crypto
    ac_add_options --disable-debug
    ac_add_options --enable-strip
    ac_add_options --disable-shared
    ac_add_options --enable-static
    

  • Run ./configure and compile with gmake. If the configure script complains about missing packages, install them from ports (i.e., you'll need gtk, orbit, etc).

  • When complete, use the following script to run from your homedir:
    #!/bin/sh
    cd ~/mozilla
    if [ -f dist/bin/components/compreg.dat ]; then
            rm dist/bin/components/compreg.dat
    fi
    export LD_LIBRARY_PATH=~/mozilla/dist/lib
    ~/mozilla/dist/bin/mozilla $1
    
  • $Id: hotd.html,v 1.5 2004/09/26 23:47:17 aaron Exp $