Tuesday, September 13, 2016

How Not To Make Pokeweed Ink

Around here, pokeweed is everywhere. And this time of year some of the plants are beginning to produce tempting clusters of purple berries. There are two things you need to know about these berries: First, they're terrifically poisonous (to us) and second of all, they make great ink. Ever since I learned the latter, I wanted to give it a try.

Last night, while on a walk, I carefully snipped off a cluster of purple berries and carefully placed them into a Ziplock bag. This morning, I cautiously squished the bag and lo and behold, I had a bright liquid to work with:

Next up, I knew I needed to strain the mixture. My plan: grab a swatch of old old t-shirt and use it like a cheesecloth. Because I had comparatively little liquid to work with, I used an empty tea candle base as the ink well. I carefully cut the bag and poured the juice into the t-shirt covered ink well:

At first I thought it was working. How wrong I was. The juice did exactly what it was supposed to do when it hit the t-shirt fabric: it stained it. The result was a wonderfully colored swatch of t-shirt fabric and no ink in my inkwell. D'oh.

I was about to give up, when I noticed I had a few drops of liquid left in the bag. I squeezed those into my inkwell. For good measure I added a bit corn starch (as recommended here), and gave it all little mix with a toothpick.

Using a toothpick as a stylus, I went to work creating a masterpiece from my new ink:

I've got to say, the result was incredibly satisfying. I'd bumbled my way through the process and still managed to make ink! It's truly remarkable how potent those berries are - talk about a stainfest waiting to happen.

I'm definitely going to keep an eye out for more berries. And next time, I'll try using pantyhose instead of cotton fabric for the straining part. I'm sure Shira won't mind if I raid her supply.

Monday, September 12, 2016

NFC + Legos = ?, Adventures in Gamification of Legos

Who knew that buying a package of Legos could lead to an emotion roller coaster? On one hand, I was psyched when I picked up a few Lego Dimension kits at Five Below. The small set seemed perfect for a quick afternoon activity. I then found myself disappointed when I opened the package and found out that the instructions for building the small set were available only through a Lego game. I was then back to happy when I found a site that gave free access to said instructions. Finally, my little journey of joy and annoyance ended on a happy note when I learned that the plastic bases that hold the Lego Dimension characters are actually NFC Tags.

Over the summer, I sent the kids home with their Lego Dimension characters and vehicles, but held onto the little magic plastic bases. I figured I'd have to put them to use, somehow. Here's a random knock-off minifigure perched upon the NFC base, waiting for me to do something brilliant with him:

I thought about doing something practical, but I couldn't really see any value the NFC Lego base would have over the NFC stickers that are quite frankly, awesome. Then last night it hit me: I should build a sort of hybrid game, where you play with Legos but use the NFC base and a mobile phone to help steer the playing. Think Dungeons and Dragons, only with Lego Characters and your mobile phone and not dice.

There's only one small detail: I know absolutely nothing about D&D. While my older brother played, I did not. Even Simple DnD was too complex for me to quickly absorb and turn into some sort of program. So yeah, my vision of being a game master would have to wait.

But I decided I'd dip a toe into the process, regardless. Step 1: vastly simplify *everything*.

I imagined that for a character roll playing game to work you'd need something random (think: roll of a dice) and some sort of state (think: the health of your player). And so I started to futz around with these ideas. Of course, I went to my goto prototyping environment: Tasker.

Here's a Task that generates a random number, whether it's positive or negative, and updates your current score (which starts at 100). Every time I scan the character's base, my phone brings up a dialog box with the updated status of my character:

%Lego Refresh (162)
 A2: Variable Set [ Name:%char To:char1 Do Maths:Off Append:Off ] 
 A3: Variable Randomize [ Name:%polarity Min:0 Max:1 ] 
 A4: Variable Randomize [ Name:%offset Min:1 Max:10 ] 

 A5: Test File [ Type:Type Data:Tasker/lego/%char.txt Store Result In:%found Use Root:Off Continue Task After Error:On ] 
 A6: If [ %found !Set ]
   A7: Variable Set [ Name:%current To:100 Do Maths:Off Append:Off ] 
 A8: Else 
   A9: Read Line [ File:Tasker/lego/%char.txt Line:1 To Var:%current ] 
 A10: End If 

 A11: Variable Set [ Name:%updated To:%current Do Maths:Off Append:Off ] 

 A12: If [ %polarity eq 0 ]
   A13: Variable Add [ Name:%updated Value:%offset Wrap Around:0 ] 
   A14: Variable Set [ Name:%operator To:+ Do Maths:Off Append:Off ] 
 A15: Else 
   A16: Variable Subtract [ Name:%updated Value:%offset Wrap Around:0 ] 
   A17: Variable Set [ Name:%operator To:- Do Maths:Off Append:Off ] 
 A18: End If 

 A19: If [ %updated < 0 ]
   A20: Variable Set [ Name:%updated To:0 Do Maths:Off Append:Off ] 
 A21: End If 

 A22: Write File [ File:Tasker/lego/%char.txt Text:%updated Append:Off Add Newline:On ] 

 A23: Show Scene [ Name:Lego Update Display As:Dialog Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Continue Task Immediately:On ] 
 A24: Element Text [ Scene Name:Lego Update Element:Score Position:Replace Existing Text:%current %operator %offset 
= 
%updated Selection: ] 

