Wednesday, April 24, 2019

Yo Phone, Where You At? | A Simple SMS Based Find-My-Phone Solution

Weeks ago we were at dinner and I reached for my phone only to realize it wasn't in my bag. I had the usual stream of thoughts: it's probably at home. But what if it's not at home? What if it's lying in the parking lot, or otherwise lost? I could have logged into my Google Account on Shira's phone and used its find my phone feature to track down the device. But that would have been a significant disruption to dinner. I made a mental note to solve this problem later and hoped the device would be waiting for me when I got home. Fortunately, it was.

Then, a couple weeks later on on Reddit's /r/tasker I came across this post: Is there any way to text my location? Someone left a comment linking to a Where Are You task. Curious, I installed this task and was impressed: with one click I had installed an action that translated my current location into human readable form.

All that was left to do was to wire this task into an Event: Received Text Profile and I had a simple find-my-phone solution that would have put me at ease in the restaurant. For my first attempt at capturing Received Texts I made use of a Flash alert. This didn't work. Opting to write to a file instead of flashing text on the screen did work, as did my auto-text reply. I'm not sure why flashing text on the screen on this particular event fails, but I ultimately didn't need this for my solution.

The last piece of the puzzle is the credit card size backup phone I carry in my man-bag. The phone has basic text and call abilities and not much more.

Next time I find myself wondering where my phone is, I can bust out my backup phone and text myself LOC. If all goes well, a few seconds later I'll get a response from my phone with its current location. As a bonus, I've added Shira's phone number to the list of allowed numbers. So if she's sitting next to me, I don't even need to dig out my backup phone but can text from her device.

You can grab the code for this solution here, or recreate it using the screenshots below.

Tuesday, April 23, 2019

My Passover 2019 Reading List

We attended and hosted wonderful seders this year! Thanks to my brother and sister-in-law for hosting the first night and for giving me so much to (a) think about, and (b) to eat!

Below are a list of links I collected up as Passover approached. The usual happened: whenever I thought I'd read the last word on a topic I realized there was more to learn and a fresh perspective to be gained.
A fascinating timeline showing what parts of the seder come from what eras.
Thoughts on the B'nei Brak Seder
Source discussion of Rabbi Elazar ben Azaryah's comments about reciting the Exodus at night.
Transliteration of Red and Gold haggadah
Source from the Torah of story section of the haggadah
Suggestion: add a mirror to your seder plate for the Me Too movement.
Why do we spill drops of wine for the plagues?
Commentary that connects the book of Joel with the 10 plagues
Source from the book of Joel for linking the 10 plagues by text analysis.
Why do we include Rabbi's Judah's abbreviation?
Why aren't there more mentions of Moses in the haggadah?
Thoughts on Dayenu and so many plagues.
All about Rabbi
Is the seder a symposium?
Why were the first born killed?
Fresh perspective on a number of haggadah sections
Thoughts on Dayenu
Source text for Rabbi Gamliel's statements
Thoughts on Rabbi Gamliel's statements
Are blind people exempt from recounting the story of the haggdah?
Fresh perspective on a number of haggadah sections
Details about a 15th century haggdah
The hidden hero in the haggadah
Rabbi Sachs on Freedom
Torah laws on slavery
Frogs and Dogs
What do dogs have to do with Passover?

Monday, April 22, 2019

Imaginary News - A Failed Media Experiment

My sense is that everyday the political news gets more outlandish. Occasionally we hit what surely must be a high-water mark (say, Trump siding with Putin over his own intel community), but a few days later there's something new to be stunned about.

But is my sense correct? Or, is this merely me revealing my bias against the Trump administration?

I tried to imagine a concrete way of answering this question. One solution I came up with: pick a day of the presidency, say #97. Now, compare headlines and tweets from past administrations and Trump side-by-side. Ideally, you'd do this a number of times and a pattern should reveal itself.

Alas, I couldn't find a free news API that provided data going back more than a month. CNN, AP and Twitter all offer APIs, but none give access to the historic data I'd need to bring my idea to life.

I settled instead on Plan B. I used the conveniently named to build an Imaginary News site. That is, it picks a random day within the last 30 and searches the Washington Post and the Washington Times for Trump headlines. It then then generates a page substituting 'Hillary' and 'Clinton' for 'Donald' and 'Trump.'

You can try this for yourself here.

As a tool for detecting bias Imaginary News is a flop. It's little more than a political Rorschach test. If you think Trump is treated unfairly by the media, this tool proves the point. If you think this administration is generating scandals at an alarming rate, you'll see that too.

As a programming exercise, however, it was a worthy one. The API is easy to use and Just Works. There's no complicated setup or authentication, just signup and start making curl calls. You can see my code here.

Tuesday, April 16, 2019

A Handy Companion for the Classic Red and Gold Haggadah

With Passover quickly approaching, I've been on the lookout for interesting materials to share at our seder. One such discovery: a transliteration of the classic Red and Gold Rabbi Nathan Goldberg Haggadah that we use at our seder. I think this is a clever way to let those who don't read Hebrew participate in the festivities. For example, here's the transliteration of the 10 plagues:

