Posts by author RevRagnarok

Temporary File Descriptors (FDs) in Bash

Found this useful the other day when I needed an FD and not a file name… in my example, I was testing some python code where C++ was doing the heavy lifting and was going to pass an open FD to python.

exec {tempo}<> scratchfile
echo ${tempo}
ls -halF /proc/self/fd
command --fd=${tempo}

From https://stackoverflow.com/a/41620630/836748

Migrated Again

Wow. I've had this blog since 2002. Waaay back in the day, it was some proprietary format, and I migrated it 13 years ago to trac.

At that time, it was on a dedicated Red Hat box that also acted as my firewall.

At some point since then, I migrated it to vmware - see that topic for some of the problems.

Originally that VM image ran on my CentOS server (cf. https://bugs.centos.org/view.php?id=3884 ) and some point it was migrated to my Windows 7 desktop.

Since it was in a VM, I could always snapshot and really beat on it. I had files as far back as 2001 and GPG signatures for my RPMs from Red Hat OS before it was Fedora/RHEL split. Over the years, I've managed to beat it into submission to the point I had it running Fedora 31; of course it's built-in now with dnf system-upgrade. But that's not the point. Fedora 32 broke Python2, and trac isn't there yet. (Side note - the VM has been called webmail for years, but I uninstalled SquirrelMail and moved to Google-hosting many years ago.)

With the COVID-19 quarantine, I decided to migrate this blog to containers so I can just use a pre-defined trac container and go on my merry way. Hopefully less maintenance in the future.

So, that's where it is now. As I tested the site from my wife's iPad (on cellular) I just had to marvel at how data travels to get this post out of my house:

(you) <=> (Cloudflare) <=> OpenWrt <=> Win10 Pro <=> Hyper-V Docker VM <=> Container [Ephemeral] <=> Docker Volume

WiFi Checker for OpenWrt

It's been a while since I dumped anything here… hope I can post…

I have OpenWRT on my home router and it's using a secondary chipset to run a guest-only network that sometimes randomly drops out. I've been told they no longer support it in that manner, which explains a lot. Anyway, in case my config gets nuked, here's what I did:

# cat /etc/crontabs/root
* * * * * /etc/custom_scripts/guest_check.sh
# cat /etc/custom_scripts/guest_check.sh
#!/bin/sh
if iwinfo | grep -iq ragnarok_guest; then
  rm -f /tmp/guest_down
  exit 0
fi
if [ -e /tmp/guest_down ]; then
  echo "$(date) -- REBOOTING" > /var/log/guest_check
  reboot
fi
touch /tmp/guest_down
echo "$(date) -- DOWN" > /var/log/guest_check
#service network stop
#service network start
wifi down
wifi up

Spoofing an RPM's host name

I came up with this method years ago, and thought I posted it, but couldn't find it. So here's the latest incarnation:

# This spoofs the build host for both 32- and 64-bit applications

# To use:
# 1. Add libmyhostname as a target that calls rpmbuild
# 2. Add "myhostnameclean" as a target to your "clean"
# 3. Call rpmbuild or any other program with $(SPOOF_HOSTNAME) prefix

MYHOSTNAME_MNAME:=$(shell uname -m)
libmyhostname:=libmyhostname_$(MYHOSTNAME_MNAME).so
MYHOSTNAME_PWD:=$(shell pwd)
SPOOF_HOSTNAME:=LD_PRELOAD=$(MYHOSTNAME_PWD)/myhostname/\$$LIB/$(libmyhostname)

.PHONY: myhostnameclean
.SILENT: myhostnameclean
.IGNORE: myhostnameclean
myhostnameclean:
        rm -rf myhostname

# Linux doesn't support explicit 32- vs. 64-bit LD paths like Solaris, but ld.so
# does accept a literal "$LIB" in the path to expand to lib vs lib64. So we need
# to make our own private library tree myhostname/lib{,64} to feed to rpmbuild.
.PHONY: libmyhostname
.SILENT: libmyhostname
libmyhostname: /usr/include/gnu/stubs-32.h /lib/libgcc_s.so.1
        mkdir -p myhostname/lib{,64}
        $(MAKE) -I $(MYHOSTNAME_PWD) -s --no-print-directory -C myhostname/lib   -f $(MYHOSTNAME_PWD)/Makefile $(libmyhostname) MYHOSTARCH=32
        $(MAKE) -I $(MYHOSTNAME_PWD) -s --no-print-directory -C myhostname/lib64 -f $(MYHOSTNAME_PWD)/Makefile $(libmyhostname) MYHOSTARCH=64

.SILENT: /usr/include/gnu/stubs-32.h /lib/libgcc_s.so.1
/usr/include/gnu/stubs-32.h:
        echo "You need to install the 'glibc-devel.i686' package."
        echo "'sudo yum install glibc-devel.i686' should do it for you."
        false

/lib/libgcc_s.so.1:
        echo "You need to install the 'libgcc.i686' package."
        echo "'sudo yum install libgcc.i686' should do it for you."
        false

.SILENT: libmyhostname $(libmyhostname) libmyhostname_$(MYHOSTNAME_MNAME).o libmyhostname_$(MYHOSTNAME_MNAME).c
$(libmyhostname): libmyhostname_$(MYHOSTNAME_MNAME).o
        echo "Building $(MYHOSTARCH)-bit version of hostname spoofing library."
        gcc -m$(MYHOSTARCH) -shared -o $@ $<

libmyhostname_$(MYHOSTNAME_MNAME).o: libmyhostname_$(MYHOSTNAME_MNAME).c
        gcc -m$(MYHOSTARCH) -fPIC -rdynamic -g -c -Wall $<

libmyhostname_$(MYHOSTNAME_MNAME).c:
        echo "$$libmyhostname_body" > $@

define libmyhostname_body
#include <string.h>
#include <asm/errno.h>

int gethostname(char *name, size_t len) {
        const char *myhostname = "buildhost_$(MYHOSTNAME_MNAME).myprojectname.proj";
        if (len < strlen(myhostname))
                return(EINVAL);
        strcpy(name, myhostname);
        return(0);
}
endef
export libmyhostname_body

Chrome on CentOS 7

So my Google Chrome on my CentOS 7 box updated, and SELinux doesn't like it.

There's an official bug for it - https://bugzilla.redhat.com/show_bug.cgi?id=1251996 - but I don't know when that will propagate down.

Until then, here's what I did, with some plaintext showing what was happening:

$ sudo grep chrome /var/log/audit/audit.log | grep setcap | audit2allow
#============= chrome_sandbox_t ==============

#!!!! This avc is allowed in the current policy
allow chrome_sandbox_t self:process setcap;

$ sudo grep chrome /var/log/audit/audit.log | grep setcap |
audit2allow -M chrome.pol
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i chrome.pol.pp

$ cat chrome.pol.te

module chrome.pol 1.0;

require {
        type chrome_sandbox_t;
        class process setcap;
}

#============= chrome_sandbox_t ==============

#!!!! This avc is allowed in the current policy
allow chrome_sandbox_t self:process setcap;

$ sudo semodule -i chrome.pol.pp

Learning git

I've been using subversion for at least a decade now. I was going to switch to a git-based project so wanted to learn. I think I finally get the differences, especially with the "index." These are the resources I used:

And finally:

Goodbye Netflix

Wow. I just checked, and I've had Netflix since 08/10/2001. Over thirteen years. Longer than my marriage. Two houses ago. I'm down to the cheapest one-at-a-time plan, and I still get around to it every three or four months.

I think it's time to say goodbye.

But here's how they get you to stay:

Based on your 1698 ratings, this is the list of movies and TV shows you've seen. 

Yeah… thirteen and a half years of data that I don't want to lose! And that's my main account - I have two other profiles too. I searched the 'net for a solution, and came up with a lot. None worked. GreaseMonkey ones. PHP ones. None worked.

This was the closest: https://gist.github.com/tloredo/8483682

But I don't have a Mac, so I needed to manually capture that info. Ninety pages of ratings. So I used DownThemAll!. I opened the download manager manually, and for the URL I used http://dvd.netflix.com/MoviesYouveSeen?pageNum=[1:90] - I had manually determined 90 with some trial and error. This saved all the pages to files named MoviesYouveSeen.htm and then MoviesYouveSeen_NNN.htm.

I modified the script to read these HTML files instead of launching Safari. After that, the ratings were off - every movie in the file would have the rating of the first in the file. So I tweaked that. For some reason, some don't show a rating in the HTML, even when these were supposedly rated. Some are "No Interest," but others, I just don't know what happened. So I have it output 0.0 if it couldn't figure it out - a 99% solution.

Here are my changes from the gitlab (17 Jan 2014) version (depending on screen width, you might have to scroll way down):

  • .py

    old new  
     1#!/bin/env python
     2# Original @ https://gist.github.com/tloredo/8483682
    13"""
    24Scrape a user's Netflix movie ratings by automating a Safari browsing
    35session (with the user already logged in).  The ratings are written
     
    106108
    107109from jinja2 import Template
    108110from lxml import html
     111import re
     112
     113fname_regex = re.compile(r'(\w+?)_?(\d+)?\.(\w+)')
     114rating_regex = re.compile(r'You rated this movie: (\d)\.(\d)')
    109115
    110116
    111117# AppleScript functions asrun and asquote (presently unused) are from:
     
    159165    All values are strings.
    160166    """
    161167    # Load the page, grab the HTML, and parse it to a tree.
    162     script = ASTemplate.render(URL=url, DTIME=dtime)
    163     reply = asrun(script)
     168    reply = ''
     169    try:
     170      with open(url) as infile:
     171        for str_ in infile:
     172          reply += str_
     173    except IOError:
     174      return [], None
     175
     176
    164177    tree = html.fromstring(reply)
    165178    rows = tree.xpath('//table[@class="listHeader"]//tr')
    166179
     
    180193            # changing from page to page.  For info on XPath for such cases, see:
    181194            # http://stackoverflow.com/questions/8808921/selecting-a-css-class-with-xpath
    182195            # rating = data[3].xpath('//span[@class="stbrMaskFg sbmfrt sbmf-50"]')[0].text_content()
    183             rating = data[3].xpath('//span[contains(concat(" ", normalize-space(@class), " "), " stbrMaskFg ")]')[0].text_content()
    184             rating = rating.split(':')[1].strip()  # keep only the number
     196            rating_cut = rating_regex.match(data[3].text_content())
     197            rating = '0.0'
     198            if rating_cut:
     199               rating = "%s.%s"%(rating_cut.group(1), rating_cut.group(2))
     200
    185201            info.append((title, year, genre, rating))
    186202
    187203    # Next URL to load:
    188     next_elem = tree.xpath('//li[@class="navItem paginationLink paginationLink-next"]/a')
    189     if next_elem:
    190         next_url = next_elem[0].get('href')
    191     else:  # empty list
    192         next_url = None
     204    fname_cut = fname_regex.match(url)
     205    if fname_cut:
     206      if None == fname_cut.group(2):
     207        num = 0
     208      else:
     209        num = fname_cut.group(2)
     210      next_url = "%s_%03.f.%s"%(fname_cut.group(1),int(num)+1,fname_cut.group(3))
     211    else:
     212      print "Regex failed."
     213      next_url = None
     214
    193215
    194216    return info, next_url
    195217
    196218
    197219# Use this initial URL for DVD accounts:
    198 url = 'http://dvd.netflix.com/MoviesYouveSeen'
     220url = 'MoviesYouveSeen.htm'
    199221# Use this initial URL for streaming accounts:
    200222# url = 'http://movies.netflix.com/MoviesYouveSeen'
    201223

This renders a lot of the script useless, but there's no benefit in making the diff larger so I didn't trim anything else.

Here's when I ran it across my "TV Queue" account - yeah they're not all TV, sometimes I accidentally rated things with the wrong profile:

$ ./ScrapeNetflixRatings.py
Scraping MoviesYouveSeen.htm
1:  Garmin Streetpilot 2610/2650 GPS (2003) [Special Interest] - 1.0
2:  Six Feet Under (2001) [Television] - 0.0

Scraping MoviesYouveSeen_001.htm
3:  The Thief of Bagdad (1924) [Classics] - 4.0
4:  The Tick (2001) [Television] - 4.0
5:  Michael Palin: Pole to Pole (1992) [Documentary] - 0.0
6:  Kung Fu: Season 3 (1974) [Television] - 0.0
7:  Danger Mouse (1981) [Children & Family] - 3.0
8:  Farscape (1999) [Television] - 3.0
9:  Helvetica (2007) [Documentary] - 3.0
10:  Hogan's Heroes (1965) [Television] - 3.0
11:  The Lion in Winter (2003) [Drama] - 3.0
12:  Monty Python: John Cleese's Best (2005) [Television] - 3.0
13:  Sarah Silverman: Jesus Is Magic (2005) [Comedy] - 3.0
14:  Stephen King's It (1990) [Horror] - 3.0
15:  Superman II (1980) [Action & Adventure] - 3.0
16:  Superman: The Movie (1978) [Classics] - 3.0
17:  Tom Brown's Schooldays (1951) [Drama] - 3.0
18:  An Evening with Kevin Smith 2 (2006) [Comedy] - 0.0
19:  Crimewave (1986) [Comedy] - 2.0
20:  Huff (2004) [Television] - 2.0
21:  Aqua Teen Hunger Force (2000) [Television] - 1.0
22:  The Boondocks (2005) [Television] - 1.0

Scraping MoviesYouveSeen_002.htm
23:  Ricky Gervais: Out of England (2008) [Comedy] - 5.0
24:  Robot Chicken (2005) [Television] - 5.0
25:  Robot Chicken Star Wars (2007) [Comedy] - 5.0
26:  Rome (2005) [Television] - 5.0
27:  Scrubs (2001) [Television] - 5.0
28:  Stewie Griffin: The Untold Story (2005) [Television] - 5.0
29:  Spaced: The Complete Series (1999) [Television] - 0.0
30:  Alice (2009) [Sci-Fi & Fantasy] - 0.0
31:  Best of the Chris Rock Show: Vol. 1 (1999) [Television] - 4.0
32:  The Critic: The Complete Series (1994) [Television] - 4.0
33:  Dilbert (1999) [Television] - 4.0
34:  An Evening with Kevin Smith (2002) [Comedy] - 4.0
35:  John Adams (2008) [Drama] - 4.0
36:  King of the Hill (1997) [Television] - 4.0
37:  The Lone Gunmen: The Complete Series (2001) [Television] - 4.0
38:  Neverwhere (1996) [Sci-Fi & Fantasy] - 4.0
39:  Robin Hood (2006) [Television] - 4.0
40:  The Sand Pebbles (1966) [Classics] - 4.0
41:  The Sarah Silverman Program (2007) [Television] - 4.0
42:  The Silence of the Lambs (1991) [Thrillers] - 4.0

Scraping MoviesYouveSeen_003.htm
43:  Alias (2001) [Television] - 5.0
44:  Alien (1979) [Sci-Fi & Fantasy] - 5.0
45:  Band of Brothers (2001) [Drama] - 5.0
46:  Bleak House (2005) [Drama] - 5.0
47:  Brisco County, Jr.: Complete Series (1993) [Television] - 5.0
48:  Code Monkeys (2007) [Television] - 5.0
49:  Coupling (2000) [Television] - 5.0
50:  Dead Like Me (2003) [Television] - 5.0
51:  Deadwood (2004) [Television] - 5.0
52:  Family Guy (1999) [Television] - 5.0
53:  Family Guy: Blue Harvest (2007) [Television] - 5.0
54:  Firefly (2002) [Television] - 5.0
55:  Futurama (1999) [Television] - 5.0
56:  Futurama the Movie: Bender's Big Score (2007) [Television] - 5.0
57:  The Great Escape (1963) [Classics] - 5.0
58:  Greg the Bunny (2002) [Television] - 5.0
59:  How I Met Your Mother (2005) [Television] - 5.0
60:  MI-5 (2002) [Television] - 5.0
61:  My Name Is Earl (2005) [Television] - 5.0
62:  Police Squad!: The Complete Series (1982) [Television] - 5.0

Scraping MoviesYouveSeen_004.htm


Thanks a ton to the original author, and the full version is attached here for posterity.

IP Address in Python (Windows)

From StackOverflow, my changes:

  • Py3 compat (no big deal)
  • Added DHCP support
  • Use CurrentControlSet (saner IMHO)
Error: Failed to load processor python3
No macro or processor named 'python3' found

Upgrading to Fedora 21

These are mostly my personal note-to-self, but in case it helps somebody else…


fedup - I've used this a few times, and man does it make upgrades easy. I had some key problems but those were easy enough to fix.


My web server was "down" and I was looking at iptables and saw all this stuff about zones, etc. I checked /etc/sysconfig/iptables and it looked good so when I ran system-config-firewall-tui it told me that "FirewallD is active, please use firewall-cmd" - of course, now I see that in the FAQ (I used nonproduct).

It looks like they have a new Firewall Daemon. In the end, all I had to do was:

firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --reload

There are other commands I used in between like --get-services to see what was predefined and --list-services to ensure http was added after the reload.


Since it's in a VM, I do have a screenshot of the happy hot dog that mysteriously isn't in my /var/log/fedup.log file. ;)

C++ Move Semantics

I finally read this and wanted to keep it for posterity.

Awesome Stack Overflow answers (the top two).

Some BOOST examples

I've been trying to learn BOOST lately, and wrote a little program to convert 16-bit sampled data to 8-bit. In theory, you can do other things similar (scaling).

As always, any feedback is welcome. Especially a "proper" C++ way of creating a file of a given size.

// Templated function to convert from one size int to another with automatic scaling factors.
// Doesn't do so well with signed <=> unsigned!
// g++ 16_to_8.cc -o 16_to_8 -lboost_iostreams

// Boost concepts shown/used:
// integer traits (compile-time min/max of a type)
// memory mapped I/O
// (unused) make_iterator_range (converts C-style array into STL-compliant "Forward Range" concept)
// minmax_element (does 3N/2 compares instead of 2N)
// (unused) bind to create on-the-fly lambda-like function for std::transform
// lambda in std::transform
// replace_first for a string

#include <boost/integer_traits.hpp>
#include <iostream>
#include <algorithm>
//unused #include <boost/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/casts.hpp>
#include <boost/iostreams/device/mapped_file.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/algorithm/minmax_element.hpp>
#include <boost/algorithm/string/replace.hpp>

using namespace std;

// Generic read/writer
template <typename intype, typename outtype>
bool ReadWriteScale(const string &infilename, const string &outfilename) {
  using namespace boost;
  using namespace /*boost::*/iostreams;
  using namespace lambda;

  mapped_file_source infile;
  mapped_file_sink outfile;

  try {
        infile.open(infilename);
  } catch (boost::exception &err) {
        cerr << diagnostic_information(err);
        return false;
  };
  size_t insize = infile.size(); // bytes
  if (0 == insize) {
        cerr << "The input file seems empty." << endl;
        return false;
  };
  // Create a new file for output. We'll use old-school C to create the file, and then memory mapped to let the kernel handle paging.
  {
        FILE *outfile_raw = fopen(outfilename.c_str(), "w");
        fseek(outfile_raw, insize / sizeof(intype) * sizeof(outtype) - 1, SEEK_SET);
        const char nil = '\0';
        fwrite(&nil, 1, 1, outfile_raw);
        fclose(outfile_raw);
  }
  try {
        outfile.open(outfilename.c_str());
  } catch (boost::exception &err) {
        cerr << diagnostic_information(err);
        return false;
  };
  
  // Get min/max
  intype min = 0, max = 0;
  const intype *indata = reinterpret_cast<const intype *>(infile.data());
  cout << "Scanning " << insize << " bytes." << endl;
  insize /= sizeof(intype); // Change scale of insize from here on out
  //iterator_range<const intype*> iter = make_iterator_range(indata, indata+insize);
  //pair<const intype*, const intype*> result = minmax_element(iter.begin(), iter.end());
  pair<const intype*, const intype*> result = minmax_element(indata, indata+insize);
  
  // Figure out scaling. TODO: Handle unsigned properly (check const_min == 0)
  const int64_t min64 = static_cast<int64_t>(*result.first);
  const int64_t max64 = static_cast<int64_t>(*result.second);
  //cout << "Factors: " << static_cast<double>(integer_traits<outtype>::const_min) / min64 << ", " << static_cast<double>(integer_traits<outtype>::const_max) / max64 << endl;
  const double scaling_factor = std::min( static_cast<double>(integer_traits<outtype>::const_min) / min64, static_cast<double>(integer_traits<outtype>::const_max) / max64 );
  const double newmin = min64 * scaling_factor;
  const double newmax = max64 * scaling_factor;
  cout << "Scaling factor = " << scaling_factor << " = " << min64 << ":" << max64 << " => " << newmin << ":" << newmax <<
        " [" << static_cast<double>(static_cast<outtype>(newmax)) << "]" << endl;
 
  // Do the caling
  outtype *outdata = reinterpret_cast<outtype *>(outfile.data());
  // transform(indata, indata+insize, outdata, bind(multiplies<double>(), _1, scaling_factor));
  transform(indata, indata+insize, outdata, ll_static_cast<outtype>(_1 * scaling_factor));
  cout << "Processed " << insize << " data points." << endl;
  return true;
};

int main (int argc, char **argv) {
        if (argc != 2) {
                cout << "Usage: " << argv[0] << " filename.16data" << endl;
                exit(99);
        }
        
        // Change file name
        string outfilename(argv[1]);
        boost::replace_last(outfilename, ".16data", ".8data");
                
  // Return zero is success in Unix
  return !ReadWriteScale<int16_t, int8_t>(argv[1], outfilename);
}

Fixing sudo timeouts

So at work, a script needs to download a set of large RPMs and then install them. This is in a Makefile, so if sudo returns a negative, it fails and you need to find the temporary directory, or re-run. sudo can be told to change the timeout, but that seems to only be by modifying /etc/sudoers, not via a commandline option. So if the user walks away during the download and doesn't come back within five minutes (by default) after the download is complete, no dice.

Here's the applicable section of the Makefile:

# We are passed the RPM_BASE_NAME - we will pull down the entire matching directory

ifdef RPM_BASE_NAME
TMP_DIR:=$(shell mktemp -d)
endif

