Friday, September 18, 2009

mod_rewrite Voodoo

Ok, so not quite so much voodoo yet... but I have other tweaks in mind for it, and they promise to be more fun.
Background:  I have a new short domain name (flw.bz) resolving to the same place my original domain does (flowbuzz.com).  I decided to keep my flw.bz files in a subfolder (/short).  Oh, and my domain/webserver is virtual (and I think shared). I'm using YOURLS at the moment to provide URL-shortening capability (yay!).
Problem: How to get requests for flw.bz/blahblah to resolve properly while maintaining functionality of Yourls, not ending up in a mod_rewrite endless loop, etc.?
Answer: I tweaked the code in the .htaccess file that came with Yourls to look like this:



RewriteEngine On
# this doesn't do anything for me due to way my server is set up, so I left it commented out
#RewriteBase /

# take anything that's coming in to flw.bz
# and if its not a real file or directory, map it to short/ subfolder
RewriteCond %{HTTP_HOST} ^flw.bz$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
RewriteRule ^(.*)$ short/$1

# if I've put flw.bz/ in front of another URL, shorten it like a bookmarklet
RewriteCond %{HTTP_HOST} ^flw.bz$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(http://|https://)(.*)$
RewriteRule ^(.*)$ flwbz/admin/index.php?u=%1%2 [L]

# take anything that's coming in to flw.bz
# and now that it's mapped to short subfolder,
# if it *still* isn't a file or directory send it to YOURLS
RewriteCond %{HTTP_HOST} ^flw.bz$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^short/([0-9A-Za-z]+)/?$ short/yourls-go.php?id=$1 [L]


I may continue to do some tweaks, and probably will write my own PHP catching page and just use the Yourls API page. But after many hours of glazed-eye fiddling with complex mod_rewrite rules, this turned out to work.
[edited to add http catching code]

Friday, June 12, 2009

Jalapeño Margarita Sorbet

Jalapeño Margarita Sorbet

  • 1 1/4 cups sugar
  • 1 1/2 cups water
  • 1 egg white
  • ~1/2 - 2/3 cup lime juice (4-6 limes)
  • lime zest (couple of limes worth)
  • 1/4 tequila
  • 1/4 triple sec
  • 3 jalapeño peppers, deseeded & deveined (use gloves!)

Puree the peppers & water well
Make the simple syrup: boil sugar & peppers/water for a minute or two then pull off the heat.
Beat the egg white, mix in the remaining ingredients (not the syrup yet)
Temper the lime/egg white mixture by adding a little bit at a time of the warm pepper syrup & mixing.
Mix everything, cool completely, then put in your ice cream maker.

This is really tasty... the peppers give it just a teensy bit of "wow" and some great flavor but nothing too overpowering. if you've done a good job deveining them.  I adapted this from a several different sorbet recipes online.  The egg white is supposed to help keep this smooth, creamy, and help it last a while in the freezer.  Not that this will stick around long enough :)

Thursday, April 16, 2009

Converting Entrust Certs

Just a quick tip -- you can convert the PKCS#7 certificates that Entrust exports in a binary format (*.p7c) to an ascii format *.PEM file:

C:\OpenSSL\bin>openssl pkcs7 -in c:\bens_cert.p7c -inform DER -outform PEM -out c:\bens_cert.pem

References:
http://forum.pgp.com/pgp/board/message?board.id=46&thread.id=1148
https://www.sipit.net/CertToolsInstructions

Friday, April 3, 2009

iPhone OCR

There are most likely several applications for the iPhone that already do some of what this idea covers, but probably none that can pull it all together.

With all the power of the cloud/grid/global-supercomputer available via web api's, why not tap further into it with our mobile devices?  I was thinking along these lines earlier in the shower, mulling over Amazon's announcement of the Hadoop/MapReduce service and... eureka!

The iPhone could use a nice optical character recognition system.  But something more than just basic OCR.  Most OCR systems are far from perfect.  Just like most speech-recognition systems aren't perfect.  But imagine, if you will, an application that combined the two.  If you were able to use the phone's camera as a real-time video-feed while you read along "out loud," and pushed a stripe of the video frames, audio data, and accelerometer data (as you move the phone along while reading) to the cloud, it could feasible do a very *very* nice job of text recognition.

But why leave it at that?  Since you're 70% of the way there, why not add 2D barcode processing?  And since those barcodes have embedded information (and often so does text), why not give the application some convenience features while we're at it?  If capturing a URL, it could offer to launch Safari, post it to Delicious, or tweet it via bit.ly.  Phone number handling would be obvious.  In fact any captured text snippets could be pushed to several applications on the phone (somehow?) or Web 2.0 services.   Tie in geolocation and you'd have a great idea of what people are reading where, perhaps making this monetizable (if aggregated anonymously, of course).

Facial recognition might be stretching it a bit, but not a thought that's completely unreasonable.  Tie it in to Facebook and wow...  (business card capturing, anyone?)

So there you go code monkeys.  Get to work :)  And since I'd love to see something like this, consider the idea public domain (duh, it's on a blog) and All Rights Released -- although I'd it would be dandy if you'd mention me in the credits if this inspires you to go build your own.

