I recently had a need to parallel process some tasks for a non-critical app, but really didn't want it to get out of hand. I wrote this as a simple way to multi-thread without the pain of worrying about synchronizing and queues and being thread safe.
It achieves ghetto thread pooling by chunking the result set into whatever size slice is needed and spins up some threads, once that set is done it will repeat until the data is all processed before moving on.
It ended up working out really well as a direct drop-in, and speeded up the processing greatly. I wouldn't recommend this for production code, however.Continue Reading
This little script is a convenient way to add paths to your
$PATH variable without worrying about duplication. I generally break out my
.bash files to be organized across multiple servers/computers and each one seems to need different paths appended -- so thats where this little guy comes in handy. Just a simple
push_path and no worries.
I've been spending a lot of time creating reports lately, and I generally live in a terminal, so naturally I started to think of ways to easily send emails with these reports attached. I'm stuck using Microsoft Entourage here at work, but thankfully they have a pretty robust AppleScript library. Mixing some stuff together I pulled together this Ruby script which will allow me to do some neat stuff:
At its core, it is nothing more than a simple ruby shell script which compiles AppleScript and uses
osascript to execute the AppleScript. When run it will pop open a new Entourage mail window with the To/CC/Subject filled out, as well as any attachments and moves focus to the window. If I had piped anything to STDIN that would be the body, otherwise it would blank and ready for a quick message. Then a quick
CMD-ENTER and off the mail goes. Simple and elegant, yet kind of powerful :)
I was writing a small shell script in Ruby today that needed to check STDIN for data, but I didn't want to prompt the user to enter data when nothing was found (I only wanted piped in data). This turned out to involve a little more effort than just checking
Luckily, I found a solution at Footle that worked out great. Heres to anyone who needs only piped in data from STDIN without prompting the user.Continue Reading
Sinatra is awesome, but Rails has a lot of useful features. One of those is Active Record's Query Caching. I never realized how useful this is until I started to optimize Sinatra apps and felt its absence. Here is a simple way to enable active record query caching in Sinatra.Continue Reading
As we all know, iTunes is opinionated, but we can lessen that with a few
defaults write commands. One thing that is annoying is their new PING feature, which I consider useless. Another thing is their Store Arrows which can be obnoxious. This will reverse those and make it so the PING icon is hidden, and the store arrows actually search within your library. (This is common knowledge, but useful nonetheless)
I re-discovered the fun that is OpenSSL's encryption today when I was cleaning up some bash aliases and though I'd share them.
This allows you to do some really stupid but fun things like encrypt backups, or messages to pass to a buddy. The uses are endless!Continue Reading
I'll start off by saying that I love Google's JSAPI. The other day all hell broke loose when, due to internal server issues,
in all 12 or so internal apps using JSAPI. In other words, a major headache since I was faced with having to manually update the apps with the proper JS dependencies. Luckily I found out where those jsapi libs were stored, and through another stroke of luck found that they were resolving properly. So for any of you out there that get yourself into this odd situation, or wish to avoid using
google.load(...) by directly linking to the libraries themselves, here ya go.
It seems like every time I re-compile PHP I get some whacky error. Anyway, I was fortunate enough that a quick Googling found a solution from katmai for compile error.
I'm popping this up here as a reminder to my future self, as well as anyone else who stumbles into this.
If you get this error when attempting to compile PHP 5.3.3 with MySQLi on, in my case, Snow Leopard
/usr/local/include/mysql/my_global.h:1008: error: duplicate ‘unsigned’ /usr/local/include/mysql/my_global.h:1008: warning: useless type name in empty declaration
Was solved with a simple patch to ext/mysqli/phpmysqlistructs.hContinue Reading
This is a simple, but useful little script I ended up writing to test some things. I found it easier to use this than to constantly use the
./spoofmail.rb --email@example.com --firstname.lastname@example.org --subject='Hey You!' --body='whatsup guy?'
or using STDIN
./spoofmail.rb --email@example.com --firstname.lastname@example.org --subject='Hey You!' < bodyofmessage
cat|./spoofmail.rb --email@example.com --firstname.lastname@example.org --subject='Hey You!' whatsup guy? ^d
It might come in handy one day when you need to mess with a co-worker or test a mail receiver... or something else?Continue Reading