I will never understand why some people WriteCode.LikeThis(SoMuch, ThatIt, Hurts);

*shivers*

Hmm, rubber banding between C++, Python, and Bourne is an interesting way to pass time, especially when you start wishing for a hybrid.

Wait, ain’t her name Perl?

>_>

You know you’ve been using computers to much when….

All of your mental calculations are off by one, because you keep counting form zero.

You surround long strings of written arithmetic in parentheses, based on the Operator Precedence in ANSI C; and wish the rest of the world did the same.

You habitually use semi-colons and comment symbols in documents, as if they were natural.

You can’t remember the last time you spoke to someone on the phone.

You give people your Instant Messenger, rather then you’re phone number

You can type your login faster then your street address.

Your calculator has it’s own programming language, but you can’t make it count from zero.

When you forget something, you blame it on your brain not “swapping” the data from short-term to longer-term memory in time.

You think people are backwards, if they don’t understand SI

Debating the endianness of various date formats sounds like fun

You have to pause to remember how to write rarely used letters in cursive, because you haven’t written on paper in years.

You’ve named a computer in honour of HAL9000s female counterpart.

Words like grep, parse, regular expression, archive, constant, null, void, port, IP, socket, packet,; are imprinted on your vocabulary. much to your friends annoyance.

You describe the functioning of your brain, as if it was a computer; because you’re not a neuro-specialist.

You would rather use /bin/ed then notepad.exe

You have several command prompts open at all times, even on Windows.

You can tell the difference between explorer.exe and My Computer.

You can’t tell the difference between explorer.exe and your Windows taskbar, system tray, start menu, and the file manager.

You write corrections to the last message, as if invoking SED.

You use single quotes to define literal text.

You use regular expressions in place of long lists of related identifiers.

You think people are gay, if they don’t think the Macbook Pro is sexy.

You write the “show work” for maths questions in pseudo code, showing the algorithm used instead of the numbers.

You know the size of a byte is machine dependent, but never used a machine without an 8bit byte.

You’ve used 8-bit, 16-bit, 32-bit, and 64-bit systems, but wonder what will cause commodity systems to go 128-bit in the future.

You have more e-mail, then you can shake a stick at (after spam)

You haven’t used a real dictionary or encyclopedia in years.

Your desk is a dumping ground for CD-ROM disk jackets, but your home directory is neat as a whistle.

You haven’t seen a razor blade in months, but a program got written on time.

telnet and tcpdump are your favorite solutions to networking problems.

You write about network communications, as if they were PF rule sets.

You keep using -> to dereference “mental pointers” in text.

You write encrypted messages in hexadecimals or octal first, then apply a caesar chiper before encrypting them.

After so many years, that rodent with a long tail on your desk is nick named “the rat”

You use the keyboard for damn near everything, short of opening cans.

$ program folder1/folder2/folder3/filename.ext feels more natural then double clicking my computer, double clicking folder1, double clicking folder2, double clicking folder3, and then finally double clicking filename.ext.

Especially when you can type this as prog/f1/f2/f3/file.ext by using the TAB key completion of your shell, using file managers feel clumsy.

Binary files annoy you, because they can’t be easily read in text editors

You know Integrated Development Environments exist, but have yet to find one better then a UNIX shell, text editor, and development tools.

Proof reading is your favorite way to debug EIDTENT.

You write things like: let foo = [ item1, item2, item3, item 4]; whenever you want to define a list of data in chats.

You meet an attractive woman, and wonder if she is computer literate.

You can use several different styles of operating system interchangeably without problem.

People ask you for something, but don’t tell you how many, and you respond with “enter an integer”.

Your bookshelf is full of Science Fiction, Fantasy, Foo Quck References, and Networking books.

You’ve sent people messages in hexadecimal, more then once.

If you had more money, your bedroom would be like a cave with 50 computers humming.

You remind your dog, that a laptop is not a pillow.

The hum of your file server keeps people awake.

Finding old PC parts is like presents under a Christmas tree

….

Strange behavior with this bit of C++

It has been a long time since I’ve had time to do anything in C++. So I figured it would be a useful way to limber up my memory, by implementing a little bit of my favorite Python classes/modules in C++. The only crazy thing, is the result this code has yielded.

// minimal program, using the code involved
#include
#include

extern "C" {
#include <sys/param.h>
#include <unistd.h>
}

namespace os {
bool link(const std::string& src, const std::string& dst);
}

bool
os::link(const std::string& src, const std::string& dst) {
if (link(src.c_str(), dst.c_str()) != 0) {
std::perror(NULL);
return false;
}
return true;
}