The pages even match up to the 1963 edition of the Haggadah I grabbed off our shelf.

The publisher of Rabbi Goldberg's haggadah describe it so:

The definitive and most recognizable Haggadah in English. This has become the standard for most synagogues, schools, and homes.

Rabbi Nathan Goldberg's Passover Haggadah comes with an accessible English translation, clear instructions, and numbered lines so everyone can follow along in Hebrew or in English.

And from my perspective, this is true: it is the standard. It's the one I've been using my whole life. And yet, I can find no notable history of the haggadah on the web. Compare that to the similarly compact and universal text: the Maxwell House Haggadah. There's a colorful history associated with that text. Yet, the web is silent on old Red and Gold. How could this be? Could the Goldberg story really just be simple: it's an affordable, relatively easy to follow, simple text?

In a holiday so rich with meaning and minutia, surely we can't leave it at that. Can we?

Friday, April 12, 2019

The Embarrassingly Simple Source for An Up To Date Windows Version of emacs

I recently replaced my no-name mini PC with a might-as-well-be-no-name Kingdel NC860 mini PC. These fanless desktop computers have a great form factor, dual monitor support, plenty of USB ports and a bare-bones feel that I love. Credit goes to Coding Horror for inspiring my first purchase of this type of device.

I've recently switched from Firefox to Chrome as my primary browser of choice, and 1password as my password manager. The result: installing Chrome and logging in using both my Work and Personal e-mail meant that my web-based life was essentially setup. Installing Cygwin, Gimp and AutoHotKey meant that I had a nearly complete dev environment. All that was left to do was to install emacs.

At this point, I usually Google around to find the latest version of Windows friendly emacs, often ending up on this sourceforge site. On a whim, however, I thought I'd try something different: I installed emacs via cygwin.

My expectation was that I'd get a console only emacs. And my assumption was totally wrong. I ended up with the same Windows friendly emacs I'm used to, except a whole slew of issues had been resolved. I'm used to emacs operating in terms of Windows drive paths, while cygwin works in terms of a unix'y path mapping. By using a cygwin based emacs, the two environments are now in sync.

A number of issues with eshell were magically fixed, too. #! detection and signal handling (hitting Control-c) in eshell wasn't reliable in my old Windows emacs setup, whereas it's working well under cygwin based emacs.

Finally, the cygwin version of emacs is as up to date as the GNU site offers: version 26.1.

Why didn't I try this years ago?

It blows my mind that I can go from new PC to working dev environment in 15 minutes and zero dollars spent on software.

Friday, April 05, 2019

Dusting off my Microsoft Word Programming Skills

When it comes to programmatically working with documents, I'm all about Google Docs, Sheets and Slides. But I recently found myself needing to step over to the Dark Side and write some code to interact with Microsoft Word. After a quick Visual Basic for Applications (VBA) refresher, I managed to eek out the code I needed. Surprisingly, I found myself impressed by the capabilities VBA offers. The API is massive and appears to let you automate nearly everything related to Word Docs. I suppose being an ancient and archaic incredibly mature product has its benefits.

In the interest of leaving breadcrumbs for myself, or for helping some other soul who finds themselves needing to write some Word VBA code, I'm publishing a bit of test code I wrote while tackling my project. It's CS 101 level stuff: iterate through the currently selected table and display the max and min numeric values found. But given how rusty my VBA skills are, working through this example was quite helpful.

Here's the code:

Sub TableInfo()
    minVal = 0
    maxValue = 0
    Dim t As Table
    If Selection.Tables.Count > 0 Then
        Set t = Selection.Tables(1)
        For Each r In t.Rows

            For Each c In r.Cells
                v = Left$(c, Len(c) - 2)
                v = Replace(v, "$", "")
                v = Replace(v, ",", "")
                If IsNumeric(v) Then
                    If Val(v) > maxValue Then
                        maxValue = Val(v)
                    End If
                    If minValue = 0 Or Val(v) < minValue Then
                        minValue = Val(v)
                    End If
                End If
        MsgBox "Min: $" & Format(minValue, "##,##") & ", Max: $" & Format(maxValue, "##,##")
        MsgBox "You're not currently on a table."
    End If
End Sub

And here's a screenshot, note the new toolbar item I added:

You can download the Word file containing the code here. Happy Hacking!

Wednesday, April 03, 2019

One Big Gun, and Other Surprises Along DC's Waterfront

Everytime I think I've exhausted DC's esoterica, I'm reminded just how packed with random stuff this city is. Next time you're at a Nats Game, consider taking a less than a mile stroll along the pristine Anacostia Riverwalk Trail to 38.871800,-76.994906. Standing at these coordinates you'll be able to glimpse some truly remarkable Military hardware.

There's a Vietnam era Swift Boat you can approach and inspect:

Swift Boats have an unlikely origin story and played a critical role in Vietnam:

The U.S. Navy found what they were looking for in the Gulf of Mexico. Oil rig workers off the coast of Louisiana and Texas were shuttled to and from the rigs in strong aluminum boats built by Seward Seacraft Company of Louisiana. The taxi boats were sturdy, quiet and with a draft of 3 ½ feet, powered by two diesel engines with twin screws and speeds up to 28 knots. With the addition of weapons and living amenities, they were the perfect craft for patrolling the waterways of Vietnam.
Swift boats patrolled the waterways, interrupted enemy supply lines, and participated in complex insertion and extraction operations, while enduring monsoons, riverbank ambushes, mines laid by the Viet Cong, and difficult nighttime operations. Swift boat Sailors brought the naval fight inland and had a decisive role in the fight against the Viet Cong.

There's also the conning tower of the USS Balao, a WWII submarine. Despite earning 9 battle stars while operating during WWII, the sub's claim to fame is related to its movie, not military, career.

It’s real claim to fame came when Balao starred in the popular war comedy Operation Petticoat alongside Cary Grant.

The role itself was a little self-effacing. In the movie a Japanese bomber damages Balao and the submariners repairing it find they have nothing but red and white anti-corrosive paint. When they patch the sub up the gleaming new paint job is hot pink.

Audiences in 1959 screamed with delight at the prospect. The battle-hardened old sea salts of the U.S. Navy in pink? It was unthinkable. “We blushed when we asked for it and almost fainted when the Navy said okay,” the films producer explained in 1959.

Perhaps the most remarkable benefit of taking this walk is the opportunity to see "one of the largest artillery pieces in the world." That's right, parked among other employee vehicles is one of the few surviving World War I Railroad Guns. The 14"/50 caliber gun was originally deployed on battleships, but was mounted on a railroad car to help the Allies compete with German artillery superiority.

Mounting a big 'ol gun on a railroad car wasn't a WWI invention. This approach to fire superiority was conjured up during the Civil War:

The “railroad battery” was first used in Maj. Gen. George B. McClellan’s Peninsula campaign in 1862. Confederates bolted a 32-pounder Brooke naval rifle to a flatcar protected by an iron casemate, the finished car looking much like a land version of the ironclad CSS Virginia. It engaged in artillery duels before the Battle of Fair Oaks.

The Union used similar railroad mountings during the 1864 siege of Petersburg. The most famous of these was Dictator, a thirteen-inch seacoast mortar on an eight-wheeled flatcar. Lobbing 218-pound shells as far as forty-two hundred yards, this behemoth bombarded Southern batteries and bombproofs with telling effect.

While the lifespan of Railway Guns was relatively brief, for a time they were a dominant force:

Before the rise of bombers, missiles, and precision munitions, investments in railroad guns were perhaps justified. In World War I, the guns frequently proved to be fort-cracking artillery par excellence, and superb for long-range bombardment. By the 1930s, their days were numbered: armed forces turned to air power to shatter fortresses (and the guns themselves); to drop paratroops behind fortified lines; and to sever rail links, the guns’ umbilical cord. Ponderous size, camouflage difficulties, and logistical constraints all made the guns vulnerable to air attack. While a viable role remained for cannon artillery on many battlefields into the early twenty-first century, World War II’s end rang the death knell for super-heavy artillery, of which the railroad gun marked the apotheosis.

So did I find it, DC's most unusual site? Knowing this city, not by a longshot.

Tuesday, April 02, 2019

Grabbing an Ionic APK for the Truly Lazy

One of the micro annoyances I encounter with Ionic is the process of sharing an Android debug APK. After running ionic cordova build android I'm left with app-debug.apk under the android platform directory. Copying this file to the correctly named location isn't hard, but it always takes me a few extra heartbeats to do it right. Where's does the APK live again? Should I use _'s or -'s in the final name? What's the version of this app? and so on. Not hard, not even tedious, but always annoying.

I've done this enough that it was time to write a script to do the job. My strategy assumes that the location of the APK is constant and that the destination file name and version can be found in config.xml. Here's the script to grab the APK:


## Script to help with ionic dev


case "$action" in
    name=$(xmlstarlet sel -N x=  -t -v '/x:widget/x:name' config.xml)
    version=$(xmlstarlet sel -N x=  -t -v '/x:widget/@version' config.xml)
    cp -v platforms/android/app/build/outputs/apk/debug/app-debug.apk ~/dl/$name-$version.apk

    echo "Usage: {grab-apk}"
    exit 1

And here's what it looks like while running:

$ ionicassist grab-apk
`platforms/android/app/build/outputs/apk/debug/app-debug.apk' -> `/home/ben/dl/Foo-3.16.1.apk'

xmlstarlet is the obvious tool to use to grab info from config.xml. I'm always tripped up by the use of namespaces in the XML and XSLT, which meant writing the above script took a bit of extra debugging time. If nothing else, the above code is a helpful reminder to me as to how to navigate a document with namespaces.

Use and enjoy!


Related Posts with Thumbnails