rpminstall:
  echo Fetching $(RPM_BASE_NAME) RPMs...
  # -r=recursive, -nv=non-verbose (but not quiet), -nd=make no directories, -nH=make no host names
  # -P=move to path first, -Arpm=accept only RPM files
  wget -r -nv -nd -nH -P $(TMP_DIR) -Arpm -np $(DLSITE)/$(RPM_BASE_NAME)/
  # If you walk away and come back, your download was wasted after sudo's five minute timeout!
  sudo -n ls /tmp > /dev/null 2>/dev/null || read -n1 -sp "sudo credentials have expired. Press any key when you are ready to continue." dontcare
  echo " "
  sudo -p "Please enter %u's password to install required RPMs: " rpm -Uvh $(TMP_DIR)/*rpm
  -rm -rf $(TMP_DIR)

Raspberry Pi and a BT Keyboard

I bought a Favi Bluetooth keyboard to use with the Raspberry Pi.

I wish I documented better how I got it running. I followed somebody else's page, but don't have the details…

Some of the root user's history:

update-rc.d -f dbus defaults
apt-get install bluetooth bluez-utils blueman
hcitool scan
hcitool dev
hcitool lescan
hcitool inq
hciconfig -a
bluez-simple-agent hci0  54:46:6B:xx:xx:xx
bluez-test-device trusted  54:46:6B:xx:xx:xx yes
bluez-test-input connect 54:46:6B:xx:xx:xx

I added /etc/init.d/bluetooth restart to /etc/rc.local

I possibly added blacklist hci_usb to /etc/modprobe.d/raspi-blacklist.conf

I can't get it to work again, so maybe some day…

Scripting konsole and tabs

At work I want to launch two programs in separate tabs in konsole from a script, so I whipped this one up:

#!/bin/bash

checkfile() {
  if [ ! -f $1 ]; then
    echo "could not find $1"
    exit 99
  else
    echo "OK"
  fi
}

# Check for App1 XML
echo -n "Checking for App 1 XML... "
XMLA=/domain/DM.xml
checkfile ${DEVROOT}/${XMLA}

# Check for App2 XML
echo -n "Checking for App 2 XML... "
hostname=$(hostname)
XMLB=/domain/DM_${hostname}.xml
checkfile ${DEVROOT}/${XMLB}

# Launch Konsole
echo -n "Launching konsole... "
K=$(dcopstart konsole-script)

[ -z "${K}" ] && exit 98
# Create second tab and resize
SDA=$(dcop $k konsole currentSession)
SDB=$(dcop $k konsole newSession)
dcop $K $SDA setSize 121x25

# Let bash login, etc.
sleep 1

# Rename the tabs
dcop $K $SDA renameSession "App 1"
dcop $K $SDB renameSession "App 2"

# Start services, letting user watch
echo -n "starting app1... "
dcop $K konsole activateSession $SDA
dcop $K $SDA sendSession "echo -ne '\033]0;DEV (${hostname})\007' && clear && starter $XMLA"
sleep 2
echo -n "starting app2... "
dcop $K konsole activateSession $SDB
dcop $K $SDB sendSession "echo -ne '\033]0;DEV (${hostname})\007' && clear && starter $XMLB"
echo done.

The funky echo commands will set the application title to "DEV (hostname)" while the tab title is set with renameSession.

Delay Before RPM Installs

I wanted the user to have a chance to abort an install, for the ones that insist on using rpm vs yum.

%if <something>
%else
%global fake %%(for i in {1..100}; do echo " "; done)
%{echo:%{fake}WARNING: RPM will not properly require vendor drivers! }
%global fake %%(for i in {1..5}; do echo " "; done)
%{echo:%{fake}}
%global fake %(sleep 10)
%endif

Have RPM Require an Environmental Variable

$(warning RHEL4 is no longer supported!)
$(warning The driver RPMs no longer support RHEL4 and the RPM that is generated will not properly require them.)
ifeq ($(TARGET_RHEL_OVERRIDE),)
$(warning If you are OK with that, then you can re-run with TARGET_RHEL_OVERRIDE=1)
$(error RHEL4 is no longer supported!)
endif

Python deepcopy broken

Well, that was annoying… spent a long time last Friday and today to find out that Python 2.7's copy.deepcopy doesn't play well with xml.dom.minidom. See this bug report.

The workaround is to use "doc.cloneNode(True)" instead.

RPM Compression

The other day at work I noticed that at the end of an RPM build, it seemed to hang. It turns out, it was compressing the files to create the installer. I'd rather not have it do that if I am building development versions since they only get scp'd to a lab environment.

Even if it does compress, I'd like to have feedback as to what it is doing. So I added these lines to my .spec file. They should be easy enough to tweak and add to a system-level macros file.

Background: We had "dev" appended to the version number already, so this was the easiest way to do it:

%if 0%(echo %{rpm_version} | grep -c dev)
%define _source_payload w0.gzdio %%{echo:Skipping source RPM compression...}
%define _binary_payload w0.gzdio %%{echo:Skipping binary RPM compression...}
%else
%define _source_payload w9.gzdio %%{echo:Maximum source RPM compression...}
%define _binary_payload w9.gzdio %%{echo:Maximum binary RPM compression...}
%global _enable_debug_packages 0
%global _debug_package %{nil}
%endif

So now my RPMs are about four times as large as they were, but are built a lot faster.

Email your new IP address with TomatoUSB

So my router is now TomatoUSB and I wanted an alert when the IP changed. Sure, I could probably put something local on the router, but where's the fun in that?

So I put together a quick python script to drop me an email if the IP ever changes. Yes, TomatoUSB supports various Dynamic DNS services, but doesn't seem to natively support "email me."

So on the DDNS setup page, I chose the "Custom URL" service, and I put in "http://192.168.90.99/IPCHECKS?new_ip=@IP" as the URL (the internal address of an Apache server running WSGI.

I have a custom config file /etc/httpd/conf.d/wsgi_IP as follows:

WSGIScriptAlias /IPCHECKS /var/www/wsgi/IP.wsgi

<Directory "/var/www/wsgi/">
  WSGIApplicationGroup %{GLOBAL}
  Order deny,allow
  Deny from all
  Allow from 192 127 ::1
</Directory>

HOPEFULLY that means none of you can change what I think my IP address is. ;)

Here's the actual python script (/var/www/wsgi/IP.wsgi):

from __future__ import print_function
from cgi import parse_qs, escape
import socket
import smtplib

# This is RevRagnarok's ugly IP checker.
# Tomato (firmware) will post to us with a "new_ip" parameter
# At this point, I want to see manually that the IPs change, not have it autoupdate
# Note: I had to enable HTTP sending email in SELinux:
# setsebool -P httpd_can_sendmail 1

def application(environ, start_response):
    parameters = parse_qs(environ.get('QUERY_STRING', ''))
    if 'new_ip' in parameters:
        newip = escape(parameters['new_ip'][0])
    else:
        newip = 'Unknown!'
    start_response('200 OK', [('Content-Type', 'text/html')])
    # Look up DNS values
    oldip = socket.gethostbyname('revragnarok.com') # Yes, IPv4 only
    # Compare
    changed = ''
    if newip != oldip:
        changed = 'IP changed from {0} to {1}.'.format(oldip, newip)
    if changed:
        e_from = '[email protected]'
        e_to = ['[email protected]']
        e_msg = """Subject: IP Address change detected

{0}""".format(changed)
        # I considered a try/catch block here, but then what would I do?
        smtpObj = smtplib.SMTP('localhost')
        smtpObj.sendmail(e_from, e_to, e_msg)
    else:
       changed = '(unchanged)'
       changed = 'IP is {0} (unchanged).'.format(newip)
    return [changed]

And don't forget, if you use SELinux, fix permissions on the script, and allow the webserver to send email:

[root@webserver wsgi]# ls -Z IP.wsgi 
-rw-r--r--. root root system_u:object_r:httpd_sys_script_exec_t:s0 IP.wsgi
[root@webserver wsgi]# setsebool -P httpd_can_sendmail 1

Optional requirements for RPM

(Wow, it's been over a year since my last blog post…)

At work, I have a program that optionally could use the Qt libraries, but I didn't want my RPM to actually require libqt-mt.so like it wanted to. And RPM doesn't seem to support an "OptRequires" or something similar… so here's my hack of a solution.

I put this script named find-requires into my project's "build" subdirectory so it is included in the "Source" tarball that rpmbuild will be using. I wrote it to be expandable.

#!/usr/bin/perl -w
use strict;
use IPC::Open2;

# This quick script will run the native find-requires (first parameter)
# and then strip out packages we don't want listed.

open2(\*IN, \*OUT, @ARGV);
print OUT while (<STDIN>);
close(OUT);
my $list = join('', <IN>);

# Apply my filter(s):
$list =~ s/^libqt-mt.so.*?$//mg;

print $list;

Then put in your .spec file this, which will call our script with the original script as the first parameter:

# Note: 'global' evaluates NOW, 'define' allows recursion later...
%global _use_internal_dependency_generator 0
%global __find_requires_orig %{__find_requires}
%define __find_requires %{_builddir}/%{?buildsubdir}/build/find-requires %{__find_requires_orig}

Problems with Perl 5's switch

I was trying to use perl's __DATA__ subsection and was receiving the following warnings/errors:

readline() on unopened filehandle DATA
main::DATA used only once

Well, after fighting with it for like 20 minutes, I did a Google search. After wandering around different mailing list archives, etc, I finally found a hint of a solution.

Apparently, using "Switch" (via "use Switch;") does some kind of behind-the-scenes magic that breaks __DATA__ section stuff. :(

I didn't find anything in perldoc Switch that indicated it was a known bug. However, it is v5.8.5 so fairly old (2004, from RHEL 4.5) and the Switch documentation says it is from 2003.

Annoying tho.

sudo: sorry, you must have a tty to run sudo

Ran into this the other day at work on RHEL5. Unfortunately, net searches come up with a not-so-great answer - "just comment out Defaults requiretty." Don't you think it's there for a reason?

The reason is that without having TTY control characters interpreted, unless you are using the "NOPASSWD" option, sudo cannot mask out your password and it will be printed to your screen for all to see!

The simplest (and most proper IMHO) work-around is to simply use "ssh -t" instead of "ssh" in your command line that is calling sudo on the remote machine.

Screen

Screen is a useful tool when remoting into a Unix box. It's been around forever, and I'm just going to document the .screenrc that I use here:

altscreen
autodetach on
hardstatus alwayslastline "%{= bY}%3n %t%? @%u%?%? [%h]%?%=%c"
vbell on
startup_message off
pow_detach_msg "Screen session of $LOGNAME $:cr:$:nl:ended."
defscrollback 10000
nethack on
zmodem off
caption always '%{= bY}%-Lw%{= bm}%50>%n%f %t%{-}%+Lw%<'
dinfo
fit
defmonitor on
verbose on

Don't end filenames or directories with spaces

Yeah… my Ruby script that I posted before made a bunch of directories with spaces at the end. And then when I fixed the bug, I had directories with and without spaces at the end. Bad things happen…

Cannot delete file: Cannot read from the source file or disk.

PAR2 file mover

This is my first Ruby script… please feel free to contact me with feedback.

It will read a PAR2 parity file and move all the files in it to a subdirectory. The original thing I asked for:


I know you can currently download into subdirectories based on ID3 tags. I would love to be able to have downloads go into subdirectories based on the PAR2 file that "covers" them.

Example, all files downloaded overnite into a huge directory:

AAA.PAR2
AAA 01-16.mp3
AAA 02-16.mp3
...
AAA 16-16.mp3
AAA.nfo
AnnoyinglyNamedNothingLikeAAAButInThePARFileAnyway.nfo
BBB.PAR2
BBB 01-92.mp3
BBB 02-92.mp3
...
BBB 92-92.mp3
BBB.nfo
...
XXY.PAR2
XXY.mp3
XXY.txt

So I would want them moved into the subdirectories "AAA", "BBB", "XXY", etc. It wouldn't be perfect but it would be a great start for what I do to process my inbound stuff.

If not, how about dumping some log file I can parse in perl or ruby that gives me "AAA.LOG" which lists the files that went with AAA.PAR2 ?


Of course, being a borderline OCD engineer, I didn't just solve the problem but also put together a full object-oriented infrastructure to parse and process PAR2 files. I've only handled one packet type defined in the PAR2 specifications, but put in place a Par2BasePacket with an interface that all the other packet types can be derived from.

Without further delay, see the attached code (sorry, my install doesn't support syntax highlighting of ruby and I don't have time now - but you can paste the code into this online highlighter).

Using Kompare

So I was using Python to do some pretty diffs (will post that some time soon) and a coworker pointed out the program Kompare on Linux. I don't normally use Linux as a desktop, only servers. Anyway, it gives me an awesome interface, almost as good as the TortoiseSVN diff viewer I am used to. It can take the output of svn diff and then will find the original files and show you graphically all the changes.

The command I have been using:

svn diff | kompare -o -

Arduino Project

I'm thinking about starting an Arduino project. I don't want to reveal details yet. But it won't be all that cool, just something I want.

I was really liking the BlackWidow until I read that it is not 802.11b/g but b only, which would slow my network down too much. FAIL guys. :(

So now I need to decide - do I get a Ethernet shield for $46 and then load OpenWRT into a $25 802.11n router? Then if the project fails, I still can re-use the router as a bridge somewhere else… or do I splurge and spend $90 for a "real" Arduino 802.11g unit?

I Hate Java

(Originally posted 27 Nov 09, lost in server mishap, found in Google's cache of this page)

So for some reason this evening, my favorite RSS Reader (RSSOwl 2) wouldn't run… and that scares me. I use it to peruse probably 60-80 websites daily.

Anyway, it just wouldn't run. No error messages. Didn't even look like Windows would give it a chance. Never showed up in Task Manager. Well, I was using a beta, so I uninstalled it and installed the newly released 2.0. Still no luck. Nothing at all.

Decided to try it from the command line, to see if the helps:

Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

That's nice and descriptive - WTF? Remembering that RSSOwl is built on the Java IDE Eclipse, I decided to make sure I have the newest Java. I am running Windows 7, which is fairly new, so maybe something happened there. Doesn't explain why I've been running it since its release with no problems up to now… In fact, I notice that running java from the command line gives me the same error.

BTW, Google was useless, a bunch of posts about Java from 2005, or talk about the SDKs and/or rt.jar. None seemed to apply.

So I install the latest, which is "Java 6 Update 17" - an odd numbering scheme, I will get back to that. With a fresh install, the plugin works in Firefox. Java.com has a link to check your JVM too. That crashed Firefox. So I copy the URL and try Internet Explorer. Crashed that too. Drop to the command line to try java - same error.

Open up the control panel to add/remove programs, and I see that there are 4 or 5 versions of Java installed. Why? Shouldn't "Update 17" be sufficient instead of also having Updates 2, 5, 7, and 13 also? (I don't remember the exact numbers).

After uninstalling all of them, and then installing the newest, everything works fine, including RSSOwl and the JVM check page:

RevRagnarok@Jotunheim ~
$ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)

One note: I think Update 17 was the first one to be installed/updated after the upgrade from Vista to Win7. That may be related to why there was such weirdness… but I still don't agree with an update not removing all the previous ones.

RHEL/CentOS/VMWare pissed me off

(Originally posted 25 Oct 09, lost in server mishap, found in Google's cache of this page)

I cannot believe that a point release would hose me up so badly…

More than 4 serial ports under Linux

(Originally posted 24 Oct 09, lost in server mishap, found in Google's cache of this page)

So at work I am using a PCI104 octal serial port board. It's pretty cool that Linux now supports those OOB, but I had problems; I only saw the first two ports!

After doing a bunch of research; I finally found the problem. I had assumed it was something with the chipset itself. However, it is a problem with the default kernel build from RHEL/CentOS. They only allow up to four by default! To get more (up to 32 with the RHEL/CentOS kernel), you have to add to the command line in GRUB:

8250.nr_uarts=12

Again, that can be up to 32. I chose 12 because "traditionally" the mobo could have up to four. That made the two on the mobo ttyS0 and ttyS1, so the octal card has ttyS4 to ttyS11. So ttyS2 and ttyS3 are unused. A quick check with dmesg | grep ttyS will show them being allocated.

Side note: You can check how many the default is by doing grep CONFIG_SERIAL_8250 /boot/config-`uname -r` and looking for CONFIG_SERIAL_8250_RUNTIME_UARTS. CONFIG_SERIAL_8250_NR_UARTS is the maximum you can have without rebuilding the kernel.

Maybe I'll get inspired and blog sometime about the cool stuff I did with udev so that I can configure a box and then the software would just "know" where which serial port the (external device) was on by calling /dev/projectname/extdevice .

Strange Software Install Issue (Installer silently hangs)

I've been having a strange install issue with the ATI Catalyst software. It's documented here on the AMD site: http://forums.amd.com/game/messageview.cfm?catid=279&threadid=125401&forumid=11

However, forums like that have a great history of disappearing when I need them most, so a summary is also now here.

Setup was totally hanging. I tried all kinds of things to trace what was happening. Then this wonderful post came along:

From Wiink:


I signed up to post in this thread since I was having the exact same issue and was really frustrated over it. I have a 4890 and have always used Ati graphics cards, never had any issues and drivers always installed flawlessly until one day i decided to update from 9.8 to the current 9.12.

I'd go through the usual uninstall methods using the ati uninstaller and then follow up with driver sweeper. Click on the exe for the 9.12 suite and it would unpack/extract then an hourglass for about 5 seconds and then nothing. I would see InstallManagerApp.exe running in the taskmanager and my hdd light would be lit, but that was about it….no install. Tried many times and nothing worked. Drove me absolutely crazy. Checked and re-checked all the cleanup, c++ redist and .net stuff….All in order and still same results - nothing.

Then I came across this thread about not having full admin permission for registry changes needed for some software installs even though I am the only user and Admin of this pc. When installing the 9.12 Catalyst Suite, it needs to change something in the registry that was now being blocked , so I ran this fix posted here and my problems were solved immediately on both my Vista and my XP Pro machines. Just remember to create a fresh system restore point before applying it. I was so happy to have the issue fixed I had to share. It specifies Vista in the post, but it worked for my Xp Pro as well flawlessly. Took about 20 minutes and fixed! And sorry for the wall of text. Just do a reboot after running the cmd file and try to install the catalyst 9.12 suite again, should work now.

Post by Michael G. Simmons: http://social.msdn.microsoft.com/forums/en-US/vbexpress2008prerelease/thread/c273b0e1-7f46-4065-afaf-4edf285d2531

There is a quick fix for this and any other permission issues that occur with Vista. I've seen this happen with several different installs under Vista including VS 2005 and Orcas. The problem is for some reason regisry permissions are given to the user msiserver. You can reset each entry manually, but that is a major pain. It's much easier just to fix the entire registry by using the SubInACL utility. Basically, you can use the utility to add administrator permissions to every key in the registry.

  1. Download and install the SubInACL utility.

2.Create a new text file named fix_registry_permissions.cmd and add the following text to it and save it.

    cd /d "%programfiles%\Windows Resource Kits\Tools"
    subinacl /subkeyreg HKEY_LOCAL_MACHINE /grant=administrators=f /grant=system=f
    subinacl /subkeyreg HKEY_CURRENT_USER /grant=administrators=f /grant=system=f
    subinacl /subkeyreg HKEY_CLASSES_ROOT /grant=administrators=f /grant=system=f
    subinacl /subdirectories %SystemDrive% /grant=administrators=f /grant=system=f
    subinacl /subdirectories %windir%\*.* /grant=administrators=f /grant=system=f
  1. Run the file by double-clicking on it.

That's it. It will take several minutes to finish, but at the end all registry keys will be accessable to the administrator and system, as it should be.

My Dell XPS Gen 3 won't boot from CD-ROM!

To: Some friends of mine.

Any ideas on this head-scratcher?

My Dell XPS (getting really old, I know) won't boot from CD-ROM. I have tried 3-4 different CDs. One of the CDs has multiple boot images on it and none of them boot.

Here's the weird part - I can get the boot loaders to work! The Ghost ones will say "Loading PC-DOS..." and then the CD drive just stops spinning. The multiboot one gives me all the menus, but as soon as it tries to launch something, it hangs in the same way. Even good ol' DOS 6.22 says "Loading MS-DOS..." and hangs. I tried my CentOS 4 installer DVD - I get the boot menus, I type "linux rescue" and then it just sits there.

My config is multiple SATA drives and two PATA CDs. I have even disabled the master and then I have the same issue with the secondary (it won't touch the secondary if the master is enabled, even if no CD in master). Same thing.

And here it gets even weirder… I booted from a USB key with Ghost on it just fine; I'm doing my backups now. WTF?!?!

Various suggestions came back… then a few days later, I found the solution!

You've GOT to be shitting me… I fixed it!

http://support.dell.com/support/downloads/download.aspx?c=us&l=en&s=gen&releaseid=R104585&SystemID=DIM_PNT_P4_XPS_G3&servicetag=&os=WW1&osl=en&deviceid=308&devlib=0&typecnt=0&vercnt=8&catid=-1&impid=-1&formatcnt=1&libid=1&fileid=135030

I didn't install this BIOS release from over 4 years ago (I have A06), but look at the changelog:

"1. Prevent boot issues when USB devices with media readers are present."

Lo and behold, I plugged my monitor in a few weeks ago. Which has a (useless) built-in USB hub and media reader! I never would've expected something like that to happen! So my guess is that the BIOS tries to enumerate the drives somehow to map to INT13 and hangs up! When I yanked the USB cable from the monitor, CDs booted just fine!!?!?

I thought the USB hub was useless before because it powers off with the monitor - now it is a downright HINDRANCE!

RPMBuild stupidity

OK, this just pisses me off. It's plain dumb - rpmbuild expands macros before stripping comments. So what happened to me today (and I wasted an hour on) was that a multi-line macro was being inserted into a comment!

Based on a quick search of bugzilla at readhat, I'm not the only one - see 74949 and 99100. They say WONTFIX but that's just dumb in my not-so-humble opinion.

So now you know. If you are making a spec file for an RPM:

%files
# %build

will screw you over like it did me. You need to:

%files
# %%build

MATLAB objects and subsref

Oh MATLAB, why do you have to be so obtuse about what you are doing??? I understand that OO stuff is being shoved into a language that didn't originally support it, but WHY isn't it just documented better?

Problem: All of a sudden, my method calls from outside the class stopped working.

Background: All the documentation says that if you have a (dependent) property and there is public access to it, the methods get.propname(obj) and set.propname(obj, val) will be automatically called for you. This is true.

At least, it was until I decided I wanted my class to be able to return more than one value at a time. Once I defined at subsref() method, all external access died and now goes through it instead. EVERYTHING. So you must handle all your own public methods, etc, with useless wrapper logic. MATLAB doesn't do something intelligent like, "well, let me see… OK, there's a get.propname() so I'll call that." Nope. Instead, I need to do:

% (All within a "classdef")
function ar = subsref(obj, subs)
  switch subs(1).type
    case '.'
      switch subs(1).subs
        case 'single_val'
          ar = obj.single_val; % which DOES call the get.single_val() method!!!
      end % subs
    case '()'
      % actually do the stuff I wanted to do with ranges here
  end % type
end % subsref

This really confused me and I didn't find much on their website that was helpful about it either.

Using UltraCompare with TortoiseSVN

From "Nick's Head Sphere"

Diff:
C:\Program Files\IDM Computer Solutions\UltraCompare\UC.exe -t %base %mine

Merge:
C:\Program Files\IDM Computer Solutions\UltraCompare\UC.exe -rom %theirs %mine %merged 

MATLAB: Please dbstop here

I am doing a lot with MATLAB at work. I wanted the equivalent of a command that doesn't exist: dbstop here or dbstop now. Came up with two possible solutions with the help of the MathWorks tech support.

1: (from MATLAB documentation)

dbstop if warning 'MFILE:stop';
% Then later:
if ~isequal(input, expected_input), warning('MFILE:stop','Boom!'), end;
% At the end (or else things seem to slow down)
dbclear if warning 'MFILE:stop';

When it drops into the debugger you can then issue the above dbclear command by hand to get it to stop dropping there.

2: (my way)

This way uses the command keyboard that I didn't know about until tech support told me about it - it is not listed in help dbstop but it is a "see-also" in doc dbstop which is annoying…

breakable=1;
% Then later:
if breakable && ~isequal(input, expected_input), keyboard, end;

When it drops into the debugger (you can still use F5, etc) you can then type breakable=0; to stop it from dropping at that point. It doesn't clutter up the dbstop stack so shouldn't slow down unrelated M-files.

RevRagnarok's Blog

This is not a typical "read my thoughts blog" - instead it is a "I found something that may be useful to be jotted down for myself, and maybe others can benefit from my sweat and tears." So it is more of a brain dump. If you find any of it useful, please feel free to drop me a line at blog using this domain name. The tags should be pretty self-explanatory. Also, most of my useful links are dumped at del.icio.us. And with that disclaimer finished, I now have a "funny stuff, etc" blog on blogspot.

VMWare Client Running on Fedora 9

What a pain! You have to get the latest open-vm-tools from SourceForge. Do a configure and make && make check. But then you cannot actually install the files or VMWare gets pissy.

After the make you need to pack up the kernel files you have created and patch the real VMWare installer with them:

for i in *; do mv ${i} ${i}-only; tar -cf ${i}.tar ${i}-only; done
cp *tar /usr/lib/vmware-tools/modules/source/

Then you can run the standard vmware-tools-config.pl and it will use the source you just upgraded.

This page was assembled from various net resources…

Hidden Directories

So, apparently Vista does something that is actually kind of smart. If a program tries to put preference files, etc into the "Program Files" directory, it dumps them elsewhere so that they are still going to be user specific. (This is all hypothesis!) Anyway I was trying to move my scores from WinXP to Vista for "Snoodoku" and this was the solution. http://www.wordofmousegames.com/forums/showthread.php?t=2134


Well, I found it myself, so figured I'd post the solution for future users.

Apparently, Vista merges two directories when a program is trying to store preference files in the Program Files directory. So the file was actually hidden away in C:\Users\RevRagnarok\AppData\Local\VirtualStore\Program Files\Snoodoku


More info from Microsoft.

Car Repair Pricing

Service Manuals for a BUNCH of stuff

"sudo" for Vista

Subversion from Perl

So I spent about three hours trying to get my perl svn_compress script running and I ran kept running into the damned thing segfaulting!

svn_path_basename: Assertion `is_canonical (path, len)' failed.

I finally found the answer. Apparently, libsvn wants '' as the current directory, not '.' like every other program since the beginning of time (Jan 1, 1970, right?).

Three hours.

Where I read the answer. Pasted here:

Peter Samuelson wrote:
> [Julian Gilbey]
>> burnside:~/debian/tex/tetex-bin $ perl -MSVN::Client -e \
>>   'sub print_names { print "<$_[0]>\n"; } $ctx=new SVN::Client;
>>   $ctx->status("", "BASE", \&print_names, 1, 1, 0, 1);' | head -5
>> <>
>> <.pc>
>> <.pc/.version>
>> <configure>
>> <INSTALL.generic>
> 
> I reproduced your bugs with subversion 1.3.0-5, so I can properly
> discuss it with upstream.  Unfortunately, I don't know much about the
> Perl bindings.  But comparing "svn status" with your command, it does
> seem to correspond to the "." entry.  I wonder if that is even
> considered a bug.  I mean, if you prefix each entry with $(pwd)/, it is
> fine.
> 
> 
>> perl: /tmp/buildd/subversion-1.2.3dfsg1/subversion/libsvn_subr/path.c:377:
>> svn_path_basename: Assertion `is_canonical (path, len)' failed.
> 
> Right, that's definitely a bug.  Even if this isn't something the perl
> bindings can fix on their own, they should carp or something.

Hi. This is an issue that gets kicked around on dev at svn from time to
time, and usually ends up with the thread fizzling out sooner or later,
with no concrete action being taken, due to a lack of an obvious right
way to proceed. I'll sum up the situation...

There exist a number of path manipulation functions (svn_path_*) which
do not conform to the usual style returning an error status as the
return value, and output data via output pointer parameters. Instead
they return data directly as the return value, and are supposed to only
ever be able to experience errors that merit assert() or abort().

Subversion defines a 'canonical path' format, and most of the functions
(apart from the canonicalizer itself, obviously!) assert that the input
path looks like a canonical path.


Various groups of C programmers will conduct heated debates on whether
this is good programming practice, or an annoyance, but that is
irrelevant where the bindings are concerned, since assert()-ing out of a
scripting language interpreter is clearly bad.

There is a fairly obvious, though non-trivial, solution:
Make the bindings test all input paths (presumably using a path-specific
SWIG "in" typemap) using the same logic as is_canonical, and
canonicalize if necessary. The problem, though, is that discussions of
this nature tend to get intertwined with the parallel issue of whether
the C code is being generally unhelpful in this situation, and should be
changed too.


OK, now you know the background.

Feel free to prod dev at svn to raise awareness of this problem which has
sadly lain dormant for far too long.


Max.

Aside:
The canonical form (IIRC) is mostly common sense stuff:
* no repeated slashes
* no internal /../ sequences
* no trailing slash
BUT it has one weird rule:
* the canonical form of "." is ""

Today I created a yum repository

This is what happens when you are at work and you have ISOs for the 6 CDs of CentOS 5.2 but NOT the DVD, and no connection to the 'net… I couldn't use the 5.2 installer thanks to this bug (it's an embedded Celeron 650). Since I went thru all the work, I also then imported the directory as a "shared folder" under VMWare player and then did the same upgrade path on that machine (I want it to mirror the embedded machine for all versions of everything, except it also has the gcc suite, etc).

One Time Only

(This can be done on any Linux machine with the external drive connected)

  • I mounted the external drive under Linux and there are the 6 ISO CDs. I mounted each and then upgraded what was on it that we already had installed.
  • cd /media/ext_drive/<install dir>
  • mkdir mnt
  • mount -o ro,loop <CDFILE>.iso mnt
  • cp -urv mnt/CentOS .
    • If I were doing this again, I may mount the 6 as /mnt1 thru /mnt6 and then try to use cp -l to make links?
    • (Optionally in another window to watch progress: watch -d 'lsof -c cp -s | cut -c37- | grep rpm ' )
  • umount mnt
  • (Repeat for all 6 - this gives us a CentOS subdir with all the RPMs. If I had the DVD instead of the 6 CDs, this would've been easier)
  • Now we will make this new directory into an "official" repository
  • cd CentOS
  • rpm -i createrepo*rpm (glad that was there!)
  • mkdir repo_cache
  • createrepo -v -p -d -c repo_cache --update --skip-stat .
    • This step takes forever (even longer than the copying above)
    • With a DVD image, this is most likely not even needed!

Every Target Machine

  • We need to disable all the remote repositories:
    • Edit /etc/yum.repos.d/CentOS-Base.repo and add enabled=0 to every section
    • Edit /etc/yum.repos.d/CentOS-Media.repo and change to enabled=1
      • Depending on where the external hard drive is, baseurl will need an added path to it
        • When I did it, it was file:///media/ext_drive/LinuxInstallers/CentOS-5.2-i386-bin-1to6/CentOS/
      • There is a known bug in 5.1 - the GPG signature key should be RPM-GPG-KEY-CentOS-5 (not "beta")
  • yum clean all
  • yum install yum-protect-packages
  • yum upgrade yum
  • yum clean all
  • yum upgrade --exclude=kernel\* -y | tee upgrade.log
    • (Optionally in another window to watch progress: watch -n1 'lsof -c yum -s | cut -c43- | grep rpm ' )
  • grep warn upgrade.log
    • For this, you need to diff each file with the .rpmnew file or .rpmold file and merge them together.
  • Reboot!

Stopping a Windows Executable from Running

To prevent a file from being created, in the past I have created a folder with the same name. This lets you stop a file from running (the example used is a worm executable):

  1. Create a registry key with the name of the process you want to prevent to execute. Ex.: calc.exe
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\calc.exe 
    
  1. Under this new key you've just created, create a SZ value called "Debugger" and set it to the following value:
    SZ Debugger = "cmd.exe /c echo  %time% %date% calc.exe >> c:\ExecBlocked.log"
    

From http://blogs.technet.com/marcelofartura/archive/2006/10/24/a-virus-infection-contolling-the-outbreak-tip.aspx with slight mods by me.

Random Unix/Linux Tips

Yeah, that's pretty much the subtitle of this blog, but I found another that has similar stuff:

http://users.softlab.ece.ntua.gr/~ttsiod/tricks.html

My favs (I'm copying in case the site goes down):

Convert a static lib (.a) into a dynamic one (.so)

gcc -shared -o libXxf86vm.so.1.0 \
	-Wl,-soname,libXxf86vm.so.1 \
	-Wl,--whole-archive,libXxf86vm.a,--no-whole-archive

Create PNGs from a pdf presentation

gs -dSAFER -dBATCH -dNOPAUSE -dTextAlphaBits=4 \
    -dGraphicsAlphaBits=4 \
    -r85 -q -sDEVICE=png16m -sOutputFile=icfp-pg%02d.png \
    PhDPresentation.pdf

Read a damaged CD/DVD valid parts and get the rest with rsync

As is often the case, when I bring some burned CD/DVD 
from work, I find out that its bad at some offset.
I came up with this Perl script:

---------------------------------------
#!/usr/bin/perl -w
use strict;

my $i=0;

select((select(STDOUT), $| = 1)[0]);
unlink("data");

system("dd if=/dev/zero of=zero bs=2K count=1");

my $step = 1;

print "Sector:             ";
while(1) {
 system("dd if=/cdrom/BadSector of=sector bs=2K skip=$i".
    "count=1 >/dev/null 2>&1");
 if ($? == 0) {
     print sprintf("\b\b\b\b\b\b\b\b%08d", $i);
     system("cat sector >> data");
     $step = 1;
     $i += $step;
 } else {
     system("cat zero >> data");
     $step += $step;
     $i += $step;
     print "\nJumped over $step\nSector:             ";
 }
}
-----------------------------

With the CD/DVD mounted on /cdrom/, it will slowly but 
effectively copy sector by sector of the file mentioned 
in the 'dd' line into the file called 'data'. Reading 
sector-sector proves to be enough to correct a multitude 
of read-errors on my DVD reader, but even if that isn't 
enough, it will quickly jump over the problem areas
in the DVD, writing blank 'sectors' to mark the jumps.

After that, rsync can save the day:

rsync -vvv -B 131072 -e ssh \
	[email protected]:/path/todata data

"Hidden" Search Feature in File Open dialog

OK, I've been using Windows for years and I really thought I knew almost every shortcut. I Alt-Tab like there's no tomorrow (and occasionally remember to Win-Tab on wifey's laptop w/Vista). Win-R hourly (typing cmd or calc is quicker than finding it on the menu). Win-E any time a USB drive is nearby. Anyway, apparently you can do searches within a "File Open" dialog. Obviously, I knew most programs add a pull-down with file types. But on a whim, I was in UltraEdit the other day and type *vhd and wow it limited the selection to the VHDL files. *.v worked too, but acted like *.v* - however *.l and *.l?? showed the second one acting as I would expect (matching only 3 letter extensions starting with l - .lock was hidden). I tried it in a few other programs like Gimp and it seems to be part of the standard Windows UI. This is XP, I don't have access to any 2000 machines anymore, but no idea when it came about. (As shown before), I hate it when something I'm looking for is right under my nose!

Extra Secure Remote Desktop

I have been using Microsoft's Remote Desktop for a few years now (pretty much since I switched to XP). It's decent, and I like that it retains sessions unlike TightVNC, which is what I had used before. By using a SSH tunnel, I feel confident that my connection is secure and I am willing to visit my banks, etc. using my desktop machine via my laptop on a wireless network. Here's what I did:

On the server (in this case my desktop):

  • Installed the Cygwin build of SSHD as a service
    • Many guides are available, just search with Google above keywords like "cygwin sshd". But in a nutshell:
      • Install cygwin (duh) - include openssh (under Net) and cygrunsrv (under Admin)
      • Set up sshd: "ssh-host-config -y"
      • Start it as a service: "cygrunsrv -S sshd"
  • Allow Remote Desktop usage:
    • Right click on "My Computer" and choose "Properties"
    • Go to the "Remote" tab
    • Make sure that "Allow users to connect remotely to this computer." is checked

On the client (in this case my laptop):

  • You need a way to setup an ssh tunnel. You can use Cygwin's ssh, PuTTY, or my favorite MyEnTunnel. I previously selected MyEnTunnel for some work-related stuff, so I was able to simply add a "Profile".
  • The key is that you want a tunnel from your machine's 3390 to the remote (server) machine's port 3389 (or any other port on your local machine of your choosing). With MyEnTunnel, it is this simple:
    • Profile Page 1 Profile Page 2
  • Once MyEnTunnel has established a connection (a green padlock), you can connect.
  • Start → Run → "mstsc"
    • MSTSC setup
  • As you can see, mstsc has no idea what machine you are connecting to. As far as it knows, you connect to localhost which is your machine, which MyEnTunnel then encrypts (using PuTTY's plink) and sends to the remote machine's sshd daemon which forwards it to Windows XP listening for the Remote Desktop connection.
    • (Client:Outgoing port) -> (Client:3390) -> (Client:22) -> [encrypted link] -> (Server:22) -> (Server:3389)

Compressing Subversion checkouts

I'll let the file intro explain itself:

# "Disk space is cheap!" - SVN Authors
# "Except when backing it up!" - RevRagnarok

# This script will drastically reduce the size of an svn checkout so you can back up the folder.
# It will include a script to re-expand the directory with NO interaction with the server.
# It will also (optionally) write a script /tmp/svn_uncompress.sh that will restore all compressed
#   folders.

Something to check out in the future: http://scord.sourceforge.net/


Update 3 Apr 08: Updated the script to touch a file saying it ran so it won't run again. Also have it dump a tiny "readme" file to let somebody else know what is going on.
Update 4 Apr 08: Fixed bug with deep paths.
Update 22 Aug 08: Huge changes, now using "proper" native calls.

Compressing VMWare images

Wow, I thought I've posted this stuff before but could not find it when searching earlier today.

But that's OK because I've done something new today versus the many previous years (the "special case" below).

Anyway, the quickest way to reduce the size of a VMWare image (note: I am not talking about the physical space, I mean the size when you compress the image in the host OS, for example with tar with bzip2):

Reducing VM Image Size (Standard)

  1. telinit 1 # Drops you to single user and shuts down most other stuff
  2. Delete any files you don't need. This includes most of /tmp/
  3. dd if=/dev/zero of=delme bs=102400 || rm -rf delme # This will fill the unused space on the hard drive image with zeros. If you have VMWare set to expand-on-the-fly, it will maximize the size on the host OS, which may not be what you want. Use mount to show which partitions are being used - you need to do this for each partition (e.g. /boot). This is the "meat" of the issue. Do not background this process and then try to do the other partitions in parallel - remember, they are the same physical disk on the host OS and you will thrash your hard drive like crazy (been there).
  4. Check where your swap space is defined - it's in /etc/fstab
  5. swapoff -a # Turns off all swap space (you don't need it right now)
  6. dd if=/dev/zero of=/dev/yourswappartition bs=1024
  7. If /etc/fstab mounted the swap by label:
    • mkswap -L SWAPLabel /dev/yourswappartition
  8. If /etc/fstab mounted by partition alone:
    • mkswap /dev/yourswappartition
  9. You don't need to turn the swap back on, on the next boot of the VM it will be handled since you ran mkswap.
  10. shutdown -h now

Reducing VM Image Size (Special Case)

The special case is what I ran into today. I backed up my work trac/svn VM server as usual. However, I told another customer that I would give them a server. So I need to remove the subversion repository and trac environment. Option 1: Delete them, and then redo all the dd stuff from above, which would be O(free space) vs O(repository). Since "free space" >> "repository", I was trying to avoid that. Option 2: Zero out the files that I don't want anymore. This has the advantage of still reclaiming the gigabytes of space while not waiting for all empty space to be removed. The secret was using the shred command:

find -type f | xargs shred -u -v -n 1 --random-source=/dev/zero

For those trying to understand it better, that is "find all files (that are files) and then pass the list to shred as parameters along with: delete the file when done (-u), tell me everything you do (-v), overwrite the file only once instead of the usual 25 (-n 1), and instead of using /dev/random for your "random" data, just use /dev/zero (--random-source=/dev/zero). Note that using dd directly would have been a pain because I would have to know the size of each file (hundreds) but also it would truncate-on-write meaning that the data being written is not guaranteed to be the actual data we wanted to blank out. That defeats the purpose!

Making This Obsolete

I need to check out this Zerotools package as soon as I can since it seems to do a similar thing all the time.

How to restore a Windows restore point from Linux

Of course, the Ubuntu chest-thumping is kinda annoying and irrelevant. In fact, I would try to find any Live CD with NTFS support (Fedora maybe?) That's all you really need.

In fact it would've been easier for him to check the GRUB config file ;)

http://www.arsgeek.com/?p=3637

Pretty "Diff" in Linux

OK, this is a sad day. I like my Windows utility more than my Linux one. Hopefully somebody out there can point me in the right direction.

I want a graphical diff that looks good. I am used to the beautiful ones in trac and TortoiseMerge (part of TortoiseSVN). I am hoping for something that is available in a default Fedora install that I just haven't seen, or one I can yum install from a virgin install (rules out xxdiff and fldiff). colordiff shows the lines in color but doesn't do colors within the lines.

This is the closest I have found:

pdiff file1 file2 -o - | kghostview -

If anybody has a better one that is easy to use from the command line (so not something like from within emacs or eclipse) then please let me know.

VGA Console modes for laptops

Finally found a table explaining the vga "modes" that the Linux kernel handles. For some reason, on my work laptop (Dell M1710) only gets 0x31B but 0x31F doesn't work.

Unerasing files with subversion

in the redbean book:

  • svn copy -r 11 file:///tmp/repos/test/trunk file:///tmp/repos/test/tags/0.6.32-prerelease -m "Forgot to tag at rev 11"

So, I think in our context, the file was deleted in revision 99 and we are now at 300: (in the trunk/src directory)

  • svn cp -r 99 http://srv/proj/trunk/src/filename filename

Mounting ISO images with Windows

I have been trying to do a whole mount -o loop thing under Windows for years - didn't know that Microsoft actually has a Virtual CD driver for free! No need for Alcohol 120% or anything. Here's the link.

I wanna rsync all night long...

I use rsync a lot on my PC boxes (Cygwin) and Linux servers. I keep forgetting what I do where, so usually I have a file called "command" so I can just ". command" with bash.

Anyway, here are a few so I remember what I did. Maybe you will find them helpful too:

Backup music drive (M:, ext3) to external USB drive (X:\!Music, NTFS)

cd /cygdrive/x/\!Music
rsync -av --size-only --exclude command --exclude '!Books on MP3' --exclude '!FTP' /cygdrive/m/ ./

Backup external USB drive (X:, NTFS) to external FireWire drive (I:, FAT32)

(Yes, I backup my backup, long story…)

cd /cygdrive/i
rsync -av --size-only --exclude command --exclude *iso --exclude '/System Volume Information' /cygdrive/x/ ./

Keep my Cygwin mirror up to date on Mjolnir (Linux server)

cd /share/shared/Cygwin_mirror
rsync -va --stats --delete --exclude command --exclude /mail-archives --progress rsync://mirrors.xmission.com/cygwin/ ./ && touch date
wget http://www.cygwin.com/setup.exe
mv -f setup.exe ../

Getting Tcl/Tk stuff to work on Fedora 8

I have a third party app that has an installer that is written in Tcl/Tk. Apparently, my Fedora 8 install has a busted install of wish, the shell it uses. Here's the ass-backwards way I got it to run.

The error was "Application init failed … This probably means that Tcl wasn't installed properly."

First, I ran tclsh manually to figure out where it was looking - puts $auto_path shows me. It was looking in /build/xfndry8/J.36/env/TDS/Tcl/dist/export/lib instead of, oh, I dunno, maybe /usr/share/tcl8.4/tcl8.4 . However, Tk looks at /usr/lib/tk8.4 instead of /usr/share/tk8.4

mkdir -p /build/xfndry8/J.36/env/TDS/Tcl/dist/export/lib
cd /build/xfndry8/J.36/env/TDS/Tcl/dist/export/lib
ln -s /usr/share/tcl8.4/tcl8.4 /build//J.36/env/TDS/Tcl/dist/export/lib
cd /usr/lib
mv tk8.4 tk8.4_orig
ln -s /usr/share/tk8.4 tk8.4
cp tk8.4_orig/pkgIndex.tcl tk8.4

Note: This is all scratched on the back of a Dilbert calendar sheet so there may be a typo or two.


Follow-up

Apparently, one of my yum updates broke it. I needed to re-run the mv and ln commands. For the record, I'm now at:

tcl-8.4.17-1.fc8
tk-8.4.17-2.fc8

I decided to file a bug


Follow-up 2

I should've known - when all else, fails, blame Xilinx. If I had paid attention, I would've realized that Xilinx tools version 8 would be xfndry8 and J.36 is their internal build number (IIRC 9.2SP4 is J.40).

Reminder email and wiki page for trac

I wrote this a long time ago, never had a chance to update it, and somebody asked on the trac mailing list today…

You can get ADMMailHandler in the ADMLogger package (sorry, too lazy today).

You need to configure a few places too. Like I implied, not quite ready for public consumption, but at my rate never will be. Please feel free to "upstream" me any changes.

Also, if there is a trac project that matches the user name (that's how my company does trac sandboxes) then it will also create a page MyTickets with a dump of links.

#!/usr/bin/perl -w
use strict;

# Script to send email reminders in a cron job.
# Email trac at revragnarok <.> com

# I should've made it DBI compliant - but I'm not getting paid for this ;)

BEGIN {
   push @INC, "/usr/src/my_scripts/mail_reminder"; # Where ADMMailHandler is hiding
}

use Data::Dumper;
use ADMMailHandler;
use DirHandle;

use constant URLbeforeproj => 'http://webmail.revragnarok.com/';
use constant URLafterproj => '/ticket/';
use constant Nodomain => '@yourdomain.com';
use constant Subject => 'Outstanding tickets';

chdir("/var/www/trac");

my (%proj, %user);
my @projs;
# Look in directory for project names
my $dh = DirHandle->new('.') or die "Can't open trac directory! : $!\n";
while (defined ($_ = $dh->read)) {
  # Does it have a trac DB?
  if (-e "$_/db/trac.db") {
    push @projs, $_;
  } # -e
}
foreach my $projname (@projs) {
  # Open each one
  open(SQL,"/usr/bin/sqlite3 $projname/db/trac.db \"select id,status,owner,summary from ticket where status != 'closed'\"|");
  while (<SQL>) {
    chomp;
    my ($id, $status, $owner, $summary) = split /\|/;
    #print "Proj: $projname, ID: '$id', status: '$status', owner: '$owner', summary: '$summary'\n";
    next if ($owner eq '');
    $user{$owner}{"$projname-$id"} = $summary;
  }
  close(SQL);
}
foreach my $username (sort keys %user) {
  # Verify it is valid
  my $fullname = $username;
  $fullname.= Nodomain if ($fullname !~ /@/);
  # Put together the email
  my $mh = ADMMailHandler::new($fullname, 1, Subject);
  $mh->append(qq{<TABLE WIDTH=95% BORDER=1><TR>
<TD><B><U>Project</U></B></TD>
<TD><B><U>Ticket Summary</U></B></TD></TR>});
  foreach my $ticket (sort keys %{$user{$username}}) {
    my ($proj, $num) = split(/-/, $ticket);
    # print "Processing (proj = $proj) (num = $num) (summary = $user{$username}{$ticket})\n";
    $mh->append(qq{<TR><TD>$proj #$num</TD><TD><A HREF="}.URLbeforeproj.$proj.URLafterproj.$num.qq{">}.$user{$username}{$ticket}."</A></TD></TR>\n");
  }
  $mh->append("</TABLE>");
  $mh->sendit();
  # Now we'll make a special 'MyTickets' wiki page if the person has their own sandbox
  my ($tryname, undef) = split(/@/, $fullname);
  if (scalar grep(/^${tryname}$/, @projs)) {
    # There is a match
    open(WIKI, ">/tmp/$$");
    print WIKI "== My Tickets ==\n||'''__Project__'''||'''__Ticket Summary__'''||\n";
    foreach my $ticket (sort keys %{$user{$username}}) {
      my ($proj, $num) = split(/-/, $ticket);
      print WIKI "||$proj !#$num||[$proj:ticket:$num $user{$username}{$ticket}]||\n";
    }
    close WIKI;
    `/usr/bin/trac-admin $tryname wiki remove MyTickets > /dev/null 2>/dev/null`;
    `/usr/bin/trac-admin $tryname wiki import MyTickets /tmp/$$`;
    unlink "/tmp/$$";
  } # Sandbox or not
} # Each username

Xilinx BIT files and the Linux/Unix/BSD "file" command

The attached file will ID a Xilinx BIT file and tell you when it was compiled, the original NCD file name, and most importantly the chip it is for. It doesn't give a speed grade, but it gives all the other stuff.

All credit goes to the FPGA FAQ Question 26.

To install on a machine that already has file installed (yours probably does) you need to find your magic file. I will present what I did on a Cygwin box as an example, season to taste:

  1. cd /usr/share/file/
  2. rm -rf magic.mgc
  3. cat /tmp/xilinx-magic >> magic
  4. file -C

The last command "compiles" the magic file into magic.mgc. To make sure it all worked, you can grep -i xilinx magic* and see a few spots.

Example output:

admaras@brisingamen ~/projects/ss/trunk/vhdl
$ file */*bit
BenADDA/benadda.bit:                Xilinx BIT file - from BenADDA.ncd - for 2v6000ff1152 - built 2007/ 6/27(13:19:26) - data length 0x23d014ff
BenADDAV4/benadda.bit:              Xilinx BIT file - from BenADDA.ncd - for 4vsx55ff1148 - built 2008/01/07(15:37:49) - data length 0x1f3928ff
BenADDAV4_Clock/mybenaddaclock.bit: Xilinx BIT file - from MyBenADDAClock.ncd -for 2v80cs144 - built 2008/01/11(14:18:37) - data length 0x1652cff
BenDATAV4/bendatadd.bit:            Xilinx BIT file - from BenDATADD.ncd - for 4vlx160ff1148 - built 2008/01/11(17:53:27) - data length 0x4cf4b0ff
BenNUEY/bennuey.bit:                Xilinx BIT file - from BenNUEY.ncd - for 2vp50ff1152 - built 2008/01/10(17:14:41) - data length 0x2447c4ff

