Losing the war: On evading lisp

AAGGGGHHH !!!!

Why does Lambda Calculus and Scheme have to be so damn interesting!!!

I need to be kicking myself into a standard tool kit of language+libs+utils, not learning a new one lol. But I have an addiction to learning things :

Slithering around an aging question

Hmm, it seems if I can sort a suitable SQL-interface (beyond the standard issue sqlite3 module) that Python will become my primary language.

It seems, no matter how much I try to circumvent it, Python is the best choice all around : And I’ve tried to knock it down to size lool.

Pythons str and list classes, I actually quite like; although I don’t care much for dict (Pythons associative array class), that might change come Python 3. Most of the stuff built into Python, I like using. The regular expression support, well what can I say… I don’t like any stuck on OOP or procedural interfaces, after having used Perl. The =~, s//, [m]//, and related $symbolic_vars in Perl are just to useful!!!! But Pythons ‘re’ module is good enough for stuff, I guess. Between the built in xml.* and the third-party lxml interface to libxml2, that routes pretty much a snap. I get along well with Pythons IPC offerings about as well as I do with posix’s C offerings. The zlib, gzip, bz2, zipfile, and tarfile modules are enough for the compression/archive formats I may eventually need to operate on. For network related operations, Python provides a lot of stuff plus a familiar sockets interface; I don’t have no problems with sockets programming (although I rarely get a chance to use it in C), I just don’t have time to say, implement FTP! For GUI toolkits, basically offered is TKinter, GTK+, WxWidgets, and Qt. And it looks like GTK+ will probably be my new default kit… The epydoc program also seems to provide the style of documentation I’m used to (Javadoc-style) with good options hehe.

Not to mention the best parts of using Python as my standard language (I and II)

This is how I relax…. lol.

Having taken some time to analyze the mailcap and mime.types files, which map media types to handler programs and file extensions respectively. I’ve decided to implement something, uhh…. more “fun” out of it, for my own usage. I’ll use mailcap and mime.types to setup a suitable mime/file associations to desire, and a mixture of m4 and environment varables to make it more useful hehe. I’ve also setup a small wrapper around Pythons mailcap and mimetypes modules, so I’m happy !

Since I need a handler that includes a web browser, rather then creating an if x is probably running … script, to just use $BROWSER. But since, there is a shitload of apps that don’t understand it, I’ve created quick python script to handle it. Thus, mailcap will execute this script, which will “figure it out”. Once I realized how much I could use such a quickie, I added a little more abstraction to it; making it usable with other variables. And used getopt for a simple interface to it.

#!/usr/bin/env python

import sys, os, getopt

# default values for -e and -s options
envvar = "BROWSER"
envsep = ":"
# skip executing program
noexec = False

# accepted options, usage statement, and manual page
shortopts = "hme:s:n"
longopts = [ 'help', 'man', 'environment=', 'separator=', 'no-exec' ]
def usage():
print """
usage: %s [options] file ...

Parse a field delimited list of programs, executing each in turn, until the
specified application has opened the indicated file(s).

Options:

-h,--help display this useless message
-e,--environment the environment variable to look up, default to BROWSER
-s,--separator the field separator for -e VAR, defaults to :
-m,--man view this manual page
-n,--no-exec do not execute any programs, useful if parsing $PATH

--long-options may be abbreviated.

Exit Status:

The return status of the last executed program handler. If no program was
executed, return with a non-zero exit status.

Caveats:

A non-zero exit status is considered a successful execution.

Programs found by parsing the environment variable, are passed onto the
system shell UNMODIFIED. This is not secure, but it is flexible.
""" % sys.argv[0]
sys.exit(1);


try:
opts, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
except getopt.GetoptError, e:
print(str(e))
usage()

for opt, arg in opts:
if opt in ('-h', '--help'):
usage()
elif opt in ('-m', '--man'):
# XXX works on unix, dos, winnt, osx
os.system("%s -h | $PAGER || more" % sys.argv[0])
sys.exit(0)
elif opt in ('-e', '--environment'):
envvar = arg
elif opt in ('-s', '--separator'):
envsep = arg
elif opt in ('-n', '--no-exec'):
noexec=True
else:
assert False,"unhandled option: %s" % opt

