Archive for February, 2007

If you simply must have it

For people who simply must have the ‘++’ operator in their language, I wrote one for ruby.


def plusplus(n)
  lambda {n += 1}
end
 
puts plusplus(3).call

Feel free to use it, as I release the above under the Glorious Peoples License.

(yes I am kidding around :p )

Grabbing import exceptions

I have a problem. I need to admit it. I can’t read anything without then chasing the information down all over the internet. It’s bad. :)

Yesterday, against my better judgment, I was reading John’s blog. The post was about a Python project that converts Java to Python. I figured like most of those X2Y programs it was probably fraught with problems, but I wanted to see the parser they came up with. So off I trudged to the svn repository. Well I never did get to the parser, because I saw they were wrapping the import of psycho in a try catch block. Now psycho is a non essential module, so you could easily dismiss any exception you caught, but it got me thinking that that could be handy in other languages as well, that way you could catch the exception and exit gracefully…unlike the nasty Perl error:


Can't locate Foo.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .)

That is confusing for non perlers, and could be made nicer using something like the above.

Here is the Python example:

try:
    import psyco
except (ImportError, ):
    pass
else:
    psyco.full()

And then in Ruby:

begin
  require 'Foo'
rescue LoadError
  puts "Aieee"
end

Perl was a little trickier. If only because I wasn’t sure how to do it. Eric lent me a hand and we came up with:

eval "use Foo()";
if ($@) {
  print "Aieee";
}

Anyway, I am adding this knowledge to my toolkit of programmatic-fu.

Of all the stupid *NIX crap

Apparently, crontab -r deletes your crontab. ‘r’ just happens to be beside ‘e’. So if you are going to edit the crontab, and you hit -r, you are screwed…/me grumbles and heads off to find a backup.

For those of you that don’t read comments | Yahoo Pipes

For those of you who don’t read the comments here (shame on you, the people that read this blog are a lot smarter than me and say much more poignant things than I) I think this comment deserves a post of it’s own.

David, a buddy of mine, saw my plight with the Dubner post below, and fixed it with this Yahoo Pipe. Pretty trick if you ask me.

Bash tip

Not sure if I posted this before, but I was just using one of my favorite Bash tricks and I thought I would post it here.

Often for testing or whatever I will need to make a bunch of dummy files or directories and one easy way I like to do it is


  touch foo{1..10}

Bash will expand that for you and create 10 files titled foo1, foo2, foo3…etc

C25K: Week 3 Day 1

I missed running yesterday to attend a lunch at work, so that was going to put the squeeze on my running for the week if I missed today due to weather. And the guy I run with would really have been squeezed to not run today. So out we went. It was actually not bad at all. The temp was nice and because the roads were pretty snowy we only had to deal with a few cars. All in all a good day running. This was the first day of running for 3 minutes sustained. While that might not sound bad to you, I am starting at or near the bottom of the fitness rung. I will say I did it easily and felt like I could have done much more by the time it was over.

Dubner

Dubner, the writer half of Freakonomics is a goof. The freakonomics blog is littered with his worthless posts. Basically, at least it appears to me, he’s riding the coat tails of his talented partner, Levitt. His posts aren’t interesting or informative, Levitt’s on the other hand are usually quite good. I don’t know, maybe I am projecting based on the author, but it appears that way to me. I am unsubscribing from the RSS, it’s tripe, and it’s Dubner’s fault for diluting an otherwise interesting take on life.

Uncle

Round one, tobacco companies 1, Nathan 0.

That sucked way more than I want to begin to talk about. I lost this one. I know I have to quit, I am just not sure how I am going to do it.

Thanks to everyone who commented, and cheered me on, that meant a lot. Sorry I didn’t make it.

**Update: Yes I feel like a dope **

10 Hours

Well I was right so far. Man does this suck :)

The lozenges do help somewhat. They are keeping the addiction withdraw symptoms at a low roar. I have eaten three of them so far. If it wasn’t actually happening to me it might even be interesting. I still have the habit part, so I will instinctively think about getting my smokes, and that causes a pang of addiction.

My hope is I can control the physical part long enough to break the habitual part, then just ween off the lozenges. We’ll see. I suppose making it 10 hours is some kind of victory, but I couldn’t feel less like celebrating.

I may run tomorrow even though it’s an off day, just to get out and stretch the lungs a bit…what’s the point in quitting if you can’t put the lungs though a workout.

C25K: Week 2 Day 3

Good run today. Legs felt good, ran a good pace. I pushed it a little more today and it felt good, however I didn’t have much left at the end so I think I might have gone a little too fast.

« Previous PageNext Page »