Perl promotes laziness

#
# We need to open a set of files for writing, and reference the paths later;
# the hash gives us a nice way to work with them later.
#
my %lgfiles = ( pidfile => "${datadir}/${0}.pid",
errlog => "${datadir}/${0}.err"
... => ... );

# but how do we open the set of files?


# this is a lot of typing, but common style in some places
open PIDFILE, ">", $lgfiles{pidfile} or die "some message: $!";
open ERRLOG, ">", $lgfiles{errlog} or die "some message: $!";
open ..., ">", $lgfiles{...} or die "some message: $!";


# this is better, but still too much typing
{
my $msg = 'some message:';
open PIDFILE, ">", $lgfiles{pidfile} or die "$msg $!";
open ERRLOG, ">", $lgfiles{errlog} or die "$msg $!";
open ..., ">", $lgfiles{...} or die "$msg $!";
}


# this is handy
#
# open each key in %lgfiles for writing to as KEY
#
while (my ($k, $v) = each %lgfiles) {
open uc($k), '>', $v or die "can't open $v: $!";
}

# same thing, but faster to read (IMHO)
#
# open each key in %lgfiles for writing to as KEY
#
map {
my $fn = $lgfiles{$_};
open uc($_), '>', $fn or die "can't open $fn: $!";
} keys %lgfiles;

For some reason, the intregration of regular expressions, qw/quote words/, map {} @list, grep {} @list, the $_ default variable, and the do_something or die $! thing are my favorite features of Perl. While in most other languages, the only great feature I get to enjoy is the trinary/ternary ?: operator, when there’s a place that it improves readiblity and reduces visual clutter ;-).

Ok, so my biggest beefs about Python 2.5 is no ? : and having to import re, hehe

Day dreams

Recently, I’ve been drueling a bit at the T-Mobile G1, if I had the money to spare, it would really be worth it, in it’s own way lol. Especially the fun of bending it to the functionality I require from such a gizmo, although honestly; I don’t care much for such mobile devices. In America, we’re stuck in a country where it pays more to rehash last years crap then be innovative; just look at Microsofts last 30 years of products.

I doubt, if I’ll ever meet a gizomo smaller then a laptop but bigger then a pen, that I won’t consider unneccessarily “downgraded”, short of importing an old Zaurus PDA or building something myself. Heh, if I had the kind of cash Mark Shuttleworth has, I would really have some fun :-). Enough cash to cover the educational-in-betweens, and the cash to see just what is possible with modern technology…

And then sale it and go broke in the process of competing with same ol’craps that tries to set the users expectations, not go for the gold.

Days thoughts, thus far

Managed to get to bed early last night, was only up to around 0330R haha. Dreams were a mixture, of pleasant and unpleasant; the former parts still being on my mind. I also woke up to some good news: an unexpected day off work! Which is good, because tomorrow will likely be a living hell…. as usual.

I’m tired, and it’s only 1736R. Really, I think the dog is the smart one lol, Willows been sleeping all day >_<. Last night, I posted on Daemon Forums asking for suggestions on a lightweight web browser to replace Firefox3. I've used Firefox for a really, really, really long time; but 1.5.x was the best hehe. I found Fx2 disappointing in terms of usability, and Fx3 has been totally useless for me on Windows, and a major pain in the ass under FreeBSD. I also went through Links 2.2, and tested it thoroughly; I could live without CSS support, if only it supported tabbed browsing in the GUI. Links is really a very nice browser on the user side, it also boats great speed and highly legible display. Today, I did some heavy testing on the FreeBSD and Linux builds of Opera 9.63. For a long time, I used Opera, first in the 8.5x and later into the early 9.x before switching defaults. Dillo2, Arora, and Midori are next on my hit list; but it would be awesome to adapt Opera as my standard browser again. I'm a person that very much likes to use his own personal environment, rather then someone else’s can of spam.

I also enjoy software that are both portable, easy to manage, and don’t make you unlearn things just for changing Operating Systems. One of my big beefs with Firefox for example, Unix edit->preferences Vs Windows tools->preferences. It adapts to what the user would expect, which is honourable for such a program I guess, but pisses me off ^_^.

Opera is one of the better proprietary products I’ve encountered, and one of my favorite web browsers. Unlike Internet Explorer and Mozilla Firefox, there is no need to extend it in order to get the most bang for ya buck either 😉

Writer’s Block: Tricky Questions

What is your first reaction when someone says “I need to talk to you”?

Live Journals Writer’s Block

“About what?”

What else could I possibly think of on first contact? >_>.

Ok, so my mind just works like that, lol — I can’t help it 🙂

Hard Target