# exec handlers until success, abort, or exit
try:
browser = os.environ[envvar]
apps = browser.split(envsep)
for handler in apps:
# just print it, don't execute it
if noexec:
print handler
continue

ret = os.system(handler)
if not ret == 0:
print("Bad handler -- %s" % (str(handler) % " ".join(args)))

except KeyError:
print("No %s set!!!" % envvar)
sys.exit(1)
except Exception, e:
print("Un-handled exception! -- %s" % e.message)

One of the common questions of a language, is how to parse command line options? I’ve tried several interfaces in differing languages, but I know one thing… The getopt(3) routine in C on unix is awesome for short options. Give something more portable and with (easy) support for long options, and I’ll have a big grin on my face >_>. But if I have to wade through 20 pages of documentation for a comparable OOP-Interface, I’ll be snoring before I get to writing usage().

Scheming flirtations

Trying to wrap my head around Schemes syntax, which is quite a different style of writing then I am used to.

An example at the childs level:

Scheme:

(define x 2)
(define y 5)

(if (> y x)
(display y)
(display x))

; which could also be written as if one wanted to use cond instead
(cond ((> y x) (display y)) ((< y x) (display x)))

C and related languages:

int x = 2;
int y = 5;

if (y > x) {
printf("%d", y);
} else {
printf("%d", x);
}

/* which could also be written on one line as */
if (y > x) printf("%d", y); else printf("%d", x);

I don’t really have a problem with the parenthesesification, but the prefix notation :. Let’s just say, I’ve used infix notation since kindergarten, and internally my brain does too by now lol.

Notational example
prefix + 2 2 –> 4
infix 2 + 2 –> 4
postfix 2 2 + –> 4

Getting my head to live with prefix notation, is the only thing that is pushing my luck, so far that is….

This is how I spend a night off work? I think I really need to get a better life again >_>

the past ~48 hours

Been quite a busy time, I guess lol.

I think I royally fragged my blood sugar; after last nights gorging on beefaroni, I’ve been pissing my brains out (every ~30min). Things are finally starting to resync with the usual input equals output style equation. I’m not diabetic (as far as I know), but many people in my family have had diabetes, most dying of heart attack, stroke, and cancer even when fully healthy. Of course, I’ve always figured it’s a case of which of the 3 will get me first…. But I expect the third, if the first permits in the long term.

I really should watch what I eat, and an extreme amount of pasta and meet is probably a bad idea. As I understand it, carbohydrates from pastas breaks down into glucose slowly over time, slower then a lot of snacks anyway. I’ve no idea whether that is good or bad thing; but I like pasta, in almost all of it’s forms ^_^. Eating a shit load of it on the other hand, is probably just as bad as eating a lot of sugar though :.

My guess is that it caused enough of a glucose spike, that my kidney’s have been workin’ overtime to deal with it. Biology (in general) was never really one of my strong points, in fact… My high school text book put me to sleep lol. The fact that searching the web and thumbing through old encyclopedias was better for passing exams, then remembering the text books contents, is besides the point :-P.

For the time being: I’ve cut the soda from my fluid intake, shit load of HFCS in that stuff… And replaced it with water, I usually drink soda during the day and bottled water at work & at night. Along with sweets, my diet usually consists of lunch, dinner, and a sweet or salty snack or two every few days (although I avoid junk food, because if I had it, I’d eat it).

I managed to download and install Virtual Box. I’ve also got PC-BSD7 in both the 3 CD and 1 DVD sets, the CD ISOs are on my laptop, and the DVD ISO on the desktop (I figured it would be easier to use with VB). When booting off the DVD ISO in VirtualBox, the boot process fails: snap shot. I intend to install it on my desktop, but after one of the posts I read on forums.pcbsd.org (by Graedus I thin), I’m not willing to let PCBSD7 touch my harddrive, until I’ve taken a full backup of my Windows install…. took to many hours to set it up the way I wanted, and I still have no wall paper lmao.

As to the image, I posted a thread on PC-BSDs support forum, not that I actually expect any help lol. In fat, one of the reasons I elected to test with VB first, is in he hopes I might be able to help some of the people having problems with PCBSD7 under VirtualBox.