This file has been submitted to the maintainer of the file command so some day may come with a default build.

Makefile dependencies

So I inherited a project that apparently had Makefiles written by people who had no idea how Makefiles are supposed to work.

When I edited one of the header files and reran make, nothing happened. So I read some stuff online about making gcc auto-create dependency files. However, they seemed to be outdated pages that referred to using sed and stuff when gcc seems to automagically dump the proper format already. And this is a RHEL3 box, so not exactly cutting edge.

Anyway, I went with a hybrid approach of a few different pages I found, so figured I would share it here.

These reply on the "main" Makefiles defining OBJS as the target files (.o, e.g. SocketHandler.o).

In the main Makefile, I redefined their CLEAN_CMD to add $(OBJS:.o=.d) to the $(RM) command. Then, after the OBJS was defined, I include Makefile.dep.

Also note that this is a little convoluted because the project actually combines a bunch of .o files into .a library files. For non-library compilations, the targets would just be %o and the gcc command line would be slightly tweaked. I just wanted to show the newer-than-any-webpage-I-saw -MF command. No more sed or redirects needed.

Makefile.dep:

# This Makefile will generate .d files for every source file found.
# This allows make to handle header files properly.

# This file must be included AFTER $OBJS has been defined, not in
# the global Makefile

# Include existing .d if they are present:
-include $(OBJS:.o=.d)