Here's 3 scans of my character in a row:

So yeah, there's not much to see here. But it is interesting to see how Tasker Scenes work, and to continue to experiment with novel uses of NFC. I'll have to think about what strategic code I can write that will start moving this closer to an actual playable activity. With the right story line and heavy use of imagination, perhaps not much. We'll see.

Friday, September 09, 2016

Pastebin and the Command Line - Clipboard Access Anywhere

A couple of days ago, I setup my phone to push the clipboard to pastebin.com automatically. Now I wanted an easy way to access these pastes from the command line. Fortunately, the pastebin API is a breeze to use, and quite curl friendly.

Here's a shell script that pulls down the most recent paste:

#!/bin/bash

##
## A command line tool to pull pastes from pastebin.com
##

USER_KEY=__SAME_USER_KEY_TASKER_USES__
API_KEY=__SAME_API_KEY_TASKER_USES__
count=1


ids() {
  curl -s -d api_option=list \
       -d api_user_key=$USER_KEY \
       -d api_dev_key=$API_KEY \
       -d api_results_limit=$count \
       'http://pastebin.com/api/api_post.php' | 
    grep paste_key |
    sed -e 's|<paste_key>||' -e 's|</paste_key>||'  
}

for id in `ids` ; do
   id=`echo $id | tr -d '[\r\n]'`
   curl -s http://pastebin.com/raw/$id
done

On Windows, I can leverage clip.exe to store the output of the most recent paste into the clipboard.

  pbget | clip

Getting content from my phone's clipboard to my Desktop's clipboard is now nearly automatic, and thanks to pastebin.com is archived for 24 hours. And as a bonus, I'm not limited to accessing the phone's clipboard from a local computer. Any server with curl and a net connection can now get quick access to my phone's clipboard.

How I Get Stuff Done

Over at /r/getdisciplined, the following advice was offered:

[Advice] This is the *real* secret to success...a million self help books boiled down to their essence in one sentence.

Learn to front-load your pain.

The author continues:

If you procrastinate, you're putting off more than your work. You're putting off the pain. Right?

But doesn't it always catch up to you?

What you have to do is front-load all those yucky crappy feelings. Go ahead and feel it now so you don't have to feel it later. And guess what? If you put it off, it gets amplified. Right now you're dreading doing your homework or writing an article or w/e, but what if you don't do it? And worse, what if you put that stuff off consistently?

That thing you feel crappy about? That thing you're dreading? That is exactly the thing you need to do in order to improve your life.

This got me thinking about how I get stuff done, and it occurred to me that I follow a related, yet different paradigm. I'd tersely describe it so:

Pump your legs.

Allow me to explain.

Imagine you're a 6 year old kid. You want to swing on the swing-set, but you know you're too old to ask your mom or dad to push you. Instead, you decide it's time to try the technique your parents have been barking at you for the last few months: pump your legs! You brace yourself and heave yourself forward with all your might. Nothing happens. Well, not quite nothing. You notice that you move forward ever so slightly. You try again. And again. At some point, something magical happens, you start to rock back and forth. Then you start pumping your legs like your parents told you. And just like that, your swinging all without any help. What started as an apparently futile effort morphed itself into a beautiful display of playground mastery.

And that's how I tend to tackle projects.

I start small. Do something. Do anything. At first, my attempts look clumsy and seem to make little to no progress. But after warming up a bit I gain that magic momentum where I start making more and more progress. Before I know it, the project I was dreading is something I can't wait to work on. You can forget questions of "where to put the pain" because there isn't any pain.

This approach works because of this mysterious property I'm referring to as momentum. But what the heck is it? I think it's is closely related to flow. Where flow applies to a particular work session, momentum is the result of stringing together sessions that hold the potential for reaching flow. Where flow makes a particular set of tasks seem effortless, momentum helps make the entire project seem on track and generally in the groove.