int
main() {
std::cout << "link()t" << std::endl;
os::link(std::string("./test"), std::string("/tmp/test"));
return 0;
}

compilation: /usr/bin/g++ -Wall -ggdb3 os.cpp test.cpp -o test

I compiled on FreeBSD 7 with the systems GCC 4.3.1 and get a segfault, then tried the code on my OpenBSD 4.4 machine. The OpenBSD 4.4 release has shipped with a patched GCC 3.5.3 (propolice) – on OpenBSD it ran perfectly! Trying to feed it through the debuger on FreeBSD wasn’t pretty either:

  • FreeBSD 7, system GCC 4.3.1 -> test program dies with a Segmentation Fault.
  • FreeBSD 7, system GDB 6.1.1 -> Endless stepping when used with a break point, or SIG SEGV in libc’s malloc() when run.
  • OpenBSD 4.4, system GCC 3.5.3 -> prints proper message from std::perror() as expected, when the program is executed.

If I change os::link to os::link_x and recompile on FreeBSD, it works the same as it does on OpenBSD, when unmodified that is. In a few tests on FreeBSD, When I run the program under GCC, it tells me

Program received signal SIGSEGV, Segmentation fault.
0x281fabc3 in malloc () from /lib/libc.so.7

if I set a break point in test.cpp on the os::link() call, and step through it into os::link() in os.cpp. If I keep stepping after the link(), I get returned to the os::link() call in main and can step through it all again. Like an endless loop of stepping into/out of the os::link() function call in test.cpp’s main(), and the if-conditional in os.cpp’s os::link(), geeze.

At least looking at the results I’ve had tonight, I know I’m not freaking nuts… lol. I still shouldn’t write code when I’m half asleep, but hey… It’s the only time I get :, Oh well… unless my family is late as usual, I need to be up in a few hour.

*head hits laptop, snores loudly until morning*

This is so recursive, it hurts

# this is so recursive, it hurts
for topdir in args:
for root, dirs, files in os.walk(topdir):
for file in files:
for regexp in patterns:
if re.search(regexp, file):
file = os.path.join(root, file)
if verbose:
sys.stdout.write("file name: %st" % file)
p = os.stat(file)
a, m, t = (
time.strftime("%Y-%m-%dT%H:%M:%S",
time.gmtime(p.st_atime)),
time.strftime("%Y-%m-%dT%H:%M:%S",
time.gmtime(p.st_mtime)),
time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()), )
sys.stdout.write( "atime: %stmtime: %stnow: %sn" %
(a,m,t))
else:
print file

What a huge, ugly, monster, I’m glad the finished code doesn’t look like that lol.

getting bored

#!/bin/sh
#
# usage: vimbuild [tag]
#
# fetch indicated release tag of vim, compile, and test it.
# Requires the Concurrent Versions System (cvs) or Subversion (svn) client,
# and a suitable make tool.
#
# environment:
#
# $TMPDIR will be used as a staging area if defined, else /tmp is used.
#
# exit status: non zero on failure, zero on success.
#

PATH="/bin:/usr/bin:$PATH"

WORKDIR=${TMPDIR:-/tmp}
VTAG=${1:-vim}
CONFIGURE_ARGS="--enable-perlinterp --enable-pythoninterp --enable-tclinterp --enable-rubyinterp --enable-cscope --enable-fontset --enable-gui=gtk2 --disable-gtktest"

mkdir -p $WORKDIR || exit 1
cd $WORKDIR

# fetch latest vim
if [ -x "`which cvs`" ]; then
echo using cvs
cvs -z3 -d:pserver:anonymous@vim.cvs.sf.net:/cvsroot/vim checkout $VTAG
elif [ -x "`which svn`" ]; then
echo using svn
svn checkout https://vim.svn.sourceforge.net/svnroot/vim/branches/${VTAG}
else
echo 'error, could not find a cvs or svn binary in $PATH!'
exit 1
fi

cd $VTAG
./configure $CONFIGURE_ARGS

#
# set the make command
#
uname | grep -i linux > /dev/null
if [ $? -eq 0 ]; then
NCPU=$(expr `cat /proc/cpuinfo | grep processor | wc -l` * 4)
MAKE="make -j${NCPU}"
else
# assume GNU make is gmake, like on *BSD
if [ ! -x "`which gmake`" ]; then
echo "Warning, GNU make not found!"
echo "This will probably make a GTK gui build fail..."
MAKE=make
else
uname | grep -i bsd > /dev/null
if [ $? ]; then
# check number of cpu via BSD sysctl
NCPU=$(expr `sysctl hw.ncpu | awk '{ print $2 }'` * 4)
MAKE="gmake -j${NCPU}"
else
MAKE=gmake
fi
fi
fi