I can’t make heads or tails out of the output before BTX halted. I know most of the names, corrispond to processor registers. In fact, to be more precise, I believe the ‘e’ is some extended-mnemonic from when Intel’s chips moved into the 32-Bit world. I don’t understand the output though, because I never had time to learn about assembly or dive deep into documentation on IA-32.

I managed to get a little time in, training with Jonsi on TG#1. Do to current affairs, I’ve been spending most of my server time in SWAT (PG3/TG3), but it’s nie to be reminded; I am still limber enough to put recruits through their paces :-). I need to take a look and see what’s going on these days, training wise in RvS.

I also spent sometime to help a friend with porting a page from (invalid) HTML 4.01 Transitional to XHTML 1.0 Strict. Not to hard for me, since I work with XHTML like most people I know, would use MS Word. Although, I personally prefer LaTeX for documents, for a long time; I did use XHTML+CSS as a replacement for word processors. If I had the time to learn to do as much as I can in LaTeX/TeX, I probably would prefer troff; but a more TeXuaL solution is where I ended up investing time.

Also my brain was complimented today, but despite the things I know, it doesn’t do me much good; because no one in this rats nest, will actually pay me for what I know or for using my brain lol. That’s one reason, why I try to be content with the fact, that most of what I know, I learned because I wanted to and enjoyed learning, as opposed to ever learning stuff to make money off it. Although, I do admit… getting paid for what I know, would seriously be an improvement over my current line of work lol. But I’m generally content with enjoying it on my own time.

Now, if only I could change the one point that really does bother me…

Hmm, with about 34% of battery power remaining (according to hw.acpi.battery.life), I think it is time for bed !!!

Time for bed, I’ll finish cleaning up after others later… And since I think I’ve figured out who did the nbsp look up and why, I might just have a few words with a certain someone or someones after work as the case may be…

Tomorrows job doesn’t bring any favorable thoughts to mind, especially when I need to get back to work on my on projects, but work pays the bills :. I hav a few things to do after work, including finishing tonights work lol. But it’ll hold a day or two if necessary. The reworking I’ve been doing tonight, is mostly because I need a test case for one of our new sub systems. And also, because the module of code the last sample came from, irks me in just about every way possible. And extremely wasteful operations and problem-side-steppings aside, it’s a pile of shit to start with. So refactoring it to use something more, ehh ‘sane’, can’t be to bad a thing….

Now if I could just convince the dog to give me a place to lay down >_>

Haha, a quick sneeze and Willow took off at light speed, looks like I get to stretch my feet haha!

This one is just to much

Ok, now this one has me putting my hands up an shoutin’ “this one’s to much!”

I’m working on rewriting an old pile of sludge that hurts my eyes, properly porting it to the new interface that works better… So far, so good, except for the fact that the actual bi-language mingle used for both logic and display, is about as undocumented and about as helpful, as a bullet in the toe.

All was going well in trying to understand it, until I saw this kind of thing:

/* NB: I probably added most of this indentation myself */
$query4 = *_query("look up a user", $dbh);
$name=*_fetch_array($query4, $dbh);
echo "<font color='#6699ff'><b".$name['the users name']."</b></font><BR><BR>";
echo "<table border='1' cellspacing='0' cellpadding='3'><tr border='0'><td align='left' border='0'><font color='#6699ff'><b>some header</b></font>";