Tuesday, March 31, 2009

Energy Efficient Elevators

While not anything necessarily "groundbreaking," I think that a building with several busy elevators could see a slight drop in power usage if they tweaked the settings so that the elevator doors stayed open slightly longer when it was lighter (less full).

Thursday, March 26, 2009

Existential Moment

As I drove in to work this morning, with my wife and sick child at home behind me and my as-of-yet unfullfilling and more than a little frustrating job ahead of me... with the morning sun shining directly into my eyes... I had a somewhat existential moment. On a side note, I wish the taco trucks opened early so I could get huevos ranchero y chorizo in a warm tortilla.

Thursday, February 12, 2009

Restaurant Incubator

I saw a post on PSFK that reminded me of a business idea I had quite some time ago. First I'll introduce a bit of background: our area (Tri-Cities, WA) is notoriously fickle and more than a bit flaky. We constantly have new restaurants popping up here or there and unfortunately as many good ones going out of business just as fast. It was this fact coupled with remembering a joke that a friend of mine once told me once, "Do you know how to make a million dollars in the restaurant business? Start with two million," that sparked my idea.
So if the title didn't give the concept away, here it is: Restaurant Incubators. A building set up so that you could have multiple easily-reconfigured restaurants designed to share some resources (and come pre-equipped with others). I know in practice this could be tricky (too many chefs in the kitchen), so some of the things would need to be independent -- but with good planning, it just might work. This would allow places that might otherwise not exist the opportunity to establish themselves, their menus, and some clientele with lower initial risk, and then move out to their own buildings after a couple years. I think it would also cultivate many new culinary/restaurant ideas that people would otherwise be adverse to trying.

Wednesday, January 14, 2009

Scotch Eggs

Scotch Eggs

  • 8 Large Eggs, hard boiled and peeled
  • 2 tubes of bulk sausage (1.5 - 2 lbs, depending on how large the eggs are)
  • Bread crumbs
  • Flour


Simply: enrobe/encase the eggs with sausage, coat with breadcrumbs, and fry (or bake).

Tips/tricks:
  • Coat (roll) the eggs with flour -- it helps the sausage stick to them. I'd do two coats, five or so minutes apart.
  • Keep the sausage cool, it makes it more sticky... so either work fast, have a partner helping, or form all the balls first & coat them with crumbs afterward.
  • Make an un-even thin sausage patty, with the patty in one hand, place an egg in the center of the patty, then fold & smoosh the sausage around the egg until it is completely enclosed, like a pork & egg version of nigiri.

The hard part: Next to getting the sausage to stick to the boiled & peeled eggs (which if you follow the tips above won't be the hard part), the hardest part is cooking the big sausage balls all the way through, evenly. Baking would probably be a better solution (and perhaps a skosh healthier).


I first heard of these "Scotch Eggs" back in 1994. Several of us from RAF Mildenhall had taken some leave and gone down to attend the Reading Festival -- this enormous 3-day outdoor music festival (think Woodstock). We all made a nice big camp in one of the fields, and the camp right next to ours was a big group of Scots. One of them was this hilarious, rough (and bald as an egg herself) Scottish chick who should have had a career in stand up comedy. She wandered into our camp one day munching something, cracking jokes, and making fun of everyone with hangovers. After trying to discretely figure out what the heck she was eating, I finally just asked... and she told me all about Scotch Eggs (although I think her eggs were pickled). Last night was my third time making these... and I had told myself after the second time that the NEXT time I would try coating the eggs with flour first, since getting sausage to stick to slippery eggs was difficult (understatement). Bingo!

[edited to get rid of a code snippet that had somehow found its way in]