Caught an interesting action movie on, Hard Target. I’m not a fan of Jean Claude van Damme, but I was well impressed. Throughout the entire action flick, I couldn’t help but wonder who made this movie… the planning and use of the camera was awesome; in a way, that I have not seen for years lol.

I also had the train of thought, some where along the lines that if John Woo didn’t have some influence on this, I’d eat my hat! Sure enough, Directed by John Woo, and executive produced by Sam Raimi, which really explains a lot. The shots in the movie alone make it worth watching, the ingenuity during fight, fusion of gun play and close quarters, go well beyond what you see in many of the more recent action movies. Not quite the invincible hero syndrome of the 80’s, or the regular 90’s flair but without a doubt, superb! Hard Targets a must see for any action movie goer lol.

Also good to see a techniques using a pistol in each hand, combined with Van Damme’s foot work; which can only be outshone by the bayou lovin’, moon shine drinkin’ uncle lol.

I can really relate to this:

Dark Helmet: Careful you idiot! I said across her nose, not up it!
Laser Gunner: Sorry sir! I’m doing my best!
Dark Helmet: Who made that man a gunner?
Major Asshole: I did sir. He’s my cousin.
Dark Helmet: Who is he?
Colonel Sandurz: He’s an asshole sir.
Dark Helmet: I know that! What’s his name?
Colonel Sandurz: That is his name sir. Asshole, Major Asshole!
Dark Helmet: And his cousin?
Colonel Sandurz: He’s an asshole too sir. Gunner’s mate First Class Philip Asshole!
Dark Helmet: How many asholes do we have on this ship, anyway?
[Entire bridge crew stands up and raises a hand]
Entire Bridge Crew: Yo!
Dark Helmet: I knew it. I’m surrounded by assholes!
[Dark Helmet pulls his face shield down]
Dark Helmet: Keep firing, assholes!

For some reason, they’ve been playing Spaceballs a lot lately, refreshing really – they usually don’t put it on cable that much.

scary…

Ok, picking apart X86 assembly by studying code written for Linux under GAS, using NASM for documentation on FreeBSD, was fun.

When it’s after 0800 zulu, I’m starving, and picking apart notations is beginning to compile into making sense….. and you can’t remember the last time you slept at ease, somerhing is just nuts… : I guess, the real question, is how much will still be remembered in the morning, or with the time frame I’m likely to get to bed at, probably the _afternoon_

Grrr….. spanning around 20 pages of wikipedia and other places on the net, I think I can kiss sleep good bye tonight…

One sad fact, with the limitations of my education: I always find myself backtracking through the “Eh, what does that mean” ‘ing of things, until eventually I figure it out, or my brains stack overflows; especially a problem, since once I start I often end up exploring further. (I still remember looking up something from the 1800s for school, and ending my quest around the 1960s in Vietnam War…)

In one of my many side steps from topic matter, to trying to make heads or tails of things I see, I finally saw something that made sense:

rewritten as:

I saw something like the above earlier today, and scratched my head. Seeing the decompiled form of it, the really strange thing? I see an iterative loop much like a line of code, haha! I remember seeing a symbol like the one in the center somewhere, in reference to summation; so considering that possibility (and noting to look try and look it up later); the n above and the i=1 below the symbol, it became clear. The ci xi made sense the instant I saw it, I’m not that numb lol; it was the stuff in the center that didn’t fit my comprehension.

So, if the n was the length of vectors c and x, with i so obviously being an index value >0 and < n; i=1 would have to be the first index value to use for iteration over c and x; intended to make it clear what element the slice begins at (helpful to me, since I often count from 0 to n, thank you C lol); and having already written off the funky-E as an operator meaning the find the total value of each element added together. The middle of the image became in my minds eye like some what like this:

for (i=1, n=length(c); i <= n; i++) { do a sum += c[i]; ... }

only, written sideways with lovable horizontal terseness 😉 I am reminded of a something I once read:

Mathematicians are [like] a sort of Frenchmen; if you talk to them, they translate it into their own language, and then it is immediately something quite different.

Johann Wolfgang von Goethe

but in this case, you could say a programmer is trying to translate math notation, into concepts he already knows as second nature lol. You know, it really would’ve be nice if school had thought me this stuff.

I think, I could really use a drink…

I had a shocking thought, stick a nice cigar in my mouth and give me a week in the brush, and I’m starting to look a little to much like Big Boss for my tastes :. I really need to get cleaned up this weekend, and get a close shave…. Really, I’d like to get out of this rats nest for awhile, and have some fun, but I am supposed to be using this time for a little Rest and Relaxation; guess taking a Buddy Love inspired holiday wouldn’t be very restful any way >_<

If it wasn’t for trying to learn something about differential equations (curse smart people for piquing my interest!) and reading a little bit of lisp, this might be a boring, lol.

Now if I could just do something about getting some sleep at night…….