While my preferred strategy differs from the one offered on Reddit, it does have an important commonality: they both only work if you start today. Building momentum takes time, so procrastination is definitely the enemy.

So how do you prefer to get stuff done? Please share in the comments.

Wednesday, September 07, 2016

Pastebin and Tasker - An Automatic Clipboard Archiving Solution

The other day I realized I had no seamless way of accessing my phone's clipboard while on my desktop computer. Sure, I had work-arounds like pasting the clipboard into a Google Doc and accessing said Google Doc on a desktop machine, but that's clunky to the say the least. Here's my first pass at a more automated solution.

After a bit of poking around, I decided that I'd shoot for the following: have my Android phone push the system clipboard to pastebin.com, and then use a browser on my desktop to access pastebin. Solutions like AirDroid are really slick, but are relatively cumbersome to setup. By having the clipboard in pastebin, I know I can easily access it from anywhere. Additionally, pastebin's archival nature means that accessing older clipboard entries is breeze. As a bonus, pastebin's API is drop dead simple and I was hoping it would play nice with Tasker.

Fortunately, my hunch was correct: Tasker's HTTP Post action is a near perfect fit for the pastebin API. Here's the Tasker Action I worked up that creates a new pastebin entry:

Pastebin, Create (115)
  A1: Variable Set [ Name:%api_key To:API_KEY ... ] 
  A2: Variable Set [ Name:%paste To:%par1 ...] 
  A3: Variable Set [ Name:%expires To:%par2 ... ] 
  A4: Variable Set [ Name:%user_key To:USER_KEY ... ] 
  A5: HTTP Post [ 
   Server:Port:pastebin.com
   Path:/api/api_post.php 
   Data / File:
    api_option=paste
    api_dev_key=%api_key
    api_paste_private=2
    api_paste_name=From My Phone
    api_paste_expire_date=%expires
    api_user_key=%user_key
    api_paste_code=%paste 
   ... Content Type:application/x-www-form-urlencoded
   Output File:Tasker/pastebin.response.txt
  ] 
  A6: Read File [
   File:Tasker/pastebin.response.txt To Var:%response 
  ] 
  A7: Return [ Value:%response Stop:On ] 

A few notes on the code above. You'll need to fill in your own version of API_KEY and USER_KEY to make this work. The above action is intended to be called by Perform Action with two parameters: the content to paste and an expiration date. The result is a generic Pastebin, Create action that can be used in a number of contexts.

With the above code written and debugged, I just needed to setup a simple action that would ship off the the magic %CLIP variable that contains the clipboard contents to pastebin.

Pastebin, Push Clipboard (134)
 A1: Perform Task [
   Name:Pastebin, Create
   Priority:%priority+1
   Parameter 1 (%par1):%CLIP
   Parameter 2 (%par2):1D
   Return Value Variable:%response
   Stop:Off ] 
 A2: Notify [
    Title:%response Text: Icon:ipack:crystalhd:package_editorspackage_editors
    Number:0 Permanent:Off Priority:3
 ] 

Note that I'm setting the 'paste' to expire in 1 day. I expect I'll tweak this over time, but for now, I'm thinking 1 day makes sense.

Finally, I setup a profile that detects when the %CLIP variable changes:

With all of this in place, anytime I copy text to my phone's clipboard, it shows up just a few moments later on pastebin. An unexpected bonus: my phone has a Copy to Clipboard sharing action which means that I can effectively push data from apps to pastebin with a single click. Here's an example of this functionality as seen from the YouTube app:

If I clicked the Copy Link option, a few moments later, the URL of the video would be on pastebin.

I doubt this will be the last word on copy and pasting the clipboard between my phone and desktop devices. But it sure is a fun start. I've been a fan of Pastebin for many years, so I'm psyched to integrate with the service. And the fact that it's completely automated, well let's just say I wrote the code and even I think it's magic. Time will tell how practical it is, though.

Tuesday, September 06, 2016

A Digital Tribute to a Sweet WII Hack

ITS Tactical has an excellent post up on the World War II Cricket Clacker, a humble, yet powerful device I'd never heard of it. They explain:

During Operation Overlord, the WWII D-Day Invasion into Normandy, France on June 6th 1944, American Paratroopers carried a signaling device known as the Cricket.

The Cricket Clicker (aka Cricket Clacker) provided a distinct “click” sound when the steel backer was depressed against the brass body of the small 2 inch device.

Used as an early IFF (Identification Friend or Foe) device, the Cricket enabled paratroopers to communicate with each other under total darkness and surrounded by enemy forces as they landed scattered and out of position on the beach.

Here's what a Cricket Clicker looks like:

