http://pastebin.ca/1291353
That has to be within the top 20 longest functions I have ever seen…. but without a doubt, some of the most heavily indented code I have ever seen lol. Like WoW man !
An orange in an apple orchard
http://pastebin.ca/1291353
That has to be within the top 20 longest functions I have ever seen…. but without a doubt, some of the most heavily indented code I have ever seen lol. Like WoW man !
Hooah, I’ve nearly completed my little organizational pattern hehe.
~/stuff -> dumping ground for work load management
-------/bin -> binaries to help out (links to ~/sh)
------------/cgrep -> comma grepper for contacts file
------------/reminded -> reminder notifications daemon
-------/bookmarks -> links to pages I need to read
-------/contacts -> CSV file with why,method,id of people I need to contact
-------/delegates -> list of things I pawned off on other people (and need to follow up with)
-------/open-loops -> list of things I need to do; if it is here, it is a commitment
-------/reminders -> directory full of reminders
-----------------/YYYY-MM-DDTHH:MM -> send me this files contents on YYYY-MM-DD at HH:MM UTC
-------/hope-chest -> things I wish I had time for; deal with in future
-------/school -> reserved for future need
-------/projects -> tmp files for various projects.
On Sunday (2008-12-07), I started writing cgrep in Perl, and setting up the contacts & open-loops files. Finished the final touches yesterday, and finished reminded today (Aside from tweaks needed for WinXP; adjust $ENV vars). Not to bad, considering how little coding time I’ve had lately :
Terry@dixie$ ~/stuff/bin/cgrep -h
/usr/home/Terry/stuff/bin/cgrep -- Grep for the contacts CSV file
Usage:
cgrep [IWhimvw] [-f file | --file file] regex [file ...]
Options:
-I, --id grep the 'id' column
-W, --why grep the "why" column
-V, --verbose display line for AWK
-h, --help print usage help info
-i, --ignore-case ignore case distinctions
-m, --method grep the "method" column
--man read manual page
-v, --invert-match select non-matching items
-w, --who grep the "who" column
Terry@dixie$ ~/stuff/bin/reminded -h
/usr/home/Terry/stuff/bin/reminded -- reminder notifications daemon
Usage:
reminded [-t seconds] [-n|-m addr] [-p program] [-d directory]
Options:
-D, --debug Debugging output
-d, --directory Directory to search
-m, --mail=address Remind by Mail to address
-h, --help print usage help info
-n, --notify Remind by notification popup
--man read manual page
-p, --program=string Execute string as the notifier
-t, --timer=secs Sleep secs between checks
Terry@dixie$
I’ll probably modify ~/init.sh to launch reminded during my sessions; maybe rsync files to Vectra, and run it in mailing mode.
Things in ~/stuff/open-loops are more or less sorted into a queue of tasks; which are to be done in mostly the order listed. Once they are done, they get deleted; and generate or nuke other entries IAW the resulting outcome. So far, it’s actually worked well enough; cgrep, reminded, and the structural are all done ahead of schedule. Now if I could just do something about controlling the amount of time available to work on crap!!! I once tried Personal Information Manager (PIM) software, but usually found the surveyed apps to lack the level of flexibility I need. And to hack it in, would take more time then using a few megs in sticky notes. ssh’ing to Vectra and mucking with a todo file ain’t so hot either, so here we go 🙂 It’s simple, it’s effective (as anything else), and no need to screw around with a big, overwait, memory hogging, overly mouse riddled program, just to manage things -> I can use my shell xD.
It’s amazing, how often I can throw perl at a problem, and see it work lol.
Then again, I can usually read my Perl scripts in six++ months… can’t always say the same for other peoples golf game.
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?
>_>
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
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
….
Use IMAP to access mail = great idea
Deal with IMAP from code = can be headache
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:
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
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.
#!/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.
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-$