$query = *_query("look up first section from database", $dbh);
if ($query) {
$nr = *_num_rows($query, $dbh);
for ($k=0;$k<$nr;$k++) {
$topic = *_fetch_array($query, $dbh);
echo "&nbsp;".$topic['the topics name']."&nbsp;";
// ... do other crap

Where ‘the topics name’ is looking up a row in the database, which contains a non breaing space: &nbsp; ALL THAT FOR WRITING A FREAKING BLANK SPACE !? I have no idea if that was a quick and dirty way of cutting an item out of the list or what (before I took over), but for crying out loud… If I ever did something so moronic, I would shoot myself before leaving it for someone to find.

THANK GOD THAT I DID NOT CREATE THIS MODULE …. Even if I’m the sap whose got to keep it running like a swiss clock :

Days recap

Quite a full day, if not very productive :

I was up to around 0500 last night, I dunno why but I never seem to get much sleep lately lol. The other day, I thought I was getting to bed early, and it was 0430’ish, well.. an hour early then the two days before I guess hahaha. Tried to sleep in today, since work didn’t start until the afternoon — not much luck. At least though, Tuesdays job is more time consuming then strenuous, tomorrows job on the other hand… Is more so a pain in the ass, then it is time consuming.

One thing odd, I heard Amanda kicked Adam out and that he’s staying with his parents again. Not a good sign in my opinion. Especially since, as memory serves, in 2007 I’ve seen and heard of a lot more people getting divorced or dying. 2008, I had somewhat hopped would put that incremental stream of numbers to an end lol.

One of these days, I really ant to take some time to write up a review of Google Chrome — I love that freaking thing!!! And whether the V8 JavaScript engine is really THAT fast or Google is taking advantage, gmail is so snappy on loading + the seperate process per tab thing, means no more browser-locks when launching gmail. Google Chrome is enough of an improvement over Firefox 2.x, that I might actually be able to re-take control of my inbox, if I ever get a linux binary package to use on my FreeBSD box… or better still, a native binary ;-). Perhaps it would be more fair to compare it to Firefox 3, but I use Flock 1.x most of the time, which is based on Firefox 2.x. And in all honesty, I hate Firefox 2 when compared to Firefox 1.0,x-1.5.x, it’s just lost that feeling I guess… I just don’t like the changes, and Firefox 3’s alpha builds didn’t look like an improvement. Although, I do have FF3 installed on SAL1600 just in case, but more so because it’s a newer version.

Google Chrome, I think is perhaps the best thing since Lynx and HTTPS but who knows >_>

As far as my efforts to standardize myself around 1/2 languages + what we use on [SAS], has fallen back into deadlock. Every way I slice the pie, Python seems to be the best choice for all of my needs, hell… The only time I’ve had an interpreted language come out as to slow for jobs I’ve tried to use them on, is an oddity. A script had to invoke perl so many times to process text, that it was faster to invoke sed/awk instead, which could actually be considered interpreted languages I guess lol. Some of the things I’ve heard about Python 3000 alarm me in that regard, but I’m not very concerned. The real problem is, I prefer C, but I don’t have *time* for C. When it comes to using C++ for tasks, I look at it as a two edge sword. More time savers then C but they all go out the window, in situations where they are not helpful.

That and working with gtkmm on Windows will probably be a pain in the royal hind quarters when it comes time to link against stuff. Although, I rather think a combination of Boost, Qt, and libs used in gnome is a good idea. The odd thing? C++ is not actually a language that I like a lot, but hey… beats Java I guess :

Java would actually be a perfect tool for my needs, except I don’t want to have to write in Java that much loooool.

Watchin’ the fireworks

The last couple of hours have been quite productive, probably because everyone else is sleeping for a change hehe.

I’ve been working on a simple class that provides the database usage schematics that I desire, namely… If I shoot myself in the foot, when in doubt — explode. And simple iterator support for rows. There are numerous interfaces I’m sure, but I’ve yet to see one that provided *what* I wanted, and it seems faster to write my own rather then keep researching.

The basic frame of thought I have, is if debugging a fuck-up is to costly in time, make sure it is easier to debug. In fact, in implementing the class… I accidentally shot myself in the foot, and the class exploded on me. I tried to implement something without thinking about the state of the supporting code clearly. I had forgotten to support 1 of 2 possible successful outcomes of a lower level method, which assumed any non successful outcome from this method was a critical problem (and it is 99% of times I’ve seen it fail). Since the method is intended for a situation where paranoia is preferred over ignoring problems, and needs to *only* allow correct actions to pass by it’s safe guards. The end result of my lack of thinking being, that I improved the iterator that started the chain reaction to report a problem that never occured to me as possible, and fixed the lower level support method in question to behave correctly, then tested it to ensure it works properly (along with methods depending upon it). If I hadn’t had that failed test initially, I probably wouldn’t have thought about fixing that until the next phase of testing (pre deployment), and would not have made that adjustment to the iterator, until I really got smacked upside the head using it lol.

Not exactly why I designed it the way I have, but it’s starting to pay for itself I guess :