Gist of the Day: Simple Threading in Perl

So today’s gist is a simple example of how to do two different things with two separate threads. Threading in Perl is misunderstood and often belittled, but it’s pretty straight-forward. The #1 problem that I think people encounter when threading in Perl is that they are using non-thread-safe code. If you’re using a CPAN module, you need to make sure you evaluate it for thread-safety prior to running it with threads (and if it’s using XS, it likely isn’t).
Anyway, this gist takes a function which crunches a set using a calculation routine. The calculation routine takes three parameters:

  1. The value so far
  2. N
  3. And the next value in the set

From there, the calculation routine performs the appropriate action on the next value in the set – given the prior value and the value of N – and then returns the result.
Here’s the Gist:

Gist of the Day: Mounting a Remote Share on OSX Using Obj-C and AppleScript

Way back when, I used to work on a Mac in a mostly Windows shop. People would send me windows network paths and expect me to be able to open them. I had to write a program to handle this stuff, and I thought this was a neat portion of that program.
Please note: This code was ripped out of its program, and therefore probably won’t work right away, though I think it’d be mostly portable. Check it out!
Here’s the Gist:

Gist for Tomorrow

As I do my gists I will play with new things. For tomorrow: a Python script which loads a CSV file into MongoDB. The day after the goal is to come up with a map-reduce for that.
I sincerely invite the (maybe) one person who is reading this to suggest some ideas for gists. Remember, keep it small.

A Gist per Day!

In all of the picking up and learning of new things I’ve been doing lately, I’ve decided to make a Gist per day for 30 days. This won’t be super-awesome or innovative, but these are just little brain teasers for me to do every day.
Feel free to follow me as I go along. If you have any requests or suggestions, please feel free to jump in!