And here's what one sounds like. While not much to look at, it was a brilliant solution to an age old problem: how to navigate the fog of war. There's no denying that technology plays an important role in combat operations, but every once in a while, classic low-tech solutions really shines through. Like the tri-graph based encryption used during the Vietnam war. And you really can't get much lower tech than a brass and steel rectangular box. But it apparently did the job.

ITS relays this story:

“I had my pistol in one hand, my cricket in the other… I crept along the hedgerow looking for a gate. Just as I found it, I heard a stir on the other side. I drew my pistol and got all set. Then I heard the click. That was the most pleasant sound I ever heard in the entire war.” ~ General Maxwell D. Taylor, Commander of the 101st Airborne Division

Given my fondness for clever hacks like this, it's tempting to pick one up online. However, I thought I go the digital route and make a quick android version of the clicker. Naturally, I banged this out in Tasker.

First up, I needed some sound files to play. SoundBible.com totally had me covered. In a nod to the name of the original device, I grabbed 4 sounds: a click, a frog croaking, a bird singing and of course crickets chirping. I then worked up a trivial Tasker action to play back an arbitrary sound:

Play Sound (145)
 A1: Variable Set [ Name:%name To:%par1 Do Maths:Off Append:Off ] 
 A2: Music Play [ File:Tasker/sounds/%name.mp3 Start:0 Loop:Off Stream:3 ] 
 A3: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] 
 A4: Music Stop [ Clear Dir:Off ] 

Next I needed to build a little UI for my app. This is strictly for covert use, so the fact that my UI is especially cryptic works to my advantage.* I busted out Tasker's scene capability and drew up this UI:

I wired each of the rectangles above into the Play Sound action with a specific sound file provided and I had my working app.

To launch the app, I created a Tasker Widget on my launcher

And here's the app in action:

Next time I've got a covert night mission to run (read: a rousing game of capture the flag) I'll totally have to bust this app out to give our team the advantage.

Joking aside, it really is amazing how simple tech can do so much.


*In hindsight, I should have also designed the UI with a dark look (black background, dark buttons, etc.), as that would make the app more friendly to use at night. Oh well, that will have to be part of v2.0.

Monday, September 05, 2016

A Bit of Brooklyn

After a fun and exhausting few days at the US Open, it was such a treat to meet up with our friends Jen and Jim in Brooklyn. They served up a gourmet breakfast of waffles, berries and fresh whipped cream (yum!). After eating Jen took us on a stroll through the Brooklyn waterfront. As we walked down the end of their street, I was blown away with the scene in front of me: you had the sky scrapers of lower Manhattan, the iconic Brooklyn Bridge and even the Statue of Liberty off in the distance. Needless to say, I couldn't stop snapping photos.

After walking along the waterfront and seeing how the various warehouses and docks had been turned into sport fields and playgrounds, we made our way to Atlantic Avenue where we picked up some essentials for our ride home (read: fresh bagels, fresh pita and fresh fruit). Of course we passed a Cat Cafe, because, you know, it's Brooklyn. Oh, and we also passed a pop-up pool, again, because why shouldn't you have a little beach oasis in the city?

After days of watching tennis, there's could be no bigger treat than hanging with friends and taking in the sites of the city. Thanks Jen and Jim!

US Open 2016 - More Tennis Than You Can Shake a Racket At

Another US Open is behind us, and while I could probably go another 365 days or so without sitting through another tennis match, I have to admit I had fun. A lot of fun. It really is a thrill to watch amazing athletes perform, all while chowing down on waffle fries and ice cream.

A few highlights: watching Jack Sock beat Marin Cilic (USA!, USA!, USA!). Peering over the edge of Arthur Ashe stadium and watching Stan Wawrinka fend off a match point in a tiebreaker and then turning around and watching Venus Williams crush Laura Siegemund on the court below (USA!, USA!, USA!). Sitting in the second row while Joao Sousa and Grigor Dimitrov battled it out. Getting dinner from Soom Soom, which had surprisingly authentic, fresh and delicious pita, falafel and hummos. Waffle fries and Ben and Jerry's Ice Cream (yes, I mentioned this above, but it bears repeating). Watching from the second row as Tsonaga warmed up for his round 3 match against Kevin Anderson. Watching del Potro sweep Steve Johnson in a night match, just about 7 years after watching him in our first professional tennis match we'd attended. Hanging out with friends who were attending the Open for the first time.

It wasn't all highlights. We had two matches that ended early due to retirements, including a Novac Djokovic match, a player we were very much hoping to see in action. But the unpredictability of the Open is definitely a feature and not a bug.

I better start resting up now, as we're almost certainly going back next year. Whoo!

View Full Album