Thursday, April 27, 2017

Using art to change the world, one discarded wrapper at a time

I can't resist heaping praise on this sort of project:

early in the morning, with a pen, a painting board, and no paper, I cycle in the alleys of Dali Old town and collect wasted paper. Once I find some paper or cardboard, I dismantle the wrappers, flatten it, and draw the architecture in front of me directly on it. After that, it will be nailed to the wall exactly where I picked it so that it could be seen by more people.

I mean, what's not to love? It's low-tech, low-cost and high-impact. The creator is literally turning trash into something beautiful and using art to fight pollution.

I love that this project ignored scalability and Just Did It. You could easily sit around wondering how you can use art to change the world, or you can get on your bike, find some trash, and actually change a small part of the world.

See the results here, they're truly wonderful:

Thanks to this talk for the lead to this project.

Wednesday, April 26, 2017

No URL? No Problem. Adding local file support to

3shrink does a great job of linking online resources with offline media. For example, shrinking a lengthy Google Mail URL into a 3 letter code that gets hand written on a TODO list. But what if the resource isn't yet online? Say, a photo I've just snapped with my cell phone, or a PDF I've downloaded to my local computer.

To support this use case, I'd need to add the ability to upload arbitrary files to 3shrink. So that's what I did.

The first step was detecting a file upload. Because I plan to use this functionality with Tasker, I based this functionality on its HTTP POST Action. Here's the code that powers the detection:

function is_upload_request() {
  return (g($_SERVER, 'REQUEST_METHOD') == 'POST' &&
          g($_SERVER, 'CONTENT_TYPE')   == 'application/octet-stream' && 
          geek_val()                    == GEEK_KEY);

Most of that's pretty standard, except for the geek related code. I setup 3shrink so that if the URL parameter geek is provided, then the system operates in a command line friendly way. In this latest version of 3shrink, I've extended this in two ways: first, geek can be provided as either a URL parameter or a cookie, the latter being more convenient for the HTTP POST Action. And second, I only allow uploads from requests that know the value of GEEK_KEY. So while anyone on the web can 3shrink a URL, only those who have requested the key from me (please do!), can perform file uploads.

Once I've detected and upload, storing the data in S3 and generating a URL to it, was surprisingly straightforward:

function do_upload() {
  $in_fd     = fopen("php://input", 'r');
  $buffer    = tempnam("/tmp", "upload");
  $buffer_fd = fopen($buffer, 'w');
  while($data = fgets($in_fd)) {
    fputs($buffer_fd, $data);
  $info      = finfo_open();
  $mime_type = finfo_file($info, $buffer, FILEINFO_MIME_TYPE);
  $name      = md5_file($buffer);
  $s3 = upload_s3_client();
  if(!$s3->doesObjectExist(UPLOAD_BUCKET, $name)) {
    $s3->putObject(['Bucket'      => UPLOAD_BUCKET,
                    'Key'         => $name,
                    'SourceFile'  => $buffer,
                    'ContentType' => $mime_type]);
  return $s3->getObjectUrl(UPLOAD_BUCKET, $name);

I'm suing the finfo library offered by PHP to effortlessly determine the mime type, and the Amazon PHP library to push the data to S3. I'm basing the name of the file on its contents, which means that multiple attempts to shrink the same file always returns the same 3 letter code.

I know that PHP isn't a particularly sexy language, but I'm impressed at how effortlessly I was able to implement offline storage, including mime type detection. Much of what makes this code especially cool isn't visible. For example, the PHP library code is managed by composer, and authentication to Amazon is powered by IAM roles, and is therefore automatic. Library management and authentication aren't typically hard, but they're do contribute to the friction in getting work done. And in the above solution, much of that friction has been eliminated.

To integrate uploading into the shrinking process was almost too easy:

if(is_upload_request()) {
  $content = do_upload();
} else {
  $content = g($_GET, 'i');

That's because the result of do_upload is a URL that the rest of the 3shrink process can work with.

With the code in place, here's how it can be invoked using curl:

curl -s -H 'Content-Type: application/octet-stream' \
     -b geek=xxxxxxxxxxxx \
     --data-binary @foo.jpg \

With this foundation in place, the next step is to enhance the AutoSharing capability on a mobile device to allow uploading of files. When that's done, I should be able to effortlessly snap a picture and moments later, have a 3 letter code that represents that picture.

Tuesday, April 25, 2017


The weather continues to mess with our heads, what with yesterday being 55°F and this weekend calling for nearly 90°F temps.

But the local flora isn't kvetching; it's spring, time to grow!

Monday, April 24, 2017

Weekly Discoveries - Political Rap, Hiking in 3D and Star Wars Awesomeness

I suppose it's more of a re-discovery than discovery, but Sade's No Ordinary Love is a song that transports me back to college every time I hear it. I don't even have a specific memory I associate with the song, it just brings me back to that time for reasons that are beyond me. So powerful.

I get that Oddisee's, Like Really is a political protest song, and an impressive one at that. But it's going to take quite a few more listens before I full process it. The opening lyrics are clear enough, though:

how you past due on payments, and I'm seeing you on vacation
how you gonna make us great when we were never really that amazing
take it back what, I don't find hanging black lives entertaining

Agree or disagree with the commentary, it is poetically delivered.

I always enjoy Joe Brewer's outdoor exploits, but one of his most hiking videos is especially interesting: he shot it with a 3D camera. The result is that as the video is playing, you can rotate the perspective, looking essentially in any direction. Is this a leap in film making, or just a gimmick? Time will tell, I suppose.

Bad Lip Reading productions are always pretty awesome, but they've outdone themselves with this Star Wars film: Not The Future. Yes, the lip reading is creative, but more than that, they've made an actually watchable and listenable tune. So well done! For more goodies, check out Bushes of Love and Seagulls!.

Check out out all the videos here:

Friday, April 21, 2017

The $2.00 Cell Phone Projector

The $1.00 iPhone Projector project was just too cool not to experiment with. The idea is simple: you take small box, fit it with a lens, and setup your cell phone behind it so that it projects onto a wall. The original instructions call for using a magnifying glass as the lens and Legos to create an adjustable cell phone mount.

I used the materials I had on hand, which was an random Amazon box, a $2.00 wallet Fresnel lens, duct tape and a few paper clips.

Even with my crude and hasty build, I ended up with a 'projector.' Here's me projecting a random photo of a sunset onto our basement wall:

With a better lens and more carefully constructed case, I'm sure I could get far better results. Just experimenting with using Legos as a DIY building material is probably worth the effort of doing this right. Ultimately, I'm not sure how functional this project would be even in its cleanest form, but it holds a surprising amount of promise.

Happy Hacking!

Thursday, April 20, 2017

Gotcha of the Day: Using Tasker's HTTP POST Action and PHP to upload a file

I plan to enhance 3shrink to support generating 3 letter codes in response to an upload. Before making this change, however, I wanted to understand how Tasker's HTTP POST Action works with respect to files. That way, I could be sure that any change I made to the core of 3shrink would play nicely with Tasker.

Tasker's HTTP POST Action is surprisingly finicky to use. The trickiest part: when you select a file to upload, Tasker injects a relative path to the file in the UI. Say, DCIM/Camera/20170330_005914.jpg. However, without the leading /, Tasker just assumes that this is an arbitrary string. And if you just add a leading slash to the path, you'll end up with a Tasker error about the file not being found. What's required is to have a valid absolute path in place.

After much playing, I learned that a valid absolute path begins with /sdcard, not /storage/emulated as some the file dialog box initially indicated. (At least that's how it works on my LG G6)

The other piece of the puzzle: you'll want to set the appropriate Content-Type for your file (using application/octet-stream is a fine catch-all).

Here are the correct settings:

On the PHP side of things, you can access this data by reading in the stream associated with php://input. Here's some sample code that slurps in the file from the web and writes it locally as Notice that I'm doing a bit of checking here to insure that the Content-Type is set as I expect it.

 * A chunk of PHP code to catch an incoming file that's been posted
 * by Tasker's HTTP Post action

if(isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/octet-stream') {
  $out_fd = fopen(__DIR__ . "/", "w");
  $in_fd  = fopen("php://input", "r");
  while($data = fgets($in_fd)) {
    fputs($out_fd, $data);
  echo "saved: " . filesize(__DIR__ . "/") . "\n";
} else {
  die("malformed request");

If all goes as planned, Tasker should happily push the file, and your PHP script should happily pull it in. Enjoy!

Note: for uploading a queue of files, it's far smarter to use the FolderSync and the its Tasker Plugin.

Wednesday, April 19, 2017

Weekly Discoveries and the Role of 'Likes' in Art Appreciation

I'm not quite sure where my head was at last week, but musically I started off down tempo, and got even more somber from there with Syml's Where is my love. Things did pick up again with Big Wild's Aftergold, which is definitely a toe tapping beat.

Rone's Gravity is a fantastic creation. While it appears to be made up of little more than a single actress who does a whole heck of a lot of jumping, the results are nearly magical. It seems to me a great example of passion and effort over budget and computer effects.

And speaking of budget, Real Estate's Crime is a hilarious example of a (seemingly) budget driven video creation. Just mix un-dead extreme sports enthusiasts, an online ceramics sculpture business and old timey values and you've got a winning video, right? Right, indeed.

On the non-music side of things you've got Jay's road to art self discovery. It dovetails well with an art appreciation video I've posted before. At the end of the day, both videos share a similar message: when you focus primarily on the technical mastery of art, you're missing out on so many other important aspects.

In Jay's video he talks about how a simple drawing garnered an unusually high number of 'likes.' This opens the door to another interesting discussion: how much should 'likes' matter? Was Jay selling out because he adapted his drawing style to what people wanted? Or, was he rightly adjusting his style to best communicate with his audience? Clearly, chasing likes is a very bad idea. But using them as feedback that you're connecting, seems like a great idea. In Jay's case, 'likes' opened his eyes to the fact that a seemingly inferior drawing style could resonate more with his readers.

View all the videos here.

Friday, April 14, 2017

Weekly Discoveries x2

Between preparing for, and enjoying Passover, I managed to get behind in posting weekly discoveries. Not to worry, I've got two weeks worth right here. And there's definitely some real gems to be found.

Lots Holloway's Is Anything Real Anymore is both a wonderful song and a terrifically creative video. It's amazing what can be done using little more than simple cartoon drawings. This makes me want to re-read Blah Blah Blah, and work on my visual literacy skills.

I love the comment from this video: BUT HOW DOES HE BREATHE. Seriously, what an amazing performance.

If you have a straw and 5 minutes, you can create your own Oboe. So yeah, I did this, and it was definitely fun. Loud and annoying, but fun.

I discovered my new favorite rapper Oddisee in a most unusual fashion. I was watching his NNGE video and caught site of what looked like the Fort Washington. Indeed, it was. Apparently Oddisee is a local, along with being a wonderful artist.

I'm loving Chord Overstreet's Hold On. It's just a simple, beautiful, singing.

I don't quite get it, but I stumbled on a number of Minecraft powered Music Videos. Is this really a thing? Either way, it seems like another creative way to use video games, so that's a win in my book.

Check out all the videos here and here, or below.

Thursday, April 13, 2017

The Long Reach of Passover

Today was spent catching up from being out for the first and second day of Passover. After comparing Seder experiences over Skype with an Israeli customer, I switched my focus to a group chat with another client. In the chat, a programmer from India informed the group that he had to drop off in a bit to attend Passover Dinner.

I had a moment of panic as I thought my previous conversation had leaked into the group chat. But that wasn't the case. Then I thought maybe I was misreading the message from the programmer. Nope, he really did write that he was heading off to Passover Dinner.

I had so many questions.

Sure, it's totally possible that he was Jewish. But if so, why call it a dinner and not a Seder? And why celebrate it after the rest of the Jewish community had celebrated theirs? I kicked off a private chat and politely asked what he meant.

He informed me that he was part of the Eastern Orthodox Church and that they celebrate Passover. I asked if they'd be eating matzoh at the dinner, and he explained no, they'd be eating a local adaptation: Pesaha Appam. It was unleavened bread, but made with rice.

According to the Wikipedia page, some groups burn the left over bread, just like the Torah requires you burn the left over pascal offering. Though he laughed at the idea that there would be any left overs.

A little research on the topic took me to this article

There are two states in the world where millions of people attend a Seder. One is Israel; which is the other? No single state in American has this scale of Seder-goers and Britain certainly does not come close. The answer lies in south-western India.

In case you are imagining some massive secret Jewish population, that is not the story in Kerala; the Sedarim there are organized by Christians. The state is home to around four million St. Thomas Christians, also known as Mar Thoma Nasranis and every spring they hold a family-based celebration involving unleavened bread, reading the Book of Exodus and praying. Sound familiar?

Who knew?

I explained to him that for me, Passover was not one night, but 8 days long and that we'd go all 8 days without eating unleavened bread. Not to be outdone, he mentioned that for 50 days prior to Easter they eat no meat or fish. I guess I'll stick with my 8 day regimen, thank you very much.

Incidentally, India has some fascinating Jewish History, including Jews that have been there well over 1,000 years.

Whether you celebrate the holiday for 1 night or 8 days, may it be a time of peace and joy. L'Chaim!

Friday, April 07, 2017

Sketchbook #2 - Be Positive and Other Lessons Learned

Here's sketchbook #2, as motivated by Art Before Breakfast. Here's a few observations about this go-around:

First, by the 3rd drawing in the book something clicked and I full embraced Danny Gregory's philosophy about "bad drawings." Sure, it's cheeky to write well that turned out terribly on the page, but it's not especially useful. Instead, I'm embracing Danny's approach that a bad drawing serves to teach you something. Rather than thinking: "wow, that drawing of a chair is horrendous," it's far more useful to think "look at that, I never realized that the chair is twice as tall as it is wide--who knew?"

This dovetails well with the thought that's been kicking around in the back of my head: why even bother drawing? If photo realism is what I'm after, then why not just use the camera in pocket? No, drawing (like photography in many respects) is about seeing the world in a new way. I've learned something about a chair I'd never known, even though I've stared at them my entire life. Being annoyed with myself until my drawings look "good" is just silly: my drawing aren't going to be photo-realistic, but they can be vehicles for learning things right now.

Second of all, you'll notice some drawings of our newest family member. For privacy reasons, I can't post his photo. But, I feel comfortable sharing these drawings, because fortunately, they look nothing like him. Or, put another way: despite what my drawings suggest, we are not providing foster care for a space alien.

Finally, if Danny Gregory is the voice of Yes You Can in the back of my head, Teoh Yi Chie is the voice of Here's How. For example, his tutorial on how to draw a Chinatown Street Scene is awesome: he emphasizes a few key guidelines that you can apply to your drawing with relative ease. It's just the right level of information to be informative without being overwhelming.

I've stitched up Sketchbook #3 and it's currently sandwiched between a few text books. In another day or two, I'll be ready to dive back in and start sketching again.

Thursday, April 06, 2017

Info When You Need It - Durable, Waterproof and Quick Access

Parenting is a funny thing. They actually expect you to know esoteric details about your kid, like say, how to spell his full name and when he was born. During the first few days of a placement there's appointments to be had, forms to be filled out, and sleep deprivation to be endured. So while it wouldn't take long for the little guy's details to get lodged in my brain, I did needed the information quickly at hand, now.

My first solution was to jot the details down in my pocket notebook. That was OK, but still cumbersome. Then I took a picture of my notebook and made it my phone's background. Again, an improvement, but I could do better. Finally I said screw it, and took a page out of my brother's book, and wrote it on my hand. The info was accessible, but not very durable.

Finally, I cut a strip of Tyvek envelope, wrote the relevant information on it using a Pilot Gel G2 pen, and secured it to my wrist with a duct tape clasp. Basically, I made one of these.

What's surprising to me is how well this little bracelet has held up. I've showered in it, slept in it, and had the little guy tug on it. All this, and the writing is still completely clear and the bracelet is still securely attached.

If you need durable and waterproof solution, Tyvek, Duct Tape and the Pilot G2 are your friends. You may not opt to wear this in bracelet form, but still, it's a good combination of materials to know about.

Wednesday, April 05, 2017

Our new (not so little) bundle of joy

You may wonder why there's suddenly a burst of parenting related posts on the blog or why Shira and I are more sleep deprived than usual or why we're pushing a stroller next time you see us. Simple: we have a new placement in our home, a wonderful 8 month old baby boy. As is normal in the foster care world, we're not sure how long he'll be with us. Due to privacy reasons, I can't post his photo. So instead, I'll post a photo of the extra parts that remained after assembling his crib:

I'm sure those aren't important. Right?

Even with having him in our home for only a few days I'm reminded that children are such a miracle. And you know what is also a miracle? Amazon same day delivery. Seriously, we live in an amazing time when you can remark to yourself at Sunday at 1:00am: we really need a tiny fridge in the boy's room so I don't have to trek up and down the stairs to get his bottle. And then Sunday evening, one shows up at your door (and it works well, by the way!).

There are always a lot of unknowns with foster care. But one thing's for sure: this is an adventure.

Tuesday, April 04, 2017

High or Low? Building a super simple tidal API

Living near the Potomac river, I find it's occasionally useful to know it's current tidal status. Typically, that means mulling over NOAA Tidal Charts like this one:

While reading these charts isn't especially difficult, I did want a quicker way to answer the simple question: is the tide out or in?

Fortunately, NOAA makes the tidal data that powers their charts available for download as CSV (and JSON and XML). You can hit the following URL to get the raw data that powers charts like the one above:\

With this data source in place, deriving a quick summary of the current state of the tide is simple. Here's what I do: I request two days worth of data leading up to the current time. I then look for the max and min tide values during that time period and make that my high and low tide values. At the same time I'm crawling through this data, I find the data point in the feed that's closest to the current time. That becomes the current tidal value.

I put that algorithm along with a curl call to pick up the data into this PHP file, and my summary API is complete. For example, consider this command line usage:

$ curl

That's low tide, high tide and the current level. Note the station value of 8594900 was lifted from NOAA's site and corresponds to a Potomac monitoring station. While I was at it, I implemented JSON output in case I wanted to deal in terms of structured data:

$ curl -s '' | jq .
  "high": "3.354",
  "low": "0.036",
  "current": "3.004",
  "offset": 102,
  "source": ""

Up next, I'll implement a series of smaller Tasker tasks so that I can quickly get this data on my phone or watch.

Sunday, April 02, 2017

A Week with an LG G6

I loved my Galaxy Note 5. Yes, it was a beast. But the husky form factor was more than made up for by the ginormous screen. The stylus was also a nice bonus. I didn't use it every day, but on more than one occasion it turned out to be quite handy. After years of using the Samsung flavor of Android, I figured I'd stick with them for the foreseeable future.

Unfortunately, the Note 7 was a bust, and when I got notified that my T-Mobile Jump Plan was up, I had a fresh opportunity to buy a new phone. I handled the Samsung S7 Edge in the store, but it was too puny for my liking. Instead, I walked out of the store with a brand new LG V20. The V20, like the note, is a beast, so I felt right at home with it.

More or less simultaneously, Shira upgraded her LG V10 for a shiny new LG G6. And just like that, we were a full on LG family.

While I was liking the V20 well enough, Shira was seriously missing the secondary screen that both the V10 and V20 have. Rather than me learn to love the second screen, and Shira learn to live without it, we did a switcharoo. Shira now has a V20, and I have the sleek new LG G6.

It's been a week now of being in LG land, and here's a few observations on the G6:

  1. After the Note 5 and LG V20, the LG G6 is positively petite. It's weird to be using a phone that compact again, but it's working well. It's hard to believe that both the Note 5 and LG G6 have the same size screen.
  2. While I do miss the stylus of the Note 5, there are more than enough goodies on the LG G6 to make me not regret the upgrade
  3. The dual cameras lenses on the G6, I believe, are the winning feature for this device. I use my phone for quite a bit of photography, and it's really great to be able to get two totally different perspectives out of one device. I'd love it if they could build a high quality telephoto lens into a cell phone, but I'll gladly take the regular and wide angle lens they've provided.
  4. I'm also impressed with the camera interface, which offers a clever square shooting mode and the ability to capture photos from all the lenses at the same time. I'm not sure which of these features will turn out to be essential, and which will be little more than demoware, but it's nice to have them to play with.
  5. The sound recording capability on the phone is another serious bonus. Finally, I can record sound on my cell phone and monitor what's being recorded in head phones. They also offer the ability to record from one or two different microphones. Apparently the V20's audio recording abilities are even more sophisticated than the G6's, but for my purposes, the G6's should be more than enough.
  6. The G6 is waterproof - whoo! I used to love being able to shoot photos while splashing around in the pool or at the beach. This is another very welcome feature.
  7. My Note 5 had 64 Gig of internal space, the G6 has 32 Gig, so that's not great. But I'm back to having access to an SD card, as well as a removable battery. So perhaps the smaller built in storage isn't as relevant? We'll see.
  8. The G6 comes with Nougat by default, an upgrade that I assume the Note 5 would eventually get. Still, it's nice to leap forward in Android versions, especially on a phone with an up to date processor.
  9. I could do without the having the hardware power button on the back of the phone. I'm used to having my phone laying on the desk next to me, and with Note I could reach over and scan a finger print without picking it up. On the other hand, after a week of using the new button position, I'm almost completely used to it.
  10. I love the implementation of the Software Touch Buttons. Being able to re-order the buttons, and choose which buttons appear are both significant improvements over the Samsung approach. I only wish that I could choose from among more than the 5 measly options.
  11. Two words: USB C! Ugh. I finally had enough Micro USB plugs and accessories, and now I needed to purchase new cables. What a pain. Fortunately, the adapters I purchased on Amazon are compact, functional and allow me to use the current heap of cables I've got lying around.
  12. For the first time, I'm using the phone without a case of any kind. I miss having a kickstand, so I picked up one of these. This case-less approach might be brilliant, and reflect the fact that modern cell phones are built tough as nails. Or, it might be foolhardy, time will tell.

The Note 5 was a remarkably solid device, and even after a year and a half it wasn't showing its age. Still, the LG G6, with it's dual cameras, slick recording ability and waterproof-ness shows that even a great phone can be improved upon.