# Override default cpp and c compiling instructions:
$%(%.o) : %.c 
        $(CC) -MM -MP $(CPPFLAGS) $(CFLAGS) $*.c -MT "$@($*.o)" -MF $*.d
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c -o $*.o
        $(AR) cr $@ $*.o

$%(%.o) : %.cpp
        $(CXX) -MM -MP $(CPPFLAGS) $(CXXFLAGS) $*.cpp -MT "$@($*.o)" -MF $*.d
        $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $*.cpp -o $*.o
        $(AR) cr $@ $*.o

Obnoxious VMWare console beeps

The VMWare machines on my work laptop would chime whenever I did things like filename completion. The problem was, it was BIOS-level super obnoxious beep that was likely pissing off my cube-neighbors (no volume control nor mute worked). I had turned off all sounds in the Windows host OS, which seemed to be the problem. So if your console beeps are out of hand, set the Windows' "Default Beep" to something. That will have Windows re-intercepting the beep and then the system volume control / mute will work again.

Mail relaying fun

For the second time, my damned ISP has blocked port 25. No real reason, I have secure Linux boxes as the only things sending email; I would get 5-6 server reports a day. That's all. But they blocked me again, and I am sick of arguing with the scripted Indian morons.

Main machine

Anyway, on the main Linux box, ragnarokjr (named so because it is a VM box), I was able to finally get qmail to send all mail thru TLS:

  1. Unpacked netqmail
  2. Applied the full netqmail TLS patch to get base64.h and base64.c
  3. Erased it all and re-unzipped
  4. Copied in the base64.h and base64.c
  5. Applied the remote auth patch only
  6. "make qmail-remote"
  7. Copied qmail-remote over /var/qmail/bin/qmail-remote
  8. Edited /var/qmail/control/smtproutes to include name and password:
    :smtp.isp.net:587 username password
  9. Made smtproutes owned by "qmailr" and chmod og-r so it's kinda secured

So now qmail-remote will use TLS on port 587 as needed to get around the stupid block…

Other machines

One of my other machines runs CentOS which uses exim instead of qmail and it took me a while to find this FAQ.

/etc/exim/exim.conf, in the "routers" section:

send_to_gateway:
  driver = manualroute
  transport = remote_smtp
  route_list = * ragnarokjr.revragnarok.com
  no_more

And of course, /etc/init.d/exim restart

Hopefully, this can help somebody else. I was searching all kinds of terms like "exim upstream" (lots of Debian stuff saying what changed from standard) and it took a bit…

Using SVK for Roaming SVN Users

I have a Trac/SVN server on my work laptop (in a VMWare box). Others are needing access to the files more, so I needed a way to have two way merging. Of course, others have had this problem already, and svk was the result. However, there are certain aspects of svk that I'm not too fond of. Mainly, I didn't want to lose my TortoiseSVN capabilities or all my subversion know-how. However, I'm going to exploit the fact that an svk "depot" is under the hood a svn repository.

Here's what I did:

  1. I needed to get svk running under Cygwin. That was a real PITA, but luckily, somebody was nice enough to put all the instructions on this wiki page.
  2. Now I need to get a local copy of the entire svn repository under svk:
    • svk mkdir svnrepo
    • svk mirror http://svnserver/svn/path/to/repo //svnrepo/reponame
    • svk sync -a (This took FOREVER)
    • svk mkdir local
    • svk cp //svnrepo/reponame //local/reponame

OK, so now, we have a local svk "depot" which has in it /svnrepo/ and /local/ but it is all kept in a single svn repository on your hard drive. Now, the magic: we check out from that file using TortoiseSVN to create a subversion working copy. Using TortoiseSVN, I checked out "from" file:///E:/cygwin/home/user/.svk/local/local/reponame - you'll note that the first part is my cygwin home directory (username of 'user'), and the double local is not a typo - the first is a "real" directory on my E: drive, the second is at the root level of the repository (that we made above).

Now, when I'm offline, I can just use my local working copy, and am able to check in as much as I want without any worries. Another use for this I read about was if you want to check in a lot more than your coworkers do and want to keep the "master" repository "clean."

To perform the actual sync with the master server:

  • svk pull //local/reponame (This makes sure the local svk depot is in sync)
  • svk push --verbatim //local/reponame
    • The verbatim flag prevents svk from inserting its own header which was causing problems with trac by pointing to revision numbers in the future which just made no sense.

Drawbacks

  • One of the files I tried to push was locked on the master repository, but that information doesn't seem to be propagated properly, so the push failed until I unlocked the file manually on the master server.
  • Need to do the push and pull manually.
  • svn's keyword substitution now replaces info with local information, like revision number of the file in the local svk depot, not the master repository (which means printouts aren't going to match). - It seems that all svn properties may be iffy.

Resources

Very odd subversion issue

So, I had a file that refused to be checked in. Seems the file had previously been checked in, but then deleted with the TortoiseSVN checkbox "Keep Locks" checked. So it wouldn't go away. Anyway, the solution was svnadmin rmlocks /data/svn_repos/vhdl_bn /bn.bit

http://paste.lisp.org/display/49343

http://colabti.de/irclogger/irclogger_log/svn?date=2007-10-17,Wed;raw=on

(not really "trac" but I don't have a "svn" tag…)

FAT32 perl utilities

As noted before, my work laptop dual boots into WinXP and Fedora Core 7. They share a large FAT32 partition. Yesterday I finally got a 500GB external drive at work to back up my stuff. It's also FAT32. So I whipped up this quick script that splits a large data stream (using redirection or cat would make files work) and dumps it in 1GB slices. The second has some modifications to instead fill up the hard drive with zeroes, which is needed to make a backup of it more compressable. On a Linux box, I normally just do dd if=/dev/zero of=delme bs=102400 || rm -rf delme but that would exceed the file size limitations of FAT32. The first iteration of the filler was simply cat /dev/zero | perl splitter.pl fill but then realized that there was a lot of actual reading going on, instead of just dumping zeros, so I changed some stuff.

In filler, I tried to pre-allocate the 2GB slice file and then fill it with zero to try to avoid even more fragmentation and FAT table manipulations. However, when I re-opened the file and then seeked to zero it would change the size back down - I didn't have time to research it further; if anyone has a good solution please let me know.

I've also run filler under Cygwin to fill another partition.

splitter.pl:

#!/usr/bin/perl -w
# This program splits incoming data into ~1GB chunks (for dumping a file
# on the fly to FAT32 partitions for example).
# Data is STDIN, and first argument is prefix of output (optional).
#
# To recombine the output, simply:
# cat FILE_* > /path/to/better/fs/OriginalFile

BEGIN {
push(@INC, "/mnt/hd/usr/lib/perl5/5.8.8/");
push(@INC, "/mnt/hd/usr/lib/perl5/5.8.8/i386-linux-thread-multi/");
}
use strict;
use Fcntl; # import sysread flags

binmode(STDIN);

use constant FULL_SIZE => (2*1024*1024*1024); # 2 GB

my $chunk_byte_count = FULL_SIZE+1; # Force an open on first output byte
my $chunk_file_count = 0; # Start at file 0
my ($read_count, $buffer);
my $blksize = 1024; # This might get overwritten later
my $prefix = $ARGV[0] || "FILE";

# The framework of this is from camel page 231

while ($read_count = sysread STDIN, $buffer, $blksize) {
  if (!defined $read_count) {
    next if $! =~ /^Interrupted/;
    die "System read error: $!\n";
  }
  # Decide if we need another file
  if ($chunk_byte_count >= FULL_SIZE) { # Need a new file
    close OUTFILE if $chunk_file_count;
    sysopen OUTFILE, (sprintf "${prefix}_%02d", $chunk_file_count++),
      O_WRONLY | O_TRUNC | O_CREAT | O_BINARY or die "Could not open output file for write!\n";
    $blksize = (stat OUTFILE)[11] || 16384; # Get preferred block size
    # print STDERR "(New output file from $0 (blksize $blksize))\n";
    $chunk_byte_count = 0;
  } # New file
  my $wr_ptr = 0; # Pointer within buffer
  while ($read_count) { # This handles partial writes
    my $written = syswrite OUTFILE, $buffer, $read_count, $wr_ptr;
    die "System write error: $!\n" unless defined $written;
    $read_count -= $written;
    $wr_ptr += $written;
  } # Writing a chunk
  $chunk_byte_count += $wr_ptr;
  #print "(\$wr_ptr = $wr_ptr), (\$chunk_byte_count = $chunk_byte_count), (\$chunk_file_count = $chunk_file_count)\n";
} # Main read loop

# Report on it
print "Wrote out $chunk_file_count chunk files.\n";

filler.pl:

#!/usr/bin/perl -w
# This program fills a hard drive with 2GB files all NULL.
# (This makes compressed images of the hard drive smaller.)
# First argument is prefix of output (optional).
#

BEGIN {
  push(@INC, "/mnt/hd/usr/lib/perl5/5.8.8/");
  push(@INC, "/mnt/hd/usr/lib/perl5/5.8.8/i386-linux-thread-multi/");
}

use strict;
use Fcntl qw(:DEFAULT :seek); # import sysread flags

use constant FULL_SIZE => 2*(1024*1024*1024); # 2 GB

my $chunk_byte_count = FULL_SIZE+1; # Force an open on first output byte
my $chunk_file_count = 0; # Start at file 0
my ($read_count, $buffer);
my $blksize = 16384; # This might get overwritten later
my $prefix = $ARGV[0] || "FILL";
my $last_show = -1;
$| = 1; # always flush

# The framework of this is from camel page 231
$buffer = "\0" x $blksize;

# Without pre-alloc:
#real    1m20.860s
#user    0m10.155s
#sys     0m32.531s

# With pre-alloc:
#real    8m56.391s
#user    0m16.359s
#sys     1m11.921s

# Which makes NO sense, but hey, that's Cygwin... maybe because FAT32?

# Note: It was O_RDWR but switching to O_WRONLY didn't seem to help.
# However, maybe if Norton is disabled?

while (1) {
  # Decide if we need another file
  if ($chunk_byte_count >= FULL_SIZE) { # Need a new file
    close OUTFILE if $chunk_file_count;
    print STDERR "\rNew fill output file ($prefix)... \n";
    sysopen OUTFILE, (sprintf "${prefix}_%02d", $chunk_file_count++),
      O_WRONLY | O_TRUNC | O_CREAT | O_BINARY | O_EXCL or die "Could not open output file for write!\n";
    # Pre-allocate the file
#    print STDERR "New fill output file ($prefix) pre-allocating, expect freeze... \n";
#    sysseek OUTFILE, FULL_SIZE-1, SEEK_SET;
#    syswrite OUTFILE, $buffer, 1, 0;
#    close OUTFILE;
#    print STDERR "\tdone, now blanking out the file.\n";
#    sysopen OUTFILE, (sprintf "${prefix}_%02d", $chunk_file_count++),
#      O_WRONLY | O_BINARY or die "Could not re-open output file for write!\n";
#    sysseek OUTFILE, 0, SEEK_SET; # This might just be ignored?
    # Done pre-allocating
    my $blk = $blksize;
    $blksize = (stat OUTFILE)[11] || 16384; # Get preferred block size
    if ($blksize != $blk) {
      # new block size, should only happen once
      $buffer = "\0"x$blksize;
    }
    $chunk_byte_count = 0;
    $last_show = -1;
  } # New file
  $read_count = $blksize;
  while ($read_count) { # This handles partial writes
    my $written = syswrite OUTFILE, $buffer, $read_count, 0;
    die "System write error: $!\n" unless defined $written;
    $read_count -= $written;
    $chunk_byte_count += $written;
  } # Writing a chunk
  # End of a chunk
  my $new_show = int ($chunk_byte_count/(1024*1024));
  if ($new_show > $last_show) {
    print STDERR "\r${new_show}MB";
    $last_show = $new_show;
  }
#  print "(\$chunk_byte_count = $chunk_byte_count), (\$chunk_file_count = $chunk_file_count)\n";
} # Main while loop

# Report on it [think it always crashes before this ;)]
print "\rWrote out $chunk_file_count chunk files.\n";

Offline Wikipedia

As seen on a million and one websites (/. etc al), a smart geek put together some offline Wikipedia stuff. I had some problems on my work laptop (Fedora Core 7) because of the OS (PHP executable wrongly named) and because of the way I have it partitioned (on a FAT32 partition). Anyway, here's my email to the original poster (wiki-fied):

  1. Thanks, you're a geek hero. ;)
  2. I had a few problems with relative paths, I had to edit the places that pointed at quickstart* executables.
  3. Fedora Core 7's "php5" executable is actually only named "php" - no big deal with a "ln -s /usr/bin/php /usr/bin/php5"
  4. My machine is dual-boot, and the only partition big enough was FAT32. Had some problems with the too many split files. I threw together a perl script (I had done the split by hand before downloading the Makefile ;) ). It's pasted below.

Anyway, thanks again. Feel free to add any of this stuff to your page (like the FC7 notes). If you do, please don't include my email, just credit to RevRagnarok is fine.

  • RevRagnarok
#!/usr/bin/perl -w

# This was written by RevRagnarok (I'm on Wikipedia)
# I was having problems with all the split files on a FAT32 partition. I assume
# it is because there were so many plus two entries for each (LFNs).
# This simply combines all the rec* files again into large chunks of N where
# I used 5, but you can set below with $combine.
# Verification info below.
# Lastly, I needed to modify the Makefile and remove the "split" from the
# "wikipedia" target.

use strict;

# Using: rec13778enwiki-20070802-pages-articles.xml.bz2
my $last = 13778;
my $lastd = 5; # How many digits in above (yes, I can compute this, but why?)
my $date = 20070802;
my $suffix = "enwiki-${date}-pages-articles.xml.bz2";
my $combine = 5; # This will combine every 5 into a group
                 # (If this number makes > 4 digit results, it will not sort nicely)
my $outputdir = '/data/wikipedia/'; # Don't make it the same place...

my $joinstr = '';
my $fcount = 0;

for (1 .. $last) {
  my $num = sprintf "%0${lastd}d", $_;
  $joinstr .= "rec${num}${suffix} ";
  if (($_ % $combine) == 0) {
      &catthem($joinstr, $fcount++);
      $joinstr = '';
  }
}

&catthem($joinstr, $fcount++) if ($joinstr ne '');
print "All done!\n";

sub catthem ($$) {
  my $ofile = sprintf "rec%04d.bz2", $_[1];
  `/bin/cat $_[0] >${outputdir}${ofile}`; # Lazy again, there are more Perl-ish ways.
  print ".";
}

__DATA__

To make sure they were all taken in, you can do this:
bash$ bzip2 -tvv *bz2 2>&1 | grep -v ok | grep -v bz2 | wc -l
13778

...which is equal to the number of start blocks, so I know nothing is missing now.

Download files on a very crappy connection (work PCs)

wget -Sc -T 10 (URL)
ex:
wget -Sc -T 10 ftp://ftp.symantec.com/public/english_us_canada/antivirus_definitions/symantec_antivirus_corp/20051107-019-x86.exe

"Monte Carlo" Perl

This is pretty cool - had not seen it before.

http://math.fullerton.edu/mathews/n2003/MonteCarloPiMod.html

http://en.wikipedia.org/wiki/Monte_Carlo_method

Those of you with cygwin or unix and perl:

#!/usr/bin/perl
my $COUNT = 8; #Orders of magnitude
my $HIT = 0;

for(my $i = 1; $i < 10**$COUNT; ++$i){
        $HIT++ if rand()**2 + rand()**2 <= 1;
        printf "PI ~ %1.8f after %0${COUNT}i points\n", 4*$HIT/$i, $i if
               ($i % 1_000) == 0;
}

I got PI ~ 3.14155046 after 99999000 points and a second run with PI ~ 3.14160204 after 999990000 points

A Better "Bash Here"

There are a lot of ways to do a "bash window here" in WinXP, but this is my fav by far. It gives you the proper unix style mouse buttons since it is a terminal window not just cmd. After installing it, right click on any directory:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\0cmd-rxvt]
@="Bash Window Here"

[HKEY_CLASSES_ROOT\Directory\shell\0cmd-rxvt\command]
@="C:\\cygwin\\bin\\rxvt.exe -bg black -fg white -sr -sl 1000 -fn \"Fixedsys\" -ls -e /usr/bin/bash --login -c \"cd \\\"`cygpath -u '%1'`\\\"; exec bash\""

You may need to change the beginning of the last line if you installed in a different path, e.g. e:\cygwin\.

Updated March 2009

My buddy Bill told me there is now a Cygwin command xhere and a setup command chere that will do all the Registry insertions for you. So launch Cygwin in the default crappy shell (with admin privs) and you can type:

chere -i -af -t rxvt -o "-bg black -fg white -sr -sl 1000 -fn \"FixedSys\" -ls" -s bash -e "Bash prompt here"

You can change -af to -cf for current user only if you don't have admin on the machine.

Because he was kind enough to give it to me, I will give you his command which seriously hurts my eyes. :) I also prefer the default size and expand it if needed.

chere -i -af -t rxvt -o "-ls -sr -sl 1000 -bg grey70 -fg black -geometry 120x65+300+15 -fn 10x16 -title Bash" -s bash -e "Bash prompt here"

Using Trac for Teaching

This is something I wrote up a while back (Trac 0.9). Now it's even easier since 0.10 doesn't need the svn backend.

Using Trac in a Teaching Environment