# now build and test it
$MAKE
if [ -x ./src/vim ]; then
./src/vim --version > /dev/null
if [ $? -eq 0 ]; then
echo "I think the Vi IMproved build was a success"
else
echo "I think the Vi IMproved build was a failure"
echo "Do you wish to test it manually?"
read REP
echo $REP | grep -i y && exec ./src/vim
# NO RETURN on yes
fi
fi

cat << EOF
run: `echo $MAKE | awk '{ print $1 }'` install
as root to finish installing vim
EOF

exit 0

I wonder, if I’ll ever bother to use it lol

Hey, it actually worked lol.

Uploaded it to my server, tweaked the configure args and bingo — freshly updated via

$ vimbuild vim7

$ su – root
# cd /tmp/vim7 && make install

Just for the heck of it, I’ve made the script adapt $CONFIGURE_ARGS based on what it finds installed, hehe.

Ever wonder just what gcc does?

Terry@vectra-$ cat > test.c
#include <stdio.h>

int
main(int argc, char **argv) {

int i;

printf("%s ", argv[0]);
for (i=1; i < argc; ++i) {
if (argv[i][0] != '') {
printf("%s ", argv[i]);
}
}
return printf("n");
}

Terry@vectra-$ gcc -v test.c -o test-bin
Reading specs from /usr/lib/gcc-lib/i386-unknown-openbsd4.3/3.3.5/specs
Configured with:
Thread model: single
gcc version 3.3.5 (propolice)
/usr/lib/gcc-lib/i386-unknown-openbsd4.3/3.3.5/cc1 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=5 test.c -quiet -dumpbase test.c -auxbase test -Wall -W -Wpointer-arith -Wbad-function-cast -std=c99 -version -o /tmp//ccj26536.s
GNU C version 3.3.5 (propolice) (i386-unknown-openbsd4.3)
compiled by GNU C version 3.3.5 (propolice).
GGC heuristics: --param ggc-min-expand=46 --param ggc-min-heapsize=30393
#include "..." search starts here:
#include <...> search starts here:
/usr/include
End of search list.
as -o /tmp//cca26536.o /tmp//ccj26536.s
/usr/lib/gcc-lib/i386-unknown-openbsd4.3/3.3.5/collect2 --eh-frame-hdr -e __start -Bdynamic -dynamic-linker /usr/libexec/ld.so -o test-bin /usr/lib/crt0.o /usr/lib/crtbegin.o -L/usr/lib/gcc-lib/i386-unknown-openbsd4.3/3.3.5 /tmp//cca26536.o -lgcc -lc -lgcc /usr/lib/crtend.o
Terry@vectra-$ ./test-bin arg1 arg2 arg3 arg4 arg5
./test-bin arg1 arg2 arg3 arg4 arg5
Terry@vectra-$

By some odd twist of luck, I didn’t have to work today lol. I guess GOD knew hw much I was dreading it…. But I still ork the way I was raised. When I was growing up, it was a long time before *anyone* was workin’ but I was raised that, work don’t stop until you’re dead; it doesn’t matter if your head is falling off or you feel like death warmed over — you geet off your ass and go into work. That’s the way I was raised, that’s what I expect to have to do, even if I’d rather not lol.

One nice thing, I’ve received a new order, one that opens up quite a lot of possibilities on how I complete it. The jist of it, I had to “fix” the website from using something totally ‘insane’ to something that both works and works as it say it works… A side effect of that, being the sort order of the ranks changed slightly; most notably screwing up the special assignments wing, cadets, and veterans. So what if I’m listed at the tail end of the mighty page? I’ve got a lot more important tasks then what I consider a vanity fix for myself; when I could be doing other things that need doing. Well, my new order basically amount to fixing that, and taking the ol’sledge hammer to thing where necessary.

The code involved I think, is copyrighted from 2002, and I know it’s been hacked by at least 3 different admin team members since 2005. The code is to dependent upon a set of assumptions about the format of the data it manipulates. So there is no simple or quick fix to it, without digging into it. One good side effect, fixing it *properly* also means fixing a few other things in need of fixing, that I ain’t had time for fixing yet lol.

Hmm, maybe Operation Excalibur will happen one of these days just yet… but on a much grander scope then I had originally imagined.

For one reason or another, I seem to end up browsing /usr/src/ whenever I encounter curious program behaviors, I wonder…

Does this mean, that I would be bored stiff without access to the system sources; or do I just spend *to much* time in front of a code editor lol.