Obviously, some paths and usernames/groups etc may need to be changed…

  1. Install trac. I used 0.9.6.
  2. Create the repository (fake)
    1. svnadmin create /var/www/svn/teacher
    2. TMPDIR=`mktemp -d`
    3. svn import "${TMPDIR}" file:////var/www/svn/teacher -m "initial setup"
    4. rm -rf "${TMPDIR}"
    5. chown -R apache.apache /var/www/svn/teacher
  3. Create the trac project
    1. trac-admin /var/www/svn/teacher initenv "Mrs. M Web World" sqlite:db/trac.db /var/www/svn/teacher /usr/share/trac/templates
    2. chown -R apache.apache /var/www/trac/teacher
    3. trac-admin /var/www/svn/teacher permission add "Admin" "TRAC_ADMIN"
  4. Set up Apache as needed…
    1. htpasswd -cm /var/www/trac/teacher/.htpasswd Admin
    2. htpasswd -m /var/www/trac/teacher/.htpasswd Teacher
    3. htpasswd -m /var/www/trac/teacher/.htpasswd TestStudent [pwd: test]
    4. Create/modify trac.conf in Apache's conf.d directory (see below)
  5. (Test login at this point)
  6. Install some needed plugins
    1. WebAdmin
    2. TicketDeletePlugin
  7. Now we need to edit trac itself, to make it look nicer for student interface:
  1. Edit /usr/lib/python2.3/site-packages/trac/ticket/web_ui.py
    1. Search for "New Ticket" within a util.Markup() call and change it to "New Question"
  2. Edit /usr/lib/python2.3/site-packages/trac/ticket/roadmap.py
    1. Search for "Roadmap" within a Markup() call (with accesskey 3) and change it to "Syllabus"
  1. Edit trac.ini as needed:
    1. I changed the [header_logo] with an image of the county school system and associated link.
    2. Make sure the various plugins are enabled/disabled in [components] section of trac.ini (see below)
  2. Login again (as 'Admin'). You should have an 'Admin option'.
  3. Permissions. I made two groups "@teachers" and "@students".
    1. @students get TICKET_APPEND, TICKET_CREATE, TICKET_VIEW, ROADMAP_VIEW, MILESTONE_VIEW, WIKI_VIEW
    2. @teachers get TICKET_ADMIN, WIKI_ADMIN, MILESTONE_ADMIN, ROADMAP_VIEW
  4. At this point, we're done with the main server stuff (until the term starts and you need to add more users as above). Now the teacher can customize with that login (recommended).
  5. My recommendations:
    1. Milestones:
      1. These should be based on the syllabus (that's what the students see it as). I assume each major section of the class would get one. The "due date" could be the Monday of the Quiz week or something similar.
    2. Ticket types: General Question and Clarification Request
    3. Components: None (removed them all)
    4. Priorities: None (removed them all)
    5. Severities: None (removed them all)
    6. Versions: None (removed them all)

httpd.conf

Alias /trac/ "/usr/share/trac/htdocs/"

<Location /teacher>
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /var/www/trac/teacher
   AuthType Basic
   AuthName "Mrs. M's Web World"
   AuthUserFile /var/www/trac/teacher/.htpasswd
   Require valid-user
</Location>

trac.ini excerpts

[components]
webadmin.* = enabled
trac.wiki.macros.macrolistmacro = disabled
trac.versioncontrol.web_ui.log.logmodule = disabled
trac.about = disabled
trac.search.searchmodule = disabled
ticketdelete.* = enabled
trac.versioncontrol.web_ui.changeset.changesetmodule = disabled
trac.ticket.web_ui.updatedetailsfortimeline = disabled
trac.mimeview.patch.patchrenderer = disabled
trac.mimeview.rst.restructuredtextrenderer = disabled
trac.wiki.macros.pageoutlinemacro = disabled
trac.attachment.attachmentmodule = disabled
trac.wiki.macros.imagemacro = disabled
trac.versioncontrol.web_ui.browser.browsermodule = disabled
trac.mimeview.php.phprenderer = disabled
trac.timeline.timelinemodule = disabled

The opposite of chmod

Well, I've been using Unix for since 1993, and I just realized I don't know what the opposite of chmod is - how do I just show the permissions, not set them? lsmod is Linux kernel module listing. So, I used stat which is likely overkill. But sadly that took me a while to think of.

Rsync over ssh for backing up some files

  1. Make a file with the ssh user and password called /etc/backupcredentials_ssh
    1. Make a directory on the backup server called /mnt/backup/this_hostname/
      • Make sure it is owned by backup_user
rsync -av --delete -e ssh -l backup_user -i /etc/backupcredentials_ssh /mnt/backup backup_server:/mnt/backup/this_hostname/

This way I was able to avoid using a samba mount between the two.

Automated diffs in trac

Somebody on the mailing list for trac wanted to make a daily wiki page with the diffs for a build. He already had the scripts to do a nightly build, so I suggested this, and tried it and it worked:

echo {{{ > /tmp/tempo
echo '#!diff' >> /tmp/tempo
svn diff -r70:76 >> /tmp/tempo
echo }}} > /tmp/tempo
trac-admin /var/www/trac/personal wiki import TodaysDiff /tmp/tempo

The new blog is ready!

So I have now competed moving all my stuff from the bblog engine to trac.

To inaugurate the new blog, my notes on how I did it:

  1. By hand, slowly copied and tagged every entry. Made sure the page name was the proper date (ignored timestamp) from the old system.
  2. Wrote a script to fool trac into thinking the pages were actually written on that date (see below).
  3. In the directory with trac.db database:
    1. apachectl stop
    2. sqlite3 trac.db '.dump wiki' > wiki_in.txt
    3. ./trac_blog_datefix.pl < wiki_in.txt > wiki_out.txt
    4. sqlite3 trac.db 'drop table wiki'
    5. sqlite3 trac.db < wiki_out.txt
    6. apachectl start

The script:

#!/usr/bin/perl -w
use Date::Parse;
while (<>) {
        if ($_ !~ /insert into/i) {
                print;
                next;
        }
        if (m|(\d{4}/\d{1,2}/\d{1,2})/|ios) {
                print STDERR "Found date of $1: ";
                my $time1 = str2time($1);
                print STDERR $time1, "\n";
                # Now replace the current timestamp with a newone.
                my $str = $_;
                $str =~ s/\d{10}\.?\d{0,2}/$time1/;
                print $str;
        } else {
                # Standard wiki page (non-blog)
                print;
        }
}

Roll your own subversion

Under Cygwin…

Waiting for an official subversion 1.4 - but until then, I lost my command line svn because Tortoise SVN (awesome BTW) updated my working copy to the new format.

Abbreviated setup (I'm not telling you how to use tar, etc). It's also good idea to disable your virus scanner for a few minutes. Spawning processes under cygwin is painful to start with…

  1. Download both subversion and it's deps. Currently:
    http://subversion.tigris.org/downloads/subversion-deps-1.4.0.tar.bz2
    http://subversion.tigris.org/downloads/subversion-1.4.0.tar.bz2
    

These are from http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=260&expandFolder=74

  1. Extract them both
  2. $ ./configure --prefix=/usr/local/svn14 --enable-all-static --disable-mod-activation
  3. make all
  4. make check

(You can usually just do "make check" but there seems to be a bug where it won't properly build the dependencies)

  1. make install
  2. add to .profile:
    alias svn14="/usr/local/svn14/bin/svn"
    

I have done this on two machines now. On both, some symlink stuff failed under one of the python checks. Oh well…

Make DVD Installer from CDs

Just stumbled on this online. Feel free to extrapolate:

  1. Create a Temp folder on harddrive. Name this folder "HL2_DVD" This will be the Label of our DVD.
  2. Copy all contents of CD1 to this Temp folder.
  3. From CD2 copy just two files! The "cab" file (hl2.CAB) and the "installer.dll" file to the main directory of the Temp folder.
  4. From CD3 copy the "hl23.CAB" file to the main directory of the Temp folder.
  5. From CD4 copy the "hl24.CAB" file to the main directory of the Temp folder.
  6. From CD5 copy the "hl25.CAB" file to the main directory of the Temp folder.
  7. Now download and install "Orca".
  8. Once Orca is installed go to the Temp folder and right click the file "hl2.msi" and from near the top of the menu choose "Edit with Orca".
  9. When opened you will see 2 window panes, go to the "Tables" one on the left and scroll down to Media"
    1. Click on "Media" this will show you the entries in the Right pane. There will be 6 columns.
    2. Change all the entries in the "VolumeLabel" column to HL2_DVD
    3. Then "Save" it. (You can also use a program called "Masai Editor" instead of "Orca")
  10. Now burn to a DVD using Nero using the Label HL2_DVD.

Annoying Reboot Prompt

http://blogs.wdevs.com/ColinAngusMackay/archive/2005/10/16/10858.aspx

Text: Updating your computer is almost complete - Restart Now?

I just saw the following tip from Daniel Turini on CodeProject:

I found this after a lot of Googling, so I'd like to share the solution. Yep, this may not be new or even advanced but it surely helped me…

Anyone who is running Windows XP SP2 know what I'm talking about. That stupid, annoying, most ill-designed dialog box ever invented in the history of the computer science that asks "Updating your computer is almost complete. You must restart your computer for the updates to take effect. Do you want to restart your computer now?" And there are only two options: Restart Now/Restart Later. "Restart Later" means that this stupid thing will ask you again in 10 minutes. Yes, if you're willing to work for the next 4 hours until lunch before rebooting, this means you'll need to answer this question 24 times. Did I mention that the dialog steals the focus?

Now, to get rid of it: Start / Run / gpedit.msc / Local Computer Policy / Computer Configuration / Administrative Templates / Windows Components / Windows Update / Re-prompt for restart with scheduled installations

You can configure how often it will nag you (I re-configured it for 720 minutes, which means I'll be asked twice on a work day), or completely disable it.

Oh, I almost forgot: this setting is only loaded when Windows starts, so a reboot is needed. If that stupid dialog is on your screen now, just stop the "Automatic Updates" service (but keep it as Automatic, so it gets reloaded on the next start) and you won't see it again.

Addition (28-June-2006):
In response to this comment, I'd like to flag up here that he is completely right. I offer this tip as a short delaying tactic so that you can continue your work until the end of the day. At the end of the day you shut down your PC and when you reboot the following morning everything is installed and patched up. This should not be used to delay the installation of patches and security updates indefinitely. As a matter of course you should install security updates as quickly as you can.

Fix missing HAL, etc in Windows XP

http://www.informationweek.com/story/showArticle.jhtml?articleID=185301251

For example, if you already have some knowledge of the commands involved, many "Missing or corrupt HAL.DLL," "Invalid Boot.Ini," or "Windows could not start…" problems can be fixed with these five shortcut steps:

  • Boot from your XP Setup CD and enter the Recovery Console
  • Run "Attrib -H -R -S" on the C:\Boot.ini file
  • Delete the C:\Boot.ini file
  • Run "Bootcfg /Rebuild"
  • Run Fixboot

API Reference Page

Remove USB Icon

I had an external drive running for hours and hours to stress test it. Then my "remove" icon was gone. Nothing to right click, etc.

Finally found this:

C:\WINDOWS\system32\rundll32.exe shell32.dll,Control_RunDLL hotplug.dll

Just made it an icon on my desktop for emergencies.

Unattended XP Install

Paste code for others

Cleaning up your bblog blog

I am sick of these spammers putting trackback crap. My system doesn't allow trackbacks nor comments, but I have over a thousand filling up my database anyway. When I move fully to my new server, I plan on converting it all to a non-public wiki anyway.

To clean yours out:

Go into SQL, whatever way you normally do.

use blog; <-- yours may be different of course
DELETE FROM bB_comments where type = 'comment';
DELETE FROM bB_comments where type = 'trackback';

Now to stop them: Go into the bblog directory:

mv trackback.php trackback_disabled.php

I'll update this later if there's more.

Good for eBay

Some interesting httpd rewriting with perl

<VirtualHost *>
  ServerName svn.whatever
  ServerAlias svn
  <Perl>
#!/usr/bin/perl
my $svn_path = "/var/svn";
my $svn_location = "";
my $trac_path = "/var/trac";
opendir(SVN_ROOT, $svn_path) or die "Cannot open $svn_path";

while (my $name = readdir(SVN_ROOT)) {
  if ($name =~ /^[[:alnum:]]+$/) {
    $Location{"$svn_location/$name"} = {
      DAV => "svn",
      SVNPath => "$svn_path/$name",
      AuthType => "Basic",
      AuthName => "\"Subversion login\"",
      AuthUserFile => "$trac_path/access.user",
      AuthGroupFile => "$trac_path/access.group",
      Require => "group $name",
    };
  }
}

closedir(SVN_ROOT);

__END__

  </Perl>
</VirtualHost>

Pet Care link

Marlin P Jones

I used to buy geek crap from these guys all the time ;)

http://www.mpja.com/

Tater Tot Casserole

http://tinyurl.com/awhjk

Ingredients: 1 32 oz bag tater tots
½ cup sour cream
½ cup butter
1 cup cheddar cheese
1 can cream of chicken soup
½ med onion (chopped)
1 cup corn flakes

Directions: Thaw tater tots and break up. Add ingredients one by one, mixing after each. Spread in buttered pan, best if let set overnight. Top with corn flakes that have been mixed with ½ cup melted butter. Cook at 350 for 50 mins.

ntpd troubles

Moving server, having trouble. Found this. Seems to fix the windows client, not the linux one.

http://mail-index.netbsd.org/current-users/2004/01/16/0023.html

Subject: ntpd default change

To: None

From: Christos Zoulas

List: current-users

Date: 01/16/2004 17:56:40

Hello,

People who use windows ntp clients [and other unauthenticated clients] served by netbsd ntp servers will notice after upgrading ntpd to current their clients cannot sync anymore.

So that others don't spend time debugging this:

  1. Authentication in the new version of ntp is turned on by default;

you'll have to turn it off. The option to do this has also changed. If you had in your config file "authenticate no" should change it to "disable auth".

  1. "restrict notrust" means don't trust unauthenticated packets, so remove

notrust from your restrict line. This seemed to work fine before with "authenticate no".

Of course, you should only do this if you really need to. If your clients can authenticate, you should keep authentication on.

I hope this is useful,

christos

My DIY Bike Rack

Using qmail in an RPM (or YUM) world...

I was trying to run 'yum update' on my webmail server, which runs the highly recommended qmailrocks.org distro. Well, to get it to stop trying to install exim / sendmail / postfix I was able to create a "fake_mta.spec" based on one I found online (but had to transcribe into a VM box):

# Use rpmbuild -bb to install this

Buildarch: noarch
Conflicts: sendmail, exim, postfix, qmail
Group: Productivity/Networking/Email/Servers
License: GPL
Name: fake_mta
Provides: smtp_daemon
Release: 1adm
Summary: Fake package to protect qmail's sendmail files.
Version: 1

%description

A fake package so that qmail won't get hosed,
even tho RPM/YUM don't know about it.

%changelog
* Sun Sep 25 2005 Aaron D. Marasco
- Shamelessly stolen from SuSE security list (Chris Mahmood)

%files
/usr/sbin/sendmail 

!GreaseMonkey Rocks! :)

Finally playing with it (instead of sleeping)

Anyway, I like the auto-linkifier, but I changed one line to make it actually tell me it did the autolinkify.

Original: http://mozdev.sweetooth.org/greasemonkey/linkify.user.js

Changed line 39:

a.appendChild(document.createTextNode(match[0] + " (autolinked)"));

Netflix vs. Blockbuster

Well, I've had Netflix since forever (391 DVDs since 2001). Yes, sometimes they throttle. But I haven't had much problem with that because I don't have my queue full of all new releases. To make a long story very short, they kick BB's ass. I have tried BB for a little over two weeks now. The only advantage I see in BB is the ability to get 2 games or DVDs a month at the local store.

Selection: Netflix just has more movies, period. I really want to see the DVD "Star Wars: Clone Wars" from the Cartoon Network. BB has no mention of it, NF has had it in my saved queue since I first heard about it.

Availability: BB is crap. Of course, it is very possible that they are throttling me. Here's my current queue - note this is Apr 2005… I have added at the end of every line the year the movie is from

Movie Title Rating Availability
Bamboozled [WS] R Long Wait 2000
Shaolin Soccer PG13 Short Wait 2001
Eurotrip [WS] [Unrated] NR Short Wait 2004
Astronaut's Wife R Short Wait 1999
Torque [WS] PG13 Short Wait 2004
Honey [WS] PG13 Short Wait 2004
Tommyknockers NR Long Wait 1993
Fish Called Wanda R Short Wait 1988
Booty Call R Long Wait 1997
White Chicks [WS] PG13 Short Wait 2004
Club Dread [WS] NR Short Wait 2004

I have no idea how "The Bootiest Edition" of Booty Call from 1997 can be a 'Long Wait' along with an old Stephen King miniseries. As a guy I used to work with liked to say, "I call bullshit!"

Mjolnir, Ghost, Backup, etc

NOTE TO EVERYBODY WHO IS NOT ME: You can ignore this post. It's just random notes that I need somewhere safe. However, as of Dec 2006, it no longer applies, I use a modified version of SaraB.

Ghost really doesn't like my combo of SATA, IDE, LVM, and whatnot. To get the IDE (hdb) backup copied to the SATA (sda) I had to:
1. GHOST /FDSZ /IAL image /boot from hdb (Drive 4) to an image.
2. Put a partition on sdb (good thing it was empty)
3. Re-run ghost, copy image to sdb (not sda2 where it should be!)
4. Boot from CentOS install DVD with kernel command line:
linux rescue hdb=noprobe noexec=off noexec32=off
(took ~2 hours to find out the last two stop grub 0.95 from segfaulting on an install!)
5. mount up /dev/sda2 (destination) somewhere. Go into that directory and wipe it clean.
6. From that directory: dump -0 -f - /dev/sdb1 | restore -rf -
7. Relabel sdb1 so we don't have two /boot partitions!: tune2fs -Ljunk /dev/sdb1
8. unmount /dev/sda2
9. chroot /mnt/sysimage
10. grub --no-floppy
root (hd0,1)
setup (hd0) <== kept segfaulting here on SATA drive until noexec flags from above.
[Don't use grub-install that bombed too!]

OK, that's all the scraps of paper I can find. I really need to get a backup system running on this server before I migrate to it!

How to edit RAM disk images

I really want to read more about how this nash/lvm stuff works on my server…

Editing Ramdisks (initrds)

Following are the steps that enable one to edit a ramdisk for any changes:

  1. gunzip -c /boot/initrd-.img >initrd.img
  2. mkdir tmpDir
  3. mount -o loop initrd.img tmpDir/
  4. cd tmpDir
  5. Make all necessary changes (copy over modules, edit linuxrc etc)
  6. umount tmpDir
  7. gzip -9c initrd.img >/boot/initrd-.img

(stolen from http://openssi.org/cgi-bin/view?page=docs2/1.2/README.edit-ramdisk )


Follow-up

At some point, they stopped making them loopback ISOs and now they are just a compressed cpio archive:

 mkdir initrd
 cd initrd/
 gzip -dc /boot/initrd-2.6.23-0.104.rc3.fc8.img | cpio -id

The cpio is in the "new" format, so when recompressing, you need to use --format='newc' .

(stolen from http://fedoraproject.org/wiki/KernelCommonProblems )

My Kingdom for a Command Line!

I need to disable a drive in Linux (the BIOS hides it, but the kernel is 'too smart'). I searched high and low for "linux kernel command line" etc, etc.

Anyway, what I was looking for:

hdb=noprobe

From: http://linux.about.com/library/cmd/blcmdl7_bootparam.htm

One of my 3 Linux boxes has that man page. The other 2 DON'T. That, and it seems ancient but helpful nonetheless.

Ghost no likee LVM

Yet more problems with Ghost… LVM crashes it with some nasty error about sectors that were in the negative billions. Anyway, tell it to just blindly copy Linux partition sectors (which sucks):

ghost /FDSZ /IAL

Firefox and Thunderbird Extensions

These are the ones I currently use. Find the links yoself.

FF: (ListZilla exported this list:)

http://blog.vollmondlicht.com/ someorbityellow 0.2.2 - A theme for Firefox based on Orbit 3+1
http://autofill.mozdev.org/ Autofill 0.2 - Automatically fill out HTML forms
http://extensions.roachfiend.com BugMeNot 0.6.2 - Bypass compulsory web registration with the context menu via www.bugmenot.com.
http://extensions.roachfiend.com Ext2Abc 0.2.1 - Alphabetizes your extension manager list.
http://flashblock.mozdev.org/ Flashblock 1.3.1 - Replaces Flash objects with a button you can click to view them.
http://clav.mozdev.org/ Flowing Tabs 0.4 - Wrap excess browser tabs onto multiple rows
http://forecastfox.mozdev.org/ Forecastfox 0.8.1.1 - Get international weather forecasts and display it in any toolbar or statusbar with this highly customizable extension.
http://googlebar.mozdev.org/ googlebar 0.9.5.06 - The Googlebar for Firefox
http://ackroyd.de/googlepreview/ GooglePreview 0.9 - Inserts web site previews in google and yahoo search results.
http://gemal.dk/mozilla/linky.html Linky 2.6.0 - Open/download/validate links and pictures in tabs or windows
http://extensions.roachfiend.com ListZilla 0.5.1 - Outputs an alphabetical list of either extensions or themes to a text, vB code, or HTML file.
http://v2studio.com/k/moz/ miniT (drag+indicator) 0.5 - Adds tab dragging with drop place indicator.
http://quicknote.mozdev.org/ QuickNote 0.6 - A note taking extension with advanced features
http://www.corestreet.com/spoofstick/ SpoofStick 1.05 - A simple way to detect spoofed websites.

TB:
Allow Empty Subject (c'mon!)
Buttons!
No New Window on Double Click
Quote Colors
QuickNote (Interchanges with FF)
QuoteCollapse
Virtual Identity (very useful for mailing lists)

A Link

Secret Firefox settings

Shamelessly stolen from: http://www.windowssecrets.com/comp/041202/

Go check it out!

Settings for me to remember:

browser.cache.memory.capacity 32000
layout.frames.force_resizability true
config.trim_on_minimize false 

Today was proxy fixing day!

Well, spent half of today fixing computers for the woman's family.

They insist on using AOL DSL, so to share the connection they have to use AnalogX Proxy instead of a "normal" wireless router. I got that up and running a year or so ago. But there have been glitches that I wasn't aware of until today.

Problem 1: Firefox don't work. On either client machine. Weird DNS issue too that I had once before with other reasons (look around on this blog). Basically any site you went to would be the same site as the first. Example - home page is google.com, then I try to go to windowsupdate.microsoft.com and it is google again. Type microsoft.com/cgi-bin/whatever and you get a 404 from google.com saying "I don't have /cgi-bin/whatever "

OK, so the fix. AnalogX proxy cannot handle HTTP/1.1 - you need to do HTTP/1.0 only.

about:config
Find "network.http.proxy.version" and make it "1.0"

Problem 2: Apparently, Microsoft in their infinite wisdom f'd up WindowsUpdate with SP2. The one machine worked fine. The other machine (brand new Dell laptop) didn't. So I update the other machine to SP2 and now it doesn't get WindowsUpdate either! Turns out that post-SP2 WindowsUpdate IGNORES THE PROXY SETTINGS YOU PUT INTERNET EXPLORER!!! What's the POINT?!?!

The fix: I'm not sure. There is a program "proxycfg" that sets up the proxy settings. I'm not sure which worked, one of these two (from the command line):

proxycfg -u

Supposedly updates the settings based on your IE ones. I'm not sure if that worked. Other possible:

proxycfg -p "http://10.70.70.70:6588"

(Obviously, put your proxy server/port in there)

As always, if this helped solve your problems, please drop me a 'thanx' note.

Shutting down VMWare clients

In /etc/services on CLIENT:

# Local services
shutdown 6666/tcp

In /etc/inetd.conf on CLIENT:

shutdown stream tcp nowait root /sbin/shutnow

In /sbin/shutnow of CLIENT: (you can prolly get rid of this and move this all into inetd.conf above, but I used to do other things too…)

#!/bin/bash
/sbin/shutdown -h now

On the CLIENT's iptables rules, I have:

0 0 DROP tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:6666

So nobody can reach that port from eth1 (internet). The host will be hitting the port on eth2 which is the host-only virtual network.

Then on the HOST in /etc/init.d/kill_vms (new file):

#!/bin/sh
#
# chkconfig: 4 90 08
# description: Kills VMs on shutdown/reboot
/usr/bin/telnet 192.168.90.201 6666 < /dev/zero
PIDS=fake
while [ "foo$PIDS" != "foo" ]
do {
echo "Delaying shutdown... VMWare still on $PIDS"
sleep 10
PIDS=`pidof vmware-vmx`
};
done

So then on the server you install the "kill_vms" with chkconfig (fix the IP from 192.168.90.201 to your virtual client IP of course!).

It won't work the first time you reboot, sorry. If you 'touch' the file /var/lock/subsys/kill_vms (at least on my ancient RH based system) then it should. Also, it will hang forever if you don't have the virtual machine set to 'Close on shutdown' and I think maybe another option in VMWare about closing if all clients close.

GPart - Guess partitions

Friend has his partition table hosed. He's starting with this, and it seems to be working very well. Looks awesome, figured I would virtually jot it down…

http://www.stud.uni-hannover.de/user/76201/gpart/

http://www.stud.uni-hannover.de/user/76201/gpart/gpart-man.html

Follow-up: He was able to get back his data. He actually ended up using this: http://www.cgsecurity.org/index.html?testdisk.html

mydiff - INI style diff

Well, needed to compare two 300MB directories at work yesterday. Unfortunately, 'regular' diff just wasn't cutting it. A file would be declared different even if it was an INI style moved section… Example:

File 1:
[a]
Setting1=a
Setting2=b
[b]
Setting3=c
Setting4=d

File 2:
[b]
Setting3=c
Setting4=d
[a]
Setting1=a
Setting2=b

Obviously, these two files are EFFECTIVELY the same, but diff will show the first as having the entire [a] section only, then [b] common, then file 2 only having… the same exact [a] section. So I whipped up a perl script to tell me that those two files are the same. This script may have problems and might not do what you want (it was quick and dirty) but it may help others (and me later, which is what this blog is more for anyway)… Looking at it this morning I can see a handful of places to easily condense it, but oh well… and if you care, these were Quartus project files and associated files (CSF, PSF, etc). Note: It fails when there is a < > or | in the text file. But if usually dumps so little you can eyeball it and decide if it is OK.

#!/usr/bin/perl -w
use Data::Dumper;
my $textdump;
my %lhash;
my %rhash;
my $debug = 0;
my $file = $ARGV[0];
# Some filenames have () in them that we need to escape:
$file =~ s/\(/\\(/g;
$file =~ s/\)/\\)/g;

open (INPUT, "diff -iEbwBrsty --suppress-common-lines Projects/$file Folder\\ for\\ Experimenting/Projects/$file|");
while (<INPUT>) {
        if ($_ =~ /Files .*differ$/) {
                #Binary files
                print "Binary file comparison - they differ.\n";
                exit;
        }
        if ($_ =~ /Files .*identical$/) {
                print "No diff!\n";
                exit;
        }
        my $a = 0;
        # For some reason chomp was giving me problems (cygwin, win2k)
        s/\n//g;
        s/\r//g;
        $_ =~ /^(.*)([<>\|])(.*)$/;
        my $left = $1;
        my $dir = $2;
        my $right = $3;
        $left =~ /^\s*(.*?)\s*$/;
        $left = $1;
        $right =~ /^\s*(.*?)\s*$/;
        $right = $1;
#       print "1: '$left'\n2: '$dir'\n3: '$right'\n";
        # OK, now we have all we wanted...
        if ($dir eq '<') {
                $lhash{$left}++;
                $a++;
        };
        if ($dir eq '>') {
                $rhash{$right}++;
                $a++;
        }
        if ($dir eq '|') {
                $lhash{$left}++;
                $rhash{$right}++;
                $a++;
        }
        print "Missed this: $left $dir $right\n" unless $a;
} # while

close(INPUT);
foreach (sort keys %lhash) {
        if (not exists $rhash{$_}) {
                # No Match...
                print "Only in left: '$_'\n";
        } else {
                if ($lhash{$_} != $rhash{$_}) {
                        print "Left count not equal to Right, $_\n";
                }
        }
}

foreach (sort keys %rhash) {
        if (not exists $lhash{$_}) {
                # No Match...
                print "Only in right: '$_'\n";
        } else {
                if ($lhash{$_} != $rhash{$_}) {
                        print "Left count not equal to Right, $_\n";
                }
        }
}

print Dumper(\%rhash) if $debug;
print Dumper(\%lhash) if $debug;

Finally... some rebate laws!?!

(Note, I almost never advocate new laws…)

Yes, it is California only, but note (from FatWallet):

I think the law will have a nationwide effect. Here's why:

Almost 75% of technology companies are headquartered in California, so all of them are subject directly to the law.

The law pertains to anyone who offers a rebate to a California resident, and that affects the remainder of companies (even though California would have a tougher time enforcing it's law on companies outside of its jurisdiction).

No matter, since everyone will have to comply with the California law where it pertains to California residents, they will not be able to differentiate them from residents of other states and so they will be forced to apply the terms of the law to everyone.

http://info.sen.ca.gov/cgi-bin/postquery?bill_number=sb_1154&sess=CUR&house=B&site=sen

ADDED BONUS

The FTC WANT you to report to them when you don't get the rebates using consumer protection laws! :)

http://www.ftc.gov/bcp/conline/pubs/alerts/rebatealrt.pdf

Cool rescue CD system

Print everything after the last occurrence

This may be long and convoluted but it is the first thing that came to mind and it worked.

Had a log file that would delimit with "As Of nn/nn/nnnn" which could be multimegabytes. Didn't feel like doing a perl solution that day, so:

grep -n 'As Of' sourcefile | tail -1 | awk -F":" '{print $1}' | xargs -r -iX awk 'FNR>=X' sourcefile > outfile

Again, likely an easier solution, but this was Q&D.

More cpio tricks

Cleaning out my desk and came across these notes…

find /mnt/old_root -depth -print | cpio -odv | gzip -c -v -1 > /opt/bad_disk/old_root.cpio.gz

find -depth -print | cpio -odv > tempo.cpio
cpio -idvm < tempo.cpio

Neat trick:

tar cf - . | (cd /usr/local ; tar xvf - ) 

Peeking on a process

We have a problem at work with an ssh failing, but I don't have access to the source of the program running ssh. So I replaced ssh with this script, renaming the old ssh to ssh_orig. The extra flags on ssh were just me seeing if I can get the thing to work, you can ignore them:

#!/bin/bash
echo $* >> /tmp/ssh-$$-in
ssh_orig -C -2 -x $* | tee /tmp/ssh-$$-out

This creates a bunch of files in /tmp/ with the input command line string given to the script in the -in files and the output in the -out files.

Note, this will probably cause a security audit problem since you messed with ssh. ;)

Anti-phishing site

Smartass Answer

Next time I get a dumb Q: http://tinyurl.com/22c6t

eBay Negative Ratings Sorter

Removing Norton !AntiVirus for GOOD

Hello Aaron,

Thank you for contacting Symantec Online Technical Support.

In your message you wrote:

I previously had NAV 2000 installed. I had paid for subscription upgrades and my last one expired 6/21/04. I bought NAV 2004. I went to install, it said to uninstall 2000, so I did. I now installed and activated NAV 2004. However, when I start it, it says I get 366 days of subscription but still shows 6/21/04 as the end date! I cannot even run the program.

Aaron, this issue occurs due to traces of the previous version still present on your computer. In order to resolve this issue, I suggest that you uninstall Norton AntiVirus (NAV) 2004, uninstall previous version completely using Rnav2003.exe utility, perform clean boot of Windows and then reinstall NAV 2004.

Please follow the steps in the URL provided below to uninstall NAV 2004:

Title: 'Uninstalling Norton AntiVirus 2004 or Norton AntiVirus 2004 Professional Edition' Document ID: 2003080311011006

Web URL: http://service1.symantec.com/Support/nav.nsf/docid/2003080311011006

Rnav2003.exe is a utility that manually uninstalls the program files and registry entries that are installed by NAV 5.0/2000/2001/2002/2003. Please follow the steps in the URL provided below to uninstall NAV by using Rnav2003.exe:

Title: 'How to uninstall Norton AntiVirus 2003 or earlier by using the Rnav2003.exe removal utility' Document ID: 2001092114452606

Web URL: http://service1.symantec.com/SUPPORT/nav.nsf/docid/2001092114452606

A clean boot is a restart of Windows with no applications running and with as few extra drivers loading as possible. Please refer the document provided below for instructions to clean boot your computer:

Title: 'Configuring Windows 98 to clean boot' Document ID: 199869145548

Web URL: http://service1.symantec.com/Support/tsgeninfo.nsf/docid/199869145548

Please click on the URL link mentioned below to read the Knowledge Base Document for the installation procedure, if you have the installation program in the CD:

Title: 'Installing Norton AntiVirus 2004 or Norton AntiVirus 2004 Professional from the CD' Document ID: 2003072912563606

Web URL: http://service1.symantec.com/Support/nav.nsf/docid/2003072912563606

If you have purchased the software from Symantec Store, please be aware that when you purchase a downloadable product from the Symantec Store, you may, for the purpose of reinstalling a replacement copy, download the software any number of times from the Symantec Store within a period of 60 days from the date of purchase at no additional charge.

If it is more than 60 days then this is not possible unless the Extended Download Service (EDS) had been previously purchased.

If you have purchased the EDS, you may download the software any number of times, for a period of one year after the date of purchase.

If you know your order number and your password, or know both the email address and credit card number under which the order was placed, you can download it again from Symantec store. Please note that you may download the software only for a period of one year after the date of purchase.

For re-downloading the software, please refer to the link provided below:

Web URL: http://www.symantecstore.com/orderlookup

If you do not remember your order details or encounter a difficulty during the download process or have any concerns regarding the download of the software, I recommend that you contact Symantec Store. You may contact Symantec Store directly by calling the following phone numbers:

International: 1-952-646-5623 North America: 866-285-6460

Or by Web at:

http://www.symantecstore.com\question

Note that Symantec Store is only responsible for software that is downloaded from the Symantec Store Web site. If you purchased the Norton software from another location then please contact the site you purchased from for assistance regarding the re-download of the software.

Please refer to the link provided below for the installation of Norton AntiVirus (NAV) that has been downloaded:

Title: 'Installing Norton AntiVirus 2004 or Norton AntiVirus 2004 Professional Edition that was downloaded from the Symantec Store' Document ID: 2003072611124806

Web URL: http://service1.symantec.com/SUPPORT/nav.nsf/docid/2003072611124806

Please let us know if this resolves the issue or if we can be of further assistance.

Regards,

Yeshaswini Symantec Authorized Technical Support

Radio listings

Radio listings. If you want to know what song you just heard. And the album it is from.

http://www.yes.net/

One of the few advantages of a handful of media companies owning all the stations.

Windows XP Wireless Network Dropping?

wikipedia.org

This site is AWESOME.

It's trying to be a collective knowledge base of the world.

Sounds cheesy, don't it?

I can click this link http://en.wikipedia.org/wiki/Special:Randompage all frikken DAY!

How else would I learn about http://en.wikipedia.org/wiki/Snus ?

What's so cool is that ANYONE can contribute. In fact, if you looked up 'Prospect' this morning you wouldn't see my hometown in CT. Why? Well, somebody else wrote up an article (actually, a bot that pulled the data from gov't servers) but never added it to the 'disambiguity' page. So I just did. And NOW if you search for 'Prospect', you'll see a link to the Prospect, Connecticut page.

Bank routing numbers

Do it until it works!

#!/bin/bash
# From LinuxGazette.com (Ben Okopnik)
# Rerun command line until successful
until $*; do sleep 1; done

Lazy Origami

cpio Cheat Sheet

http://www.intencorp.com/karmilow/share/howto-cpio.html

Bernie's abbreviated Solaris/Linux cpio How-To

1. Backing up files to a cpio file

cd to the directory you want to archive, and issue the command

solaris-$ find . -depth -print | cpio -ocBdum > filename.cpio

-or-

linux-$ find . -depth -print | cpio -o -H newc > filename.cpio

2. Restoring files from a cpio file

cd to the directory you want the archived files written to, and issue the command

solaris-$ cpio -icBdum < filename.cpio

-or-

linux-$ cpio -idum -H newc < filename.cpio

3. Backing up files to a cpio tape

cd to the directory you want to archive, and issue the command

solaris-$ find . -depth -print | cpio -ocBdum > /dev/rmt/0

-or-

linux-$ find . -depth -print | cpio -o -H newc > /dev/rmt0

4. Restoring files from a cpio tape

cd to the directory you want the archived files written to, and issue the command

solaris-$ cpio -icBdum < /dev/rmt/0

-or-

linux-$ cpio -idum -H newc < /dev/rmt0

5. Restoring a particular file from a cpio tape

cd to the directory you want the archived file (/etc/hosts in this example) written to, and issue the command

solaris-$ cpio -icBdum < /dev/rmt/0 "/etc/hosts"

-or-

linux-$ cpio -idum -H newc < /dev/rmt0 "/etc/hosts"

6. Some other local (Linux) examples

local out:

find etc -depth -print | cpio -o -H newc > cpios/etc.cpio
find include -depth -print | cpio -o -H newc > cpios/include.cpio

local in:

cpio -idum -H newc < /mnt/home/cpios/etc.cpio
cpio -idum -H newc < /mnt/home/cpios/include.cpio

7. Some network (Linux) examples

net out:

pull: remote cpio -> local archive
rsh -n remote_host "cd /remote_dir ; find remote_file -depth -print | cpio -o -H newc" > local_archive
push: local cpio -> remote archive
find local_file -depth -print | cpio -o -H newc -F remote_host:/remote_dir/remote_archive

net in:

pull: remote archive -> local cpio
cpio -idum -H newc -F remote_host:/remote_dir/remote_archive
rsh -n remote_host dd if=/remote_dir/remote_archive | cpio -idum -H newc
push: local archive -> remote cpio
dd if=/local_dir/local_archive | rsh -n remote_host "cd /remote_dir ; cpio -idum -H newc"

Free Web Site Registrations

Skip logins on pages like New York Times… http://bugmenot.com/index.php

How Old Are You?

http://www.onlineconversion.com/howold.htm

Today is my 10430th day. Yay.

Finding pinouts

Found this online today when looking for PCI pinouts…

http://www.repairfaq.org/
More specifically…
http://www.repairfaq.org/REPAIR/
http://www.repairfaq.org/REPAIR/F_Pinouts.html

Also useful is http://www.pinouts.ru/

Here's the PCI Spec I DID find...

Google Groups Link

              The PCI (Peripheral Component Interconnect) Bus

This file is not intended to be a thorough coverage of the PCI standard.
It is for informational purposes only, and is intended to give designers
and hobbyists an overview of the bus so that they might be able to design
their own PCI cards. Thus, I/O operations are explained in the most
detail, while memory operations, which will usually not be dealt with
by an I/O card, are only briefly explained. Hobbyists are also warned
that, due to the higher clock speeds involved, PCI cards are more
difficult to design than ISA cards or cards for other slower busses.
Many companies are now making PCI prototyping cards, and, for those
fortunate enough to have access to FPGA programmers, companies like
Xilinx are offering PCI compliant designs which you can use as a starting
point for your own projects.

For a copy of the full PCI standard, contact:

     PCI Special Interest Group (SIG)
     PO Box 14070
     Portland, OR 97214
     1-800-433-5177
     1-503-797-4207

     There is also a spec for CompactPCI, which uses the same timing
and signals, but uses a eurocard connector and format. This is not
presently covered in any detail within this document.


Pinout (5 volt and 3.3 volt boards)

 
               -12V     01      *TRST
                TCK             +12V
                GND             TMS
                TDO             TDI
                +5V             +5V
                +5V             *INTA
              *INTB             *INTC
              *INTD             +5V
            *PRSNT1             reserved
           reserved     10      +I/O V (+5 or +3.3) 
            *PRSNT2             reserved
                GND   Key3.3    GND
                GND   Key3.3    GND
           reserved             reserved
                GND             *RST
                CLK             +I/O V (+5 or +3.3)
                GND             *GNT
                REQ             GND
+I/O V (+5 or +3.3)     20      reserved
               AD31             AD30
               AD29             +3.3V
                GND             AD28
               AD27             AD26
               AD25             GND
              +3.3V             AD24
              C/BE3             IDSEL
               AD23             +3.3V     
                GND             AD22      
               AD21             AD20
               AD19     30      GND
              +3.3V             AD18  
               AD17             AD16
              C/BE2             +3.3V
                GND             *FRAME
              *IRDY             GND
              +3.3V             *TRDY
            *DEVSEL             GND
                GND             *STOP
              *LOCK             +3.3V
              *PERR     40      SDONE
              +3.3V             *SBO
              *SERR             GND
              +3.3V             PAR
              C/BE1             AD15
               AD14             +3.3V
                GND             AD13
               AD12             AD11
               AD10     49      AD9
                GND    Key5     GND
                GND    Key5     GND
                AD8     52      C/BE0
                AD7             +3.3V
              +3.3V             AD6
                AD5             AD4
                AD3             GND
                GND             AD2
+I/O V (+5 or +3.3)             +I/O V (+5 or +3.3) 
             *ACK64     60      *REQ64
                +5V             +5V
                +5V     62      +5V
             
             (64 Bit Bus Extension Only)
           reserved     63      GND      
                GND             C/BE7
              C/BE6             C/BE5
              C/BE4             +I/O V (+5 or +3.3)
                GND             PAR64
               AD63             AD62
               AD61             GND
+I/O V (+5 or +3.3)     70      AD60
               AD59             AD58
               AD57             GND
                GND             AD56
               AD55             AD54
               AD53             +I/O V (+5 or +3.3)
                GND             AD52
               AD51             AD50
               AD49             GND
+I/O V (+5 or +3.3)             AD48   
               AD47     80      AD46
               AD45             GND
                GND             AD44
               AD43             AD42
               AD41             +I/O V (+5 or +3.3)
                GND             AD40
               AD39             AD38
               AD37             GND
+I/O V (+5 or +3.3)             AD36   
               AD35             AD34
               AD33     90      GND
           reserved             reserved
           reserved             GND
                GND     94      reserved


* - Active Low


PCI slots are keyed so that a 3.3 volt card cannot be plugged into a 5
        volt slot, and a 5.5 volt card cannot be plugged into a 3 volt
        card. Dual voltage cards are possible.
Key3.3 - At this location, a key is present on 3.3 volt boards. On 5 volt
        boards, these pins are GND.
Key5 - At this location, a key is present on 5 volt boards. On 3.3 volt 
        boards, these pins are GND.

Signal Descriptions:

AD(x): Address/Data Lines.
CLK: Clock. 33 MHz maximum.
C/BE(x): Command, Byte Enable.
FRAME: Used to indicate whether the cycle is an address phase or
     or a data phase.
DEVSEL: Device Select.
IDSEL: Initialization Device Select
INT(x): Interrupt
IRDY: Initiator Ready
LOCK: Used to manage resource locks on the PCI bus.
REQ: Request. Requests a PCI transfer.
GNT: Grant. indicates that permission to use PCI is granted.
PAR: Parity. Used for AD0-31 and C/BE0-3.
PERR: Parity Error.
RST: Reset.
SBO: Snoop Backoff.
SDONE: Snoop Done.
SERR: System Error. Indicates an address parity error for special cycles
        or a system error.
STOP: Asserted by Target. Requests the master to stop the current transfer 
        cycle.
TCK: Test Clock
TDI: Test Data Input
TDO: Test Data Output
TMS: Test Mode Select
TRDY: Target Ready
TRST: Test Logic Reset


The PCI bus treats all transfers as a burst operation. Each cycle begins
with an address phase followed by one or more data phases. Data phases
may repeat indefinately, but are limited by a timer that defines the
maximum amount of time that the PCI device may control the bus. This
timer is set by the CPU as part of the configuration space. Each device
has its own timer (see the Latency Timer in the configuration space).

The same lines are used for address and data. The command lines are also
used for byte enable lines. This is done to reduce the overall number
of pins on the PCI connector.

The Command lines (C/BE3 to C/BE0) indicate the type of bus transfer during
the address phase.

C/BE    Command Type
0000    Interrupt Acknowledge
0001    Special Cycle
0010    I/O Read
0011    I/O Write
0100    reserved
0101    reserved
0110    Memory Read
0111    Memory Write
1000    reserved
1001    reserved
1010    Configuration Read
1011    Configuration Write
1100    Multiple Memory Read
1101    Dual Address Cycle
1110    Memory-Read Line
1111    Memory Write and Invalidate


The three basic types of transfers are I/O, Memory, and Configuration.


PCI timing diagrams:


            ___     ___     ___     ___     ___     ___    
CLK     ___|   |___|   |___|   |___|   |___|   |___|   |___

        _______                                   _________
FRAME          |_________________________________|

                ______  _______  ______  ______  ______
AD      -------<______><_______><______><______><______>---
                Address  Data1    Data2   Data3   Data4

                ______  _______________________________
C/BE    -------<______><_______________________________>---
                Command   Byte Enable Signals

         ____________                                   ___
IRDY                 |_________________________________|

         _____________                                  ___
TRDY                  |________________________________|

         ______________                                 ___
DEVSEL                 |_______________________________|


PCI transfer cycle, 4 data phases, no wait states.
Data is transferred on the rising edge of CLK.


                         [1]              [2]        [3]
            ___     ___     ___     ___     ___     ___     ___     ___
CLK     ___|   |___|   |___|   |___|   |___|   |___|   |___|   |___|   |__

        _______                                                  _________
FRAME          |________________________________________________|

                                   A               B               C
                ______           ______________  ______  _____________
AD      -------<______>---------<______________><______><_____________>---
                Address           Data1           Data2   Data3

                ______  ______________________________________________
C/BE    -------<______><______________________________________________>---
                Command   Byte Enable Signals

                                                         Wait
         ____________                                    _____         ___
IRDY                 |__________________________________|     |_______|

                        Wait            Wait
         ______________________         ______                         ___
TRDY                           |_______|      |_______________________|

         ______________                                                ___
DEVSEL                 |______________________________________________|


PCI transfer cycle, with wait states.
Data is transferred on the rising edge of CLK at points labled A, B, and C.



Bus Cycles:


Interrupt Acknowledge (0000)

        The interrupt controller automatically recognizes and reacts to
the INTA (interrupt acknowledge) command. In the data phase, it transfers
the interrupt vector to the AD lines.


Special Cycle (0001)

        AD15-AD0
        0x0000                  Processor Shutdown
        0x0001                  Processor Halt
        0x0002                  x86 Specific Code
        0x0003 to 0xFFFF        Reserved


I/O Read (0010) and I/O Write (0011)

        Input/Output device read or write operation. The AD lines contain
a byte address (AD0 and AD1 must be decoded).
PCI I/O ports may be 8 or 16 bits.
PCI allows 32 bits of address space. On IBM compatible machines, the
Intel CPU is limited to 16 bits of I/O space, which is further limited
by some ISA cards that may also be installed in the machine (many ISA
cards only decode the lower 10 bits of address space, and thus mirror
themselves throughout the 16 bit I/O space). This limit assumes that the
machine supports ISA or EISA slots in addition to PCI slots.
        The PCI configuration space may also be accessed through I/O
ports 0x0CF8 (Address) and 0x0CFC (Data). The address port must be
written first.


Memory Read (0110) and Memory Write (0111)

        A read or write to the system memory space. The AD lines contain
a doubleword address. AD0 and AD1 do not need to be decoded. The Byte
Enable lines (C/BE) indicate which bytes are valid.


Configuration Read (1010) and Configuration Write (1011)

        A read or write to the PCI device configuration space, which is
256 bytes in length. It is accessed in doubleword units.
AD0 and AD1 contain 0, AD2-7 contain the doubleword address, AD8-10
are used for selecting the addressed unit a the malfunction unit,
and the remaining AD lines are not used.

Address     Bit 32      16   15           0

00          Unit ID        | Manufacturer ID
04          Status         | Command
08          Class Code               | Revision
0C          BIST  | Header | Latency | CLS
10-24            Base Address Register
28          Reserved
2C          Reserved
30          Expansion ROM Base Address
34          Reserved
38          Reserved
3C          MaxLat|MnGNT   | INT-pin | INT-line
40-FF       available for PCI unit


Multiple Memory Read (1100)

This is an extension of the memory read bus cycle. It is used to read large
blocks of memory without caching, which is beneficial for long sequential
memory accesses.


Dual Address Cycle (1101)

        Two address cycles are necessary when a 64 bit address is used,
but only a 32 bit physical address exists. The least significant portion
of the address is placed on the AD lines first, followed by the most
significant 32 bits. The second address cycle also contains the command
for the type of transfer (I/O, Memory, etc). The PCI bus supports a 64 bit
I/O address space, although this is not available on Intel based PCs due
to limitations of the CPU.

Memory-Read Line (1110)

        This cycle is used to read in more than two 32 bit data blocks,
typically up to the end of a cache line. It is more effecient than
normal memory read bursts for a long series of sequential memory accesses.

Memory Write and Invalidate (1111)

        This indicates that a minimum of one cache line is to be transferred.
This allows main memory to be updated, saving a cache write-back cycle.


Bus Arbitration:

This section is under construction.

PCI Bios:

This section is under construction.

t


(C) Copyright 1996 by Mark Sokos. This file may be freely copied and
distributed, provided that no fee is charged.

This information is provided "as-is". While I try to insure that the
information is accurate, errors and typos may exist. Send corrections
and comments to [email protected]. The latest version of this file
may be found at http://www.gl.umbc.edu/~msokos1


References:

"Inside the PCI Local Bus" by Guy W. Kendall
Byte, February 1994  v 19 p. 177-180

"The Indispensible PC Hardware Book" by Hans-Peter Messmer
ISBN 0-201-8769-3

USS Anne Arundel

I'm living in Anne Arundel County and was looking up a law when I stumbled on this…

USS Anne Arundel - saw time in WWII both in the Atlantic (D-Day Troop Transport) and the Pacific…

Looks like an OCR scan that needs some proof-reading…

http://www.multied.com/navy/Transport/AnneArundel.html

Seems like a cool site otherwise.

(Ed note - since then, I have created a Wikipedia article.)

mp3Tag RULES!

Let me just say this thing rocks… I need to clean up my MP3 tags because of my new iPod… I was doing a lot of manipulating with Perl, but this is so much easier. It runs under windows, but does handle most Perl REs…

http://www.mp3tag.de/en/index.html

Anyway, I highly recommend adding these two new "Actions" I wrote:

  1. Remove "/N" from "n/N" track numbers
    Replace with regular expression
    Field: TRACK
    Regular expression: (\d+)/\d+
    Replace matches with: $1
    
  2. Force track numbers to be 2 digits. (You can do this in file renaming with '$num("%track%",2)' but I cannot find another quick way to fix the TAG)
    Replace with regular expression
    Field: TRACK
    Regular expression: ^(\d)$
    Replace matches with: 0$1
    

These two actions can be applied together in the order listed.

Weird DNS Problem - reinstall TCP/IP on WinXP

Problem: URLs don't properly translate.

First, I go to:

www.google.com/

(It's the home page)

Then, since it is a new machine, I do Tools→Windows Update. The link should be:

www.microsoft.com/somethingsomething/redir?sadjkajsdljl.yougetit

What comes out:

404 Error from Google - just like this (http://www.google.com/somethingsomething/redir?sadjkajsdljl.yougetit) with the URL trying to go to google not Microsoft, as if the DNS lookup returned the wrong IP.

At one point, I got windowsupdate.microsoft.com to come up, but it kept looping and would show the main microsoft.com web page (but all the graphics were broken icons).

That pretty much sums it up. I have no ideas except (1) try to reinstall the TCP/IP stack (which is tough on WinXP) and (2) just wipe the damned machine and try again since it is new anyway.

Oh yeah, lastly, I removed all the network devices and reinstalled them from scratch, so there's no stupid 'Network Bridge" stuff.


Solution:

netsh int ip reset c:\resetlog.txt


Full discussion:

http://fatwallet.com/forums/messageview.cfm?catid=28&threadid=297239


Addendum 2007-12-12

A friend of mine had a similar problem recently, when Norton Antivirus decided that his Cybersitter was a virus and hosed the TCP stack. For that, the command was the very similar:

netsh winsock reset

It looks like there are quite a few interesting commands in there.

netsh winsock ?
netsh int ?
netsh int ip ?
netsh int ipv6 ?
netsh int ipv6 isatap ?
netsh int ip dump

Circuit City Manufacturer Rebate Escalation Line

1-800-241-1343 or ccrebatehelp@…

"We apologize if you are having trouble with your manufacturer rebates, and we are here to help you. Monday-Friday 10:00am-6:30pm EST

Please have your Circuit City sales receipt or manufacturer's rebate form available when you call us so that we can solve your problem as quickly as possible."

Makefile notes

Checking tabs:
cat -v -t -e makefile

Macro substitution:
SRCS = defs.c redraw.c calc.c
...
ls ${SRCS:.c=.o}
result: calc.o defs.o redraw.o
Second string can be nothing too to truncate

Suffix Rule: default begavior for a suffix:
.SUFFIXES : .o .c .s

.c.o :
$(CC) $(CFLAGS) -c $<
.s.o :
$(AS) $(ASFLAGS) -o $@ $<

$< is what triggered (only valid in suffixes)

Forcing rebuilds:
all :
make enter testex "CFLAGS=${CFLAGS}" "FRC=${FRC}"

enter : ${FRC}
make ${ENTER_OBJS} "CFLAGS=${CFLAGS}" "FRC=${FRC}"
${CC} -o $@ ${ENTER_OBJS} ${LIBRARIES}

testex : ${FRC}
make ${TESTEX_OBJS} "CFLAGS=${CFLAGS}" "FRC=${FRC}"
${CC} -o $@ ${TESTEX_OBJS} ${LIBRARIES}

force_rebuild:
[nothing here]

Then normal "make all" does normal. "make all FRC=force_rebuild" will do all

Debugging make files:
Try "make -d"

Misc notes:
A line starting with a hyphen ignores errors resulting from execution of that command

Macros:
$? = List of prereqs that have changed
$@ = Name of current target, except for libraries, which it is the lib name
$$@ = Name of current target if used AFER colon in dependency lines
$< = Name of current prereq only in suffix rules.
$* = The name (no suffix) of the current prereq that is newer. Only for suffixes.
$% = The name of the corresponding .o file when the current target is a library
Macro Mods: (not all makes support)
D = directory of any internal mac, ex: ${@D}
F = File portion of any internal except $?

Special Tagets:
.DEFAULT : Executed if make cannot find any descriptions or suffix rules to build.
.IGNORE : Ignore error codes, same as -i option.
.PRECIOUS : Files for this target are NOT removed if make is aborted.
.SILENT : Execute commands but do not echo, same as -s option.
.SUFFIXES : See above. 

Don't Plug a 10/100 Switch Into Your Phone!

Bad things happen.

I have a patch panel for structured wiring in my house. Took me a ½ hour to figure out why all my phones were dead - I had plugged the hub into the phone system! Oopsie!

Mom's Apple Pie Recipe

Mmm Mmm Good…

2 lb Cortlands
¾ cup sugar
¼ cup flour
1 tsp. cinnamon
dash nutmeg
2 tbsp butter/marg
lemon juice
Pillsbury 9" Pie Crust

Peel/Cut Apples. Generous amount of lemon juice after first and every few - coating to prevent oxidation.

Mix with sugar, flour, nutmeg, cinn. in bowl.

Pour into crust

Dot with butter (~pat each quarter and center)

Put on top crust, seal well, vent w/ knife

40 minutes at 450F (preheated) - Golden Brown, slight bubbling from vents

Wayne's Windows Administrator Support

smtproutes.pl

Many (stupid) mail servers are now assuming all cable modem users are SPAMmers, so more and more are refusing to accept my mail. Here's a script that I run to regenerate QMail's 'smtproutes' whenever I need to add new ISPs… Start:

#!/usr/bin/perl

open OUTFILE, ">smtproutes";

$s = ":smtp.comcast.net\n"; # Replace with your ISP's outbound server

foreach (<DATA>) {
chomp;
next if /^\w*$/;
next if /#/;
print OUTFILE "$_$s.$_$s";
}

__DATA__
aol.com
pipeline.com
earthlink.net
comcast.net
ix.netcom.com
netcom.com
hut.fi
t-3.cc
earthengineering.com
usa.com
#CS is old compuserv, now AOL
cs.com
stanfordalumni.org
erasableinc.org
sbcglobal.net
hp.com
abs.net
juno.com
sourcenw.com
yahoogroups.com
msn.com

Mozilla Must-Haves

Traceroute Sites

Using bBlog on your own server.

The installation program asks for your MySQL database name and password. I couldn't get the to work by myself, because I run my own so no admin just handed me the info. If you're in the same boat, here's all you need to do:

/usr/local/mysql/bin/mysql -p

Enter password: mypassword

mysql> CREATE database blog;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX
    -> ON blog.*
    -> TO blog@localhost
    -> IDENTIFIED BY 'myblogpassword';

Obviously, change the stuff in bold. Then in bBlog's setup use the user and database name of 'blog' with the password set above.

How to delete a file already in use by Windows

***** PROBLEM *****

How to delete a file already in use by Windows?

~~~~~ SOLUTION ~~~~~

1. Create the file:

\WINDOWS\WININIT.INI

2. Add the following 2 lines:

[Rename]
nul=C:\SHORTPATHNAME\SHORTFILENAME.EXT

You will need the DOS short name, not the Windows' long name.

3. Save > Restart Windows

The file will be deleted when you restart.

All the GNU utils you can shake a CLI at for Windows

Has Mozilla stopped downloading?

Erase compreg.dat from Mozilla directory. It'll get rebuilt automagically.

ipchains to iptables quickie

(This is an old email I found I had written for some of my friends. No support provided, sorry.)

Here's my mini write-up for people to lazy too read the HOWTOs. ;)
See also: http://netfilter.kernelnotes.org/unreliable-guides/index.html

The attached file goes in your startup stuff.
In-line comments for ya to understand this stuff, I hope... bold stuff isn't in the real file. If you have any Q's lemme know. LEARN BY DOING. ;)
<lotsa snips in here>
Do a "iptables --help" to see the quick commands of P, F, N, I, A, X, and D...
                # Set policies
                ./iptables -P INPUT ACCEPTI allow anything not specifically blocked thru the firewall... oh well.
                ./iptables -P FORWARD ACCEPTJeff claims to block everything he doesn't accept, and then accepts
                ./iptables -P OUTPUT ACCEPT1024 and above.... 6 of one, 1/2 dozen the other ;)
                # User defined tables
                # Shared by INPUT and FORWARD
                  ./iptables -N Protect"N" means new chain creation. But in case we run this multiple times....
                  ./iptables -F Protect"F" flushes the chain if it already existed
                #
                # Now set up the INPUT chain  There are three default chains - INPUT, FORWARD, OUTPUT.
*** UNLIKE 2.2/IPCHAINS the INPUT and OUTPUT chains are only if the packet is destined for the firewall. FORWARD means the packet is gonna be FORWARDed (duh). ***
                #
                  ./iptables -A INPUT -j Protect                         # Spoofs, etcEverything coming IN goes thru Protect
                  ./iptables -A INPUT -p tcp --dport 20:21 -j In_FTP     # FTP inTCP w/ destination ports 20-21 go thru In_FTP
                  ./iptables -A INPUT -p tcp -j In_Mail                  # Mail in (port can be 25 or 110)ANY TCP packet goes to In_Mail
                  ./iptables -A INPUT -p udp --dport 123 -j In_TimeSrv   # Time ServersUDP with port 123 destination goes
                  ./iptables -A INPUT -j In_New     # Any new extIF connections not specified above are blocked (telnet, ssh, etc)All check
                #
                # The FORWARD chain
                #
                  ./iptables -A FORWARD -j Protect                       # Spoofs, etcEverything FORWARDED goes thru Protect also
(this is why Protect is separate from others)
                #
                # The Protect chains
                #
                  ./iptables -A Protect -j Protect_HackersAll go here...
                  ./iptables -A Protect -i $extIF -p udp --sport 53 -j Protect_DNSuUDP source port 53 coming IN ppp+ (any ppp)
Bill would put eth2 or whatever cable modem set to

*** UNLIKE 2.2/ipchains *** -i means INPUT interface NOT 'INTERFACE'. -o means OUTPUT interface now. -i can only match INPUT and FORWARD chains, -o can only match in OUTPUT chains...
                  ./iptables -A Protect -p icmp -j Protect_ICMPICMP packets go to Protect_ICMP
                  #
These next ones get complicated. "-d" is DESTINATION IP. "-m limit" limits the number of matches of a rule. Check the HOWTO for more info. That stops it to one log entry per second. The "--log-prefix" is required for fireparse 2.0. The "Hackers" part tells me what chain matched, and the ":1" says what rule number matched. **NOTE** that you need TWO rules to LOG and then do something!!! (I am not happy with that) Oh yeah the a= part is for fireparse too... tells what its action was.
                  ./iptables -A Protect_Hackers -d 204.116.1.232 -m limit --limit 1/s -j LOG --log-prefix "fp=Hackers:1 a=DROP "
                  ./iptables -A Protect_Hackers -d 204.116.1.232 -j DROPDROP the packet (vs. ACCEPT, REJECT, LOG, RETURN)
[RETURN = Fall off the end of the chain. New to 2.4/IPTables. YAY!!!]
                  ./iptables -A Protect_Hackers -s 204.116.1.232 -j DROP-s is source IP
This next line is just a little combo adding the input interface
                  ./iptables -A Protect_Spoofs -s 192.168.0.0/255.255.0.0 -i $extIF -m limit --limit 1/s -j LOG --log-prefix "fp=Spoofs:3 a=DROP "
                  ./iptables -A Protect_Spoofs -s 192.168.0.0/255.255.0.0 -i $extIF -j DROP
NOTE this next line! The new system combines NAT and packet filtering - by time the filter sees the packet, it HAS ALREADY BEEN MASQ'D BACK - meaning the destination can EASILY be the internal address of your other machines!!!
                  # Destination of 192.168.x.x is NOT a spoof because packet filter sees MASQ answers coming back with that!
Just showing that you can do subnetting on the matches (some above too):
                  ./iptables -A Protect_DNSu -s 151.196.0.38/255.255.255.254 -j ACCEPT
This line logs that DNS came thru that didn't come from my "normal" DNS sources. Note there is no related action, so it falls off the end of the chain and back to where it started (in the INPUT or FORWARD chain)
                  ./iptables -A Protect_DNSu -m limit --limit 1/s -j LOG --log-prefix "fp=DNS:1 a=ACCEPT "
Just like TCP/UDP have ports, ICMP has types.... numeric or words:
                  ./iptables -A Protect_ICMP -p icmp --icmp-type 5 -i $extIF -m limit --limit 1/s -j LOG --log-prefix "fp=ICMP:1 a=DROP "
                  ./iptables -A Protect_ICMP -p icmp --icmp-type 5 -i $extIF -j DROP
                  ./iptables -A Protect_ICMP -p icmp --icmp-type echo-request -m limit --limit 2/s -j ACCEPT # Stop ping floods
                  ./iptables -A Protect_ICMP -p icmp --icmp-type echo-request -m limit --limit 1/s -j LOG --log-prefix "fp=ICMP:2 a=DROP "
                  ./iptables -A Protect_ICMP -p icmp --icmp-type echo-request -j DROP
These are for future use (I may open FTP some day)... states can be NEW, INVALID, RELATED, CONNECTED. This stops any NEW or bad connections (note I don't waste processor time checking the protocol or port since that was already done to get here!!!) Note that FTPs from my internal network will be let thru:
                  ./iptables -A In_FTP -i $extIF -m state --state NEW,INVALID -m limit --limit 1/s -j LOG --log-prefix "fp=In_FTP:1 a=DROP "
                  ./iptables -A In_FTP -i $extIF -m state --state NEW,INVALID -j DROP
Some day I may do POP3 (port 110) so I have my 'mail' rule handle 25 and 110:
                  ./iptables -A In_Mail -p tcp --dport 25 -i $extIF -j ACCEPT
                  ./iptables -A In_Mail -p tcp --dport 110 -i $extIF -m limit --limit 1/s -j LOG --log-prefix "fp=In_Mail:1 a=DROP "
                  ./iptables -A In_Mail -p tcp --dport 110 -i $extIF -j DROP
This stops any NEW connections from ppp+ to ports 0 to 1023 (the classical Unix "reserved" ports) - combo of state, limit, LOG:
                  ./iptables -A In_New -i $extIF -p tcp --dport 0:1023 -m state --state NEW,INVALID -m limit --limit 1/s -j LOG --log-prefix "fp=In_New:1 a=DROP "
                  ./iptables -A In_New -i $extIF -p tcp --dport 0:1023 -m state --state NEW,INVALID -j DROP


Now comes Part II - NAT:
                # Just masq everything outbound
IPTables is extensible. One extension is NAT - "-t nat" says to load the NAT table. It must be FIRST on the line. For NAT, there are a few internal chains, the most important being PREROUTING and POSTROUTING (entering and leaving the machine). MASQUERADE means SNAT - Source Network Address Translation - what we want to do to hide a network behind a single IP for outbound data. Note the use of "-o" vs. the "-i" above. iptables actually has primitive load balancing for both SNAT and DNAT...
                ./iptables -t nat -A POSTROUTING -o $extIF -j MASQUERADE
                # Set some hooks for the port forwarding scripts
                ./iptables -t nat -N PortFW
Seems odd, but I made a chain called PortFW. That way my firewall setup scripts can just wipe it without worrying about other things that may be in the PREROUTING chain.
                ./iptables -t nat -A PREROUTING -i $extIF -j PortFW
The "PortFW" chain is "DNAT" - Destination NAT - we hide from the internet the DESTINATION of the packet. AKA "Port Forwarding" in its simplest form. Again, this also allows load balancing if we wanted to run web server clusters. I will give you those other scripts some other time.
                echo 1 > /proc/sys/net/ipv4/ip_forwardTurns on the kernel packet forwarding
                echo "."
        # Make sure we get called to stop later
        touch /var/lock/subsys/packetfilterThe shutdown script ("/etc/rc.d/rc" sees this file and tells us to "stop")

Unix commands you shouldn't do at 3 AM....

…well, ever.

rm -rf .*

rpm -qa | xargs rpm --erase

I've done them both and felt the pain. I did the first on a 2TB machine. In 1996, when 2TB was a lot more impressive.

Right click hanging horribly?

Other symptoms included moving any file to the trash, even with 'delete' button and no context menu used.

Re-enable PGPsdkService

This took me about 6 months to track down!!!

Ghost and error 19922 SOLVED

The Symantec 'knowledge base' has this this useless link.

The 'solution' is "Symantec is investigating this problem to determine a resolution. This document will be updated when new information or a solution is available." - They have said this since at least version 6 - search their site and see at least 4 different Ghost versions saying that they are looking into it!

My situation, and fix, hope it works for you… NAV Pro 2K4 had crashed a few days before (it only happened that once) and I never shut off my desktop. Well, what was happening was the dump file was spanning at the 2GB mark. NAV has hooks in the OS that do RPC calls when the file is closed, telling NAV to scan it. Since NAV wasn't running, the RPC call was timing out. By time the RPC call failed, the Ghost client had given up the ghost (ha!) failing with error 19922.

A simple reboot fixed it, but it still took me about 3 hours of being very worried to fix, because I had made a major change to my network since the last backup…

Strange Compression Comparisons

Well, if you're desparate to do bzip2 under windows, or pretty much any other cool GNU thing (find, grep, less, wget, etc) you can download them at http://gnuwin32.sourceforge.net/packages.html

C:\Documents and Settings\me>bzip2 —version bzip2, a block-sorting file compressor. Version 1.0.1, 23-June-2000.

  • adm
    Aaron D. Marasco wrote:
    
    > OK, a quick test. I just got a PowerPoint presentation. I am not going to mess with dictionary sizes or anything, leaving those default.
    >
    > PPT: 1,440,768 bytes (Original file)
    > ZIP: 1,311,093 (Dunno what did it, I received it this way)
    > RAR: 1,303,276 (RAR 3.20 beta 4, which does the 'new' RAR compression, default setting)
    > RAR: 1,303,241 (Same version, told it MAX compress "m5" command line)
    > ACE: 1,305,286 (2.0 compression, normal)
    > ACE: 1,309,770 (1.0 compression, normal)
    > ACE: 1,305,274 (2.0 compression, max)
    > GZ: 1,311,109 (Created by WinACE 2.5 max compression)
    > LZH: 1,440,901 (Created by WinACE 2.5 max compression) (-- this is BIGGER. This surprises me and tells me that PPT may already be compressed?
    > .TAR.GZ: 1,311,614 (Created by WinACE 2.5 max compression)
    > CAB: 1,304,092 (Created by WinACE 2.5 max compression)
    > ZIP: 1,310,299 (Created by WinACE 2.5 max compression)
    > JAR: 1,310,299 (Created by WinACE 2.5 max compression -- I think .JAR are just renamed .ZIP anyway)
    > BZ2: 1,337,976 (bzip2 Version 1.0.2 - I couldn't see a command line to change compression)
    > GZ: 1,310,209 (gzip -9 gzip 1.3 [1999-12-21]) (-- I've never seen GZIP be smaller than BZ2?!?!?
    >
    > And now sorted:
    > [root@neuvreidaghey shared]# sort -t' ' +1 tempo
    > RAR: 1,303,241 (Same version, told it MAX compress "m5" command line)
    > RAR: 1,303,276 (RAR 3.20 beta 4, which does the 'new' RAR compression, default setting)
    > CAB: 1,304,092 (Created by WinACE 2.5 max compression)
    > ACE: 1,305,274 (2.0 compression, max)
    > ACE: 1,305,286 (2.0 compression, normal)
    > ACE: 1,309,770 (1.0 compression, normal)
    > GZ: 1,310,209 (gzip -9 gzip 1.3 [1999-12-21]) (-- I've never seen GZIP be smaller than BZ2?!?!?
    > ZIP: 1,310,299 (Created by WinACE 2.5 max compression)
    > JAR: 1,310,299 (Created by WinACE 2.5 max compression -- I think .JAR are just renamed .ZIP anyway)
    > ZIP: 1,311,093 (Dunno what did it, I received it this way)
    > GZ: 1,311,109 (Created by WinACE 2.5 max compression)
    > .TAR.GZ: 1,311,614 (Created by WinACE 2.5 max compression)
    > BZ2: 1,337,976 (bzip2 Version 1.0.2 - I couldn't see a command line to change compression)
    > PPT: 1,440,768 bytes (Original file)
    > LZH: 1,440,901 (Created by WinACE 2.5 max compression) (-- this is BIGGER. This surprises me and tells me that PPT may already be compressed?
    

I think these are slightly skewed, but RAR just edged out ACE. Again, I think this is a recompression on compressed data. I would doubt that MS-CAB would normally beat ACE. This is not a directory of plaintext. You can even see that ACE can make GZip compat archives, but it was slightly larger than GZip itself. And ACE also made a smaller ZIP file than what I assume was WinZip.

And since I already bought WinACE, it's good enough.

CD-Rs bake in the sun!

OK, I had a silver CD-R (Imation 80min if you care) with MP3s. I left it in the car too much in the sun (now I flip the jewel cases over). One edge of it turned a nice golden color like the older CD-Rs are.

It had 5 CDs on it.

I have randomly sampled the files in my audio player, and they all sound fine and are as happy as can be.

Checked the SFVs of 4 of the 5.

Even though my sampling sounded fine, EVERY SINGLE FILE had a CRC failure.

Weird.

Keep yer CD-Rs in the shade!!!

HP Printers crashing Win98 (and getting VxD versions under Linux)

Kitty says to me today she's having printing problems. About ½ the time, the machine just hangs when she tries to print. I reply with the standard help desk response of "reinstall the print drivers". Oh boy.

Shortly thereafter, not only did the new printer software fail to find the printer, the damned thing would BSOD (Win98) if it was booted WITHOUT the USB printer attached!

Then USB just stopped working for a while. That was cute.

Long story short - after many (many) reboots, including logged boots and many BSODs (and just plain lockups on boot) I finally noticed that even with it all supposedly uninstalled, it still BSODd without the printer attached. I'm talking manual Registry wipes uninstall. It wouldn't lock if I deleted the USB hub from Windows. Until I rebooted again and then BSOD. I found it was still loading a VxD file.

Yes folks, think WAY back. 16 bit. Windows 3.1 - "System.ini"!!! But it wasn't there either. In there is a line that says to load "*.VxD".

So I erased (OK, moved) all the HP*.VxD files in C:\Windows\System\VMM32\ (WTF?) and wow - everything was A-OK when there was no printer attached! I figured that would make a good baseline - if it don't boot without the printer, it will never boot with.

I connected the printer, pointed it to the directory where I had downloaded the drivers, and it installed without a hitch. Even installed the accessory utils automagically.

So I went back to that VMM32 directory. The HP files were back. Copied them all to my fileserver, and ran diff on them. No differences. Except… there was a file "hpziop98.vxd" what wasn't reinstalled. Lo and behold, the old directory had both "hpziop98.vxd" and "hpziop00.vxd". Kinda suspicious, huh?

Here's a Linux command for you to file away:

strings *.vxd | grep -A 20 ProductVersion'''

hpziop00.vxd:
ProductVersion
1, 18, 6, 0
ProductName
Hewlett-Packard 1284 Driver.
OriginalFilename
hpziop00.vxd
LegalCopyright
Copyright
1998. All rights reserved.
InternalName
hpziop00
FileVersion
1, 18, 6, 0
FileDescription
1284 Driver.
CompanyName
Hewlett-Packard Company
Comments
Built on 12/30/99 2:00pm

hpziop98.vxd:
ProductVersion
1, 16, 7, 0
ProductName
Hewlett-Packard 1284 Driver.
OriginalFilename
hpziop00.vxd
LegalCopyright
Copyright
1998. All rights reserved.
InternalName
hpziop00
FileVersion
1, 16, 7, 0
FileDescription
1284 Driver.
CompanyName
Hewlett-Packard Company
Comments
Built on 10/12/99 2:30pm

Yes folks, some time between Oct and Dec 1999, HP renamed their 1284 driver file, and didn't tell the uninstaller (which I ran at least 3 times!) to remove the older version if it saw it! AND, IEEE 1284 is PARALLEL PORT!!! Lastly, you'll note the "OriginalFilename" entry for the __98 file?!?

Fixed. Total time: almost 2.5 HOURS.

binfmt_misc - Teach the Linux kernel to do neat stuff

Stolen from http://www.tat.physik.uni-tuebingen.de/~rguenth/linux/binfmt_misc.html

This is binfmt_misc - the generic 'wrapper'-binary handler!

WARNING: if you use recent kernel versions from Alan Cox (2.4.2acXX and later) or versions 2.4.13 and up you need to mount binfmt_misc using

mount -t binfmt_misc none /proc/sys/fs/binfmt_misc

Please dont ask me for reasons - ask Alexander Viro who did this during the stable series.

Abstract

Binfmt_misc provides the ability to register additional binary formats to the Kernel without compiling an additional module/kernel. Therefore binfmt_misc needs to know magic numbers at the beginning or the filename extension of the binary.

You can get a patch to include binfmt_misc into your Kernel here. There is a patch to 2.0.30, a patch to 2.0.33/34 and a patch to 2.0.35. Binfmt_misc is integrated to Kernel 2.1.43, so there is no need to get a patch for them, just upgrade to the latest (stable ;-)) 2.1.xx Kernel.

Read Documentation/binfmt_misc.txt and Documentation/java.txt for more information on how to use binfmt_misc (or continue reading this page). The 'magic' behind binfmt_misc

binfmt_misc works as follows:

  • it maintains a linked list of structs, that contain a description of a binary format, including a magic with size (or the filename extension), offset and mask, and the interpreter name.
  • on request it invokes the given interpreter with the original program as argument, as binfmt_java and binfmt_em86 and binfmt_mz do.
  • binfmt_misc does not define any default binary-formats, you have to register an additional binary-format via the /proc interface (see below).

The /proc interface of binfmt_misc

You can find the following binfmt_misc related files/directories below /proc/sys/fs/binfmt_misc:

  • register

To register a new binary format do an echo :name:type:offset:magic:mask:interpreter: > register with appropriate name (the name for the /proc-dir entry), offset (defaults to 0, if omitted), magic and mask (which can be omitted, defaults to all 0xff) and last but not least the interpreter that is to be invoked (for example and testing '/bin/echo'). Type can be 'M' for usual magic matching or 'E' for filename extension matching (give extension in place of magic).

  • status

If you do a cat status you will get the current status (enabled/disabled) of binfmt_misc. Change the status by echoing 0 (disables) or 1 (enables) or -1 (caution: clears all previously registered binary formats) to status. I.e. for example echo 0 > status to disable binfmt_misc (temporarily).

  • name (where name is the name you gave to register)

This file does exact the same thing as status except its scope is limited to the actual binary format. By cating this file you also recieve information about the interpreter/magic, etc. of the binfmt.

Example usage of binfmt_misc (emulate binfmt_java):

cd /proc/sys/fs/binfmt_misc
echo ':Java:M::\xca\xfe\xba\xbe::/usr/local/java/bin/javawrapper:' > register
echo ':HTML:E::html::/usr/local/java/bin/appletviewer:' > register
echo ':Applet:M::<!--applet::/usr/local/java/bin/appletviewer:' > register
echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > register

These three lines add support for Java executables and Java applets (like binfmt_java, additionally recognising the .html extension with no need to put '<--applet>' to every applet file). You have to install the JDK amd the shell-script /usr/local/java/bin/javawrapper, too. It works around the brokeness of the Java filename handling. To add a Java binary, just make a link to the .class-file somewhere in the path.

For full featured wrapping of deeply nested class files you will have to use the wrapper script created by Colin Watson (cjw44@…) /usr/local/java/bin/javawrapper and the additionally needed little c-proggy javaclassname.c (just compile it and stick it to /usr/local/java/bin/). These C/Script combination handles nested classes properly by looking up the fq classname from the class file.

Configuration of binfmt_misc ideally takes place in one of your init scripts (see init manual to find out where they resist, usually /etc/rc.d/). This is my personal binfmt_misc configuration script, it gets called in /etc/rc/boot.local .

Geek Reference Site

http://www.ncsu.edu/felder-public/kenny/home.html

I found it doing a quick search for entaglement, etc b/c of some questions I had regarding the book I am reading: http://www.amazon.com/exec/obidos/ASIN/0452284570/aarondmarascoaar/

Emergency reboot with Ctrl-Alt-Delete-Shift

Note: this reboots the machine VERY harshly.

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"EnableQuickReboot"="1"

Wireless Performance Stats

I cannot get this thing to connect with Encryption On using the SMC software, so I cannot turn on/off this 'Nitro' thing…

http://www.stanford.edu/~preese/netspeed/ was used to test. This program ROCKS!!! Server Linux, client WinXP Pro. 30 seconds per test, 8KB window (default) You can see there is a push and a pull test.

Server:
iperf --format K --port 999 -s
Client:
iperf -c neuvreidaghey -r -t 30 -p 999 --format K

802.11g, with encryption on.
------------------------------------------------------------
[ ID] Interval Transfer Bandwidth
[1892] local 192.168.1.169 port 2212 connected with 192.168.1.251 port 999
[1892] 0.0-30.0 sec 56408 KBytes 1880 KBytes/sec
[1868] local 192.168.1.169 port 999 connected with 192.168.1.251 port 32785
[1868] 0.0-30.0 sec 60832 KBytes 2026 KBytes/sec

802.11g, with encryption off.
------------------------------------------------------------
[ ID] Interval Transfer Bandwidth
[1888] local 192.168.1.169 port 2318 connected with 192.168.1.251 port 999
[1888] 0.0-30.0 sec 70120 KBytes 2337 KBytes/sec
[1868] local 192.168.1.169 port 999 connected with 192.168.1.251 port 32787
[1868] 0.0-30.0 sec 81504 KBytes 2716 KBytes/sec

So I am getting 15-21 Mbps of 54 theoretical - THAT SUCKS!!! [27-38% efficiency]

802.11b, encryption off.
------------------------------------------------------------
[ ID] Interval Transfer Bandwidth
[1888] local 192.168.1.169 port 2353 connected with 192.168.1.251 port 999
[1888] 0.0-30.0 sec 14176 KBytes 472 KBytes/sec
[1868] local 192.168.1.169 port 999 connected with 192.168.1.251 port 32788
[1868] 0.0-30.0 sec 12640 KBytes 421 KBytes/sec

So that is 3.3-3.7Mbps of 11 theoretical - guess that G ain't so bad - it IS about 5x faster! [30-34%]

Just for shits, I switched the G router into B/G mixed mode environment… 802.11g (with b compat) [no encryption] [results about same as G only] I tried putting both NICs in the laptop at once, and things just got ugly. Guess with only one laptop I cannot get the B to interfere enough with the G… I will try that NITRO stuff again… maybe tomorrow, maybe this weekend.

Data General UPS Pinout

The DG UPS pinout follows:

             Power
    Pin    Off    On    Signal
    ---    ---------    ------
     1      -     -
     2     +10   -10    Are we online? +10=false, -10=true
     3      -     -
     4      -     -
     5      -     -
     6      -     -
     7      -     -
     8     +-10  +10    Is the battery low? +10=false, -10=true
     9      -     -

Don't load Win98 files onto a Win98SE machine!

Spent 5 hours trying to get Ceci's Win98SE machine to work with a wireless USB thingee. The sad part is that it worked fine for a few minutes right at the beginning… then what? Windows Update killed it!!!

So I try to reinstall the driver. This time I figure that maybe I should have the installer overwrite the files from the Windoze CD since Windows Update screwed them up in the first place.

OK, no more story time. On to the lessons learned. I can almost guarantee that you will get BSODs and all other kinds of fun stuff (eg. Device Manager CRASHING even in Safe Mode!!!) if you pop in a Windows 98 disk when installing drivers and the computer is running windows 98 SE. Oh yeah. *BIG* fun. About 5 hours later it finally hit me that the CD didn't match the OS on the boot screen!!!

Don't put a WD drive in a RAID system

Ghost, ext2 and ext3, convert ext3 -> ext2

  1. Ghost 7 doesn't do ext3. I had a hint of this moving from 30G to 40G but it is now verified. It makes fsck.ext3 core dump. Not a pretty sight. I was very afraid that I lost my firewall forever.
    1. You can fool 'mount' but not 'fsck'. You can do 'mount -t ext2' to mount ext3 as ext2. If you do 'fsck -t ext2' on corrupted ext3, it will still crash knowing it is ext3.
    2. 'tune2fs -O ^has_journal /dev/hda7' will convert an ext3 partition (eg hda7) to ext2. Since Ghost copies ext3 as ext2 (which corrupts the special journal) this is required.

Ghost and ext3

bad = I am about to try to resize an ext3 partition. Ghost hosed that job up so bad that fsck actually SegFault'd!

http://www.gnu.org/software/parted/parted.html

http://www.gnu.org/manual/parted-1.6.1/html_mono/parted.html

Stupid Linux trick - virtual partition

Stupid Linux trick number ###? - Making a virtual partition. Kinda the opposite of what I want to do.

mkdir /home/foo
dd if=/dev/zero of=/home/foo/image bs=1024 count=10240
mkfs.ext3 -F /home/foo/image
mount -t ext3 /home/foo/image /home/foo -o loop
chown foo /home/foo

This creates a 10MB home 'directory' for the user named foo. No way for them to get bigger (well, /tmp but that is beyond the scope of this example).

Pound your hardware much harder than Prime95

Using M$'s official hardware pounder:

http://www.microsoft.com/whdc/hwtest/default.mspx

Get Active Desktop with IE6 on NT4

ie6setup.exe /c:"ie6wzd /e:IE4Shell NTx86 /I:Y"

Car Stereo Installation Stuff

Samba WinXP Pro Mapped Drive Problem

You can see my original ordeal here.

Problem:
I am sure everyone is sick of hearing Samba questions, but this is driving me nuts. I have had a samba share setup for almost two years but I upgraded my desktop to WinXP Pro and it is driving me nuts!

Some background:
Running Samba 2.2.7

I am not doing anything fancy on samba - no PDC or anything. Plain ol' Workgroup. Example section:

[shared]
comment = Shared Files
path = /share/shared
public = yes
writable = yes
write list = me, acekitty
printable = no
force user = me
force group = me

I have this share mapped to my drive S on the WinXP machine. For some reason, the first time I double click in Explorer on the drive (after 'n' minutes of not accessing recently), explorer just hangs for like 2 minutes. Then it comes back like nothing was wrong! No errors on the server side. I have done the "Scheduled Tasks" possible problem fix I have seen many places:

When you connect to another computer, Windows checks for any Scheduled tasks on that computer. This can take up to 30 seconds. Open regedit and browse to key:
HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/Current Version/Explorer/RemoteComputer/NameSpace
Delete the {D6277990-4C6A-11CF-8D87-00AA0060F5BF} sub-key and reboot.

So, are you ready for the weirdest part of this problem? I am also running WinXP Pro on my laptop and it has NEVER had this problem from day 1!?!?

Absolutely any help would be greatly appreciated.

  • RR

Solution:

After tons and tons of research I learned that Samba was NOT the problem!

It was just plain ol' Windows being stupid. First, I found this page: here which I am linking here because if anyone else ever stumbles upon this post it may fix their problem, and it shows some control panel that there seems to be no other way to reach!?!?

Next I found (part of) my solution here.

It seems that the service "WebClient" is what is screwing me over. However… combining these two solutions STILL didn't quite work for me… every time I booted up I had to re-enter my share passwords!

Which brings me to why the problem is so original (IMO). I have only one user on this machine, with no password. So WinXP was automagically booting into that account. To get the mounted share to work, I had to do the following fun:

  1. Run 'control userpasswords2' and wipe all remembered passwords.
  2. Add a password to my WinXP account (whose name has always matched the samba server account).
  3. Use TweakUI to automatic login the user on bootup.
  4. Disable the 'WebClient' service.
  5. Reboot

I tried various permutations, and this was the only one that worked, so all the steps seemed to be required. This does not explain why my laptop has worked fine from day one. They both have the same NetBIOS settings, host files, mapped drives, etc, etc…

Thanx for trying! I now have my M, P, S, and W drives back!

  • RR

Recovery Console

Install the Recovery Console on Your Computer

You can install the Recovery Console as an option on your startup menu and use it to recover your system in the event that safe mode and other startup options do not work. This tool is for advanced users.

  • With Windows XP running, insert your Windows XP CD in the drive, and click Exit when the installation options are displayed.
  • Click Start, click Run, and then type D:\i386\winnt32.exe /cmdcons Where D: is the CD-ROM drive letter, and then press Enter. (There is a space between .exe and the slash.)
  • Follow the instructions on screen to install the Recovery Console, and when the installation is complete, restart your computer. The Recovery Console will show up in the list of available operating systems in the Startup menu. You must be an administrator to use the Recovery Console.

If the i386 directory is already installed on your computer (as might be the case in computers purchased with Windows XP pre-installed), you can use the same syntax as in Step 2, using the [path]\i386 directory without having to use the CD.

An alternative method is to boot to the CD and start WINNT.EXE, then when prompted to Install or Repair, click Repair, which installs the Recovery Console for you.

If Windows XP will not start, you can run the Recovery Console from the Setup CD.

Optimize Swap File Performance

On systems with larger amounts of memory, more than 128Mb, the hard disk based swap file is not needed as much. This tweak optimizes the use of the swap file on such systems.

http://www.winguides.com/registry/display.php/620/

Using notepad open the SYSTEM.INI file in your Windows directory.

Find the [386Enh] section and add a new line reading

ConservativeSwapfileUsage=1

Save the file and restart Windows for the change to take effect.

Registry Settings
Value Name: ConservativeSwapfileUsage
Value Data: 1

Improve Core System Performance

On systems with large amount of RAM this tweak can be enabled to force the core Windows system to be kept in memory and not paged to disk.

http://www.winguides.com/registry/display.php/399/

Registry Settings

System Key: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
Value Name: DisablePagingExecutive
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = default, 1 = disable system paging)

nForce2 Driver Problems (Abit NV7-133R)

I have changed mobos "under" Windows many, MANY times… and THAT is the problem.

This install of Win98 has lasted since early 1999 - including… many, many registry hacks (which I am still putting back in now) mobos / procs:

  • Abit BH6, Celeron overclocked to 550
  • Abit BH6, Celeron overclocked to 850, then 950
  • Abit KG7-Lite, Athlon XP 1600+
  • died on Abit NV7-133R, Athlon XP 1600+

hard drives:

  • 20 GB on the mobo
  • Promise 66 RAID 2x20 + 1x40
  • Promise 66 RAID 2x40 + 1x80
  • Promise 100 RAID 2x40 + 1x80

video cards:

  • no-name PCI plus voodoo2
  • TNT2 (forgot which one, it was only a week)
  • voodoo3 3000
  • geforce3 ti 450 (gainward)

The list doesn't include 2 SCSI cards (ISA, then SCSI), the various CD-Burners (2), ZIP drive, scanners (3), cameras (2), mp3 player, X10 control hardware, and everything else that would bloat the hell out of the registry!

So it finally caught up with me, I am reinstalling Windows right now…

To answer all questions -

  • I will NOT go to XP as my home OS. Maybe in a VMWare window with

Linux watching it very VERY closely. I considered Win2K but found out a game I like ("Alice") doesn't work there… I have also had problems with Ghost on my laptop with Win2K…

  • The tape detection was crashing VCOMM because Windows was looking

for a parallel-port tape drive (my theory)

  • And the kicker, something that people NEED TO BE AWARE OF WITH

THIS MOTHERBOARD - installing the nForce drivers from the nVidia web page KILLED win98. I did an absolutely fresh install, ran it, BOOM no booting, total lockup. In safe mode, I went in and deleted the "new" not working PCI video - I assume the nForce installer pokes something in the registry to tell Windows that the video is there, but the 133R has it disabled, so Windows tries booting and just says "WTF?" - bootlog.txt showed it dying on video init.

Mis-ID'd Hard Drive

Problem: I have an 80GB Maxtor hooked up to the on-board IDE using a nice fancy 80 pin rounded cable. My problem is that when I cold boot, it ID's the hard drive as a "MAXTOR ROMULUS" and then says error with the drive. I hit ctrl-alt-del and it reboots, properly IDs, and boots fine. Any ideas? I have messed with the IDE delay, up to 3 seconds didn't fix it…

Solution: Turns out that drive didn't like to be the 'Slave' without a 'Master'. Never saw that before and I have had Master-less drives before…

Show All Hidden Devices in Device Manager

Devices that are installed but are not currently connected to the computer (such as a Universal Serial Bus (USB) device or "ghosted" devices) are not normally displayed in Device Manager. This tweak causes all devices to be shown.

http://www.winguides.com/registry/display.php/1107/

Registry Settings

System Key: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
Value Name: DEVMGR_SHOW_NONPRESENT_DEVICES
Data Type: REG_SZ (String Value)
Value Data: (1 = show all hidden devices)

UT Server on Laptop Problem

Don't remember how I figured it out… but I remember it took months. If your UT server is playing super crappy on a laptop under WinME (or WinXP), try running SETI@Home or distributed.net's RC5 cracker. It worked for me under both OSs.

How to fix /dev/null if it is broken

mknod /dev/null c 1 3 chmod a+w /dev/null

Mounting a Drive in a Windows 2000 Folder

Mounting a Drive in a Windows 2000 Folder

By Jim Pile

Reader Paul T. asks the following Windows 2000 question:

"I have a small (5.2 GB) drive that I would like to add to my Windows 2000 installation. I would prefer to add the extra 5.2 GB to my existing Drive C. Is there an easy way to do this?" You can assign an NTFS drive to a folder on another NTFS drive. When you do this, the contents of the added drive appear in this new folder. For example, if you add your 5.2 GB drive and assign it to a folder in Drive C named \Extra Data, then you have effectively added the contents of the new drive to your C drive. After you install and format your new drive, right-click My Computer and choose Manage. When the Computer Management dialog box opens, click Disk Management. Now, in the right pane of the dialog box, right-click your new drive and choose 'Change Drive Letter and Path'. If there is already a drive letter assigned, click Remove. Next, click Add. When the Add New Drive Letter or Path dialog box opens, select the 'Mount in this NTFS folder' radio button and click Browse. Click Drive C to select it and then click New Folder. Name the folder and click OK. Back in the Add New Drive Letter or Path dialog box, click OK to close the dialog box and apply your folder selection. Your new drive will now appear in your newly created Drive C folder. You can use the same procedure in Windows XP.

Move MySQL database from one machine to another

I just moved my ENTIRE MySQL database from one machine to another using netcat!

On the original firewall: ./mysqldump -A -a --opt -p | bzip2 | nc -w 3 192.168.1.55 2000

And then on the new virtual one: nc -l -p 2000 | bunzip2 | /usr/local/mysql/bin/mysql -p

So, on the fly compresion and everything!