How long until this nightmare is over?

I’m tired of this president already. What an awful combination of idiocy and cunning. To wit, just today from the Moron in Chief’s mouth:

This is more work than in my previous life. I thought it would be easier.

Jeebus.

Anyway, in anticipation of never having to hear about Trump every again, I wrote another little Chrome plugin yesterday. It tells you how many days until this is all over.

You can get it here: Trump Time Remaining

Normally, it’s just a little icon that tells you how much of Trump’s term remains. Here is it set to percent:

If you click on that icon, you get some more information:

That’s really all there is to it. You can change your reference date (election or inauguration) and you can adjust the expected number of terms (please, G-d, let it be just one), and you can change what is shown in the icon: days remaining, days passed, etc. Note that icons can only reliably show three digits, and we have more than 1300 days left, so days remaining may not work nicely in the icon on your computer.

So, how long until this nightmare ends? Well, 1362 days, give or day. Now you know.

 

ATIS in your kitchen

One ritual that every pilot observes before launching into the wild blue yonder (or dark gray muck) is tuning in the Automated Terminal Information Service, or ATIS. The ATIS is a recording, usually updated hourly, that contains a very terse version of the current weather and anything else new that pilots need to know.

ATIS is not the first weather information a pilot will hear before flying. In fact, it is more likely to be the last, after she has gotten a complete legal weather briefing (14 CFR 91.103), but before taking off.

A similar system, called AWOS (Automated Weather Observation System) is like ATIS, except that it usually only carries the weather (no other info) and always sounds like a robot.

As it turns out, I have a doohickey in my home that 1) can connect to the Internet to get the weather and 2) sounds like a robot. I thought, maybe it would be fun to write an app that simulates ATIS on an Amazon Echo.

Well, here it is.

This is a rather straightforward Alexa Skill. A user specified the airport of interest by using its four-letter ICAO identifier. Standard ICAO phonetics are supported.

For example, Chicago O’Hare’s IATA code is ORD, but its complete ICAO code is KORD. You could say:

Alexa, ask airport weather to get kilo oscar romeo delta.

And it would read you the weather in Chicago. The skill also knows the names of many airports and will try to fill in that fourth letter if you only give it three. For European users, you can get the visibility and altimeter settings in metric.

A few details of the skill:

  • written in node.js
  • Uses the Alexa Skills Kit API — Amazon handles all the voice stuff
  • Runs as a function in AWS Lambda
  • Accesses weather data from ADDS.
  • Stores user preferences in an AWS DynamoDB (a Mongo-like thingy)
  • Caches weather info from ADDS for up to 5 minutes to reduce load on ADDS
  • Whole thing runs in the AWS “Free tier” — which is important, as I’m not going to spend money to host a free app.

One of the more fun aspects of the project was getting to maximal verisimilitude. The ADDS weather source actually provides a METAR, which has a lot of the same information as does the ATIS, but it’s not entirely the same in form or content, so I had to do some translation and adjustment. For example, wind directions in METARs are true-north references, but in ATIS, they are magnetic-north referenced. In Northern California, where I live, that’s a 16.5° difference — not trivial. The program makes the adjustment based on the location of the airport and calculations from the World Magnetic Model.

So this METAR

 becomes:

 There is even code there to try to get the pauses and pacing to be realistic.

Anyway, code is not the cleanest thing I ever did. Such is the case when things start as personal hacks and turn into “sofware.” Check it out on github.

More instructions here: http://toolsofourtools.org/alexa-metars-and-tafs

 

Cultural variation in phalangeal deployment in the service conveying antipathy

I have a lot of thoughts about politics these days, but so does everybody else, right? So I will not write about politics.

Instead, I want to write about “the finger.” I’ve been giving the finger as long as I can remember. I probably learned it from my brother or sister, though, its use was heavily reinforced in social settings — at least those not policed by grown-ups.

I don’t give the finger very much these days, but I still enjoy seeing a good display. I noticed, recently, though, that there seems to be a lot of variation in how people give the finger, and I’ve become curious about it.

The gesture I learned, which I’ll call the “basic” finger requires that the middle finger be extended fully, and all the others be curled down as much as possible. This includes the thumb. It looks like these:

the_gesture021p5b3199

 

 

However, for a long time, I’ve been aware of an alternative interpretation of this gesture, which I will call the “John Hughes.” In this variation, the other fingers are not held down, but merely curled at the knuckles — sometimes only very slightly. The thumb may even be extended. In film, the person giving this gesture often wears fingerless gloves.

Here are some examples:

via GIPHY

 

14717243_10210240665588417_3905152048572238054_n

I actually find performing this variation rather difficult, as I cannot seem to get my middle finger to extend fully while the others are only bent. However, for my wife and many others, this is the default form — she does not associate it with the Chicago suburbs at all.

So, I ask you, my loyal readers, what’s going on? What drives this variation?

Some theories:

  • geography (soda / pop / coke)
  • class-based
  • disdain vs. anger

 

Does one skew more Republican and the other more Dem?

Are there more types out there? I realize that if you widen the scope internationally, there are many more variations, including the “V” and the thumb, but I’m mostly curious about the intra-US variation.

Trump: the disease

After last night’s embarrassing Clinton vs. Trump matchup, I’m once again feeling glum and confused. It caused me to reflect on a dichotomy that I was exposed to in high school: that of “great man” vs. circumstance. I think I believe mostly in circumstance, and maybe even a stronger version of that theory than is commonly proposed.

In my theory, Trump is not an agent with free will, but more akin to a virus: a blob of RNA with a protein coat, evolved to do one thing, without any sense of what it is doing. He is a speck floating in the universe, a mechanically fulfilling its destiny. A simulation running in an orrery of sufficient complexity could predict his coming.

This is his story:

Somewhere, through a combination of natural selection and genetic mutation, a strange child is born into a perfectly suited environment, ample resources and protection for his growth into a successful, powerful monster. Had he been born in another place or time, he might have been abandoned on an ice floe when his nature was discovered, or perhaps killed in early combat with another sociopath. But he prospered. With a certain combination of brashness and utter disregard for anything like humility, substance, or character, it was natural that he would be put on magazine covers, and eventually, television, where, because of television’s intrinsic nature, itself the product of a long, peculiar evolution, he killed, growing yet more powerful.

Later, perhaps prompted by something he saw on a billboard or perhaps due to a random cosmic ray triggering a particular neuron to fire, our virus started talking about politics. By chance, his “ideas” plugged into certain receptors, present in the most ancient, reptilian parts of our brains. Furthermore, society’s immune system, weakened through repeated recent attacks from similar viruses, was wholly unprepared for this potent new disease vector. Our virus, true to form, exploited in-built weaknesses to direct the media and make it work for its own benefit, potentially instructing the media to destroy itself and maybe taking the entire host — our world — in the process.

In the end, what will be left? A dead corpse of a functioning society, teeming with millions of new viruses, ready to infect any remnants or new seedlings of a vital society.

And the universe will keep turning, indifferent.

The end. 

Detrumpify2 — some cleanup

Even though my short brush with Internet fame appears to be over (Detrumpify has about 920 users today, up only 30 from yesterday), pride required that I update the extension because it was a bit too quick-n-dirty for my taste. Everything in it was hard-coded and that meant that every update I made to add new sites or insults would require users to approve an update. Hard-coding stuff in your programs is a big no-no, starting from CS 101 on.

So, I have a rewritten version available, and intrepid fans can help me out by testing it. You will not find it by searching on the Chrome Web Store, instead, get it directly from here. It is substantially more complicated under the hood than before, so expect bugs. (Github here, in “v2” folder.)

An important difference between this and the classic version is that there is an options page. It looks like this:

Screen Shot 2016-06-28 at 11.33.34 AM The main thing it lets you do is specify an URL from which a configuration file will periodically be downloaded. The config file contains the actual insults as well as some other parameters. I will host and maintain several configuration files ToolsOfOurTools, but anyone who wants to make one (for example, to mock a different presidential candidate) will be able to do so and just point to it.

If you want to make changes locally, you can also load a file, click on the edit button, make changes, and then click on the lock button. From then on the extension will use your custom changes.

The format of the config file is simple. Here’s an example with most of the names removed:

Explanation:

  • actions  is a container that will hold one or more named sets of search and replace instructions. This file just has one for replacing trump variations, but one can make files that will replace many different things according to different rules
  • find_regex  inside the trump action finds a few variations of Trump, Donald Trump, Donald J. Trump.
  • monikers  section lists the alternatives.
  • randomize_mode  can be always , hourly , daily , and tells how often the insult changes. In always , it will change with each appearance in the document.
  • refresh_age  is how long to wait (in milliseconds) before hitting the server for an update.
  • run_info  tells how long to wait before running the plugin and how many times to run. This is for sites that do not elaborate their content until after some javascript runs. (ie, every site these days, apparently). Here, it runs after 1000ms, then runs four more times, each time waiting 1.8x as long as the last time.
  •   bracket  can be set to a two-element array of text to be placed before and after any trump replacement.
  • schema  is required to ID the format of this file and should look just like that.
  • whitelist  is a list of sites that are enabled to run the extension. Et voila.

Let me know if you experience issues / bugs! The code that runs this is quite a bit more complex than the version you’re running now. In particular, I’m still struggling a bit with certain websites that turn on “content security policies” that get in the way of the config fetch. Sometimes it works, sometimes it doesn’t.

 

Detrumpify

nbc-fires-donald-trump-after-he-calls-mexicans-rapists-and-drug-runnersApropos of nothing, I have written a very simple Chrome extension (and a Firefox add-on) that replaces references to the Short-Fingered Vulgarian with any of several other aliases. The initial “seed” for the list came from Jezebel, which published a list of 70 such names for the Cheeto-Faced Ferret’s 70th birthday.

I really should take the time to make this plugin user-configurable, so that you can add your own insults.  However, that seems a lot of work for something that basically works ok as it is. If you want to see the (very simple) code, check it out here on Github. I’ll take pull requests. [Edit 7/6: have now done this and the link above points to the new version. Original version still available here.]

I plan to add new insults as I come across them (feel free to provide), at least through November 2016. If you have suggestions, please note that I’m only using family-friendly insults.

Enjoy!

 

 

PS — A few people have noted that the plugin doesn’t run on this or that website. That’s because it uses a whitelist of websites. I chose to do this to make the plugin as compatible and friendly as possible. It will run on the New York Times, but not on GMail, for example, nor will it interfere with your transactions at First National Bank of Trump. If you are running the current version, Detrumpify2, you can change that list yourself by adjusting the configuration file. If using the “classic” version, you’ll have to write me and ask to change it, and when I do, you’ll have to re-approve the plugin with the new permissions. Because of that, I’m going to try to avoid adding new sites to the “classic” extension too many more times.

 

Simulate this, my dark overloards!

Apparently, both Elon Musk and Neil deGrasse Tyson believe that we are probably living in a more advanced civilization’s computer simulation.

Now, I’m no philosopher, so I can’t weigh in on whether I really exist, but it does occur to me that if this is a computer simulation, it sucks. First, we have cruelty, famine, war, natural disasters, disease. On top of that, we do not have flying cars, or flying people, or teleportation for that matter.

Seriously, whoever is running this advanced civilization simulation must be into some really dark shit.

simple string operations in $your_favorite_language

I’ve recently been doing a small project that involves Python and Javascript code, and I keep tripping up on the differing syntax of their join()  functions. (As well as semicolons, tabs, braces, of course.) join()  is a simple function that joins an array of strings into one long string, sticking a separator in between, if you want.

So, join(["this","that","other"],"_")   returns "this_that_other" . Pretty simple.

Perl has join()  as a built-in, and it has an old-school non object interface.

Python is object-orienty, so it has an object interface:

What’s interesting here is that join is a member of the string class, and you call it on the separator string. So you are asking a "," to join up the things in that array. OK, fine.

Javascript does it exactly the reverse. Here, join is a member of the array class:

I think I slightly prefer Javascript in this case, since calling member functions of the separator just “feels” weird.

I was surprised to see that C++ does not include join in its standard library, even though it has the underlying pieces: <vector>  and <string>. I made up a little one like this:

You can see I took the Javascript approach. By the way, this is how they do it in Boost. Boost avoids the extra compare for the separator each time by handling the first list item separately.

Using it is about as easy as the scripting languages:

I can live with that, though the copy on return is just a C++ism that will always bug me.

Finally, I thought about what this might look like back in ye olden times, when we scraped our fingers on stone keyboards, and I came up with this:

Now that’s no beauty queeen. The function does double-duty to make it a bit easier to allocate for the resulting string. You call it first without a target pointer and it will return the size you need (not including the terminating null.) Then you call it again with the target pointer for the actual copy.

Of course, if any of the strings in that array are not terminated, or if you don’t pass in the right length, you’re going to get hurt.

Anyway, I must have been bored. I needed a temporary distraction.

 

Apple Open Letter… eh

[ Updated below, but I’m leaving the text here as I originally wrote it. ]

 

By now, just about everyone has seen the open letter from Apple about device encryption and privacy. A lot of people are impressed that such a company with so much to lose would stand up for their customers. Eh, maybe.

I have to somewhat conflicting thoughts on the whole matter:

1)

If Apple had designed security on the iPhone properly, it would not even be possible for them to do what the government is asking. In essence, the government plan is for Apple to develop a new version of iOS that they can “upgrade” the phone to, which would bypass (or make it easier to bypass) the security on the device. Of course, it should not be possible to upgrade the OS of a phone without the consent of a verified users, so this is a bug they baked in from the beginning — for their benefit, of course, not the government’s.

Essentially, though they have not yet written the “app” that takes advantage of this backdoor, they have already created it in a sense. The letter is therefore deceptive as written.

2)

The US government can get a warrant to search anything. Anything. Any. Thing. This is has it has been since the beginning of government. They can’t go out and do so without a warrant. They can’t (well, shouldn’t) be able to pursue wholesale data mining of every single person, but they can get a warrant to break any locked box and see what’s inside.

Why should data be different?

I think the most common argument around this subject is that the government cannot be trusted with such power. That is, yes, the government may have a reasonably right to access encrypted data in certain circumstances (like decrypting known terrorist’s phones!) but the tools that allow that also give them the power to access data under less clear-cut circumstances as well.

The argument then falls into a slippery slope domain — a domain in which I’m generally unimpressed. In fact, I would dismiss it entirely if the US government hadn’t already engaged in important widespread abuse of similar powers.

Nevertheless, I think the argument that the government should not have backdoors to people’s data is one of practical controls rather than fundamental rights to be free from search.

 

I have recommendations to address both thoughts:

  1. Apple, like all manufacturers, should implement security properly, so that neither they nor any other entity possess a secret backdoor.
  2. Phone’s should have a known backdoor, a one-time password algorithm seeded at the time of manufacture, and stored and managed by a third party, such as the EFF. Any attempts to access this password, whether granted or denied, would be logged and viewable as a public record.

I don’t have a plan for sealed and secret warrants.

 

[ Update 2/17 11:30 CA time ]

So, the Internet has gone further and explained a bit more about what Apple is talking about and what the government has asked for. It seems that basically, the government wants to be able to to brute-force the device, and wants Apple to make a few changes to make that possible:

  1. that the device won’t self-wipe after too many incorrect passwords
  2. that the device will not enforce extra time-delay between attempts
  3. that the the attempts can be conducted electronically, via the port, rather than manually by the touch screen

I guess this is somehow different than Apple being able to hack their own devices, but to me, it’s still basically the same situation. They can update the OS and remove security features. That the final attack is brute force rather than a backdoor is hardly relevant.

So I’m standing behind my assessment that the Apple security is borked by design.

If programming languages were exes

 

[ Please excuse this ridiculous flight of fancy. This post occurred to me yesterday while I was hypoxically working my way up Claremont on a bike. ]

An common game among the nerderati is to compare favorite computer languages, talking trash about your friends’ favorites. But what if programming languages were ex-girlfriend (or -boyfriends)?

Perl 5

Perhaps not the most handsome ex, but probably the most easy-going. Perl was up for anything and didn’t care much what you did as long as it was fun. Definitely got you in trouble a few times. Did not get jealous if you spent time with other languages. Heck, Perl even encouraged it as long as you could all play together. Perl was no priss, and taught you about things that you shouldn’t even describe in polite company. The biggest problem with Perl is that nobody approved, and in the end, you dumped Perl because everyone told you that you had to grow up and move on to a Nice, Serious Language. But you do wonder what might have been…

Perl 6

Never actually went on a date. Stood you up many times.

Python

Trim and neat, Python really impressed you the first time you met. Python came with a lot of documentation, which was a breath of fresh air at first. However, the times when Python’s inflexibility proved annoying started to mount. After one PEP talk too many, you decided to move on. You still remember that one intimate moment when Python yelled out “you’re doing it wrong!” Relationship- ender. Mom was disappointed.

C++

C++ seemed to have it all. It knew just about everything to know about programming. If you heard of some new idea, the odds were that C++ had heard of it before you and incorporated awhile back. You had many intellectual conversations about computer science with C++. Thing is, C++ seemed kind of rulesy, too, and it was hard to know what C++ really wanted from you. Most annoying, whenever you didn’t know what C++ wanted, it blamed you for not “getting” it. C++ also seemed to have a bit of a dark side. Sure, most of the time C++ could be elegant and structured, but more than once you came home to find C++ drunk and in bed with C doing some truly nasty things.

C

C is not an ex. C is your grumpy grandpa/ma who gives zero f@#ks what the kids are doing today. C is the kind of computer language that keeps a hot rod in the garage, but crashes it every time it takes it out. It’s a wonder C is still alive, given its passtime of lighting M-80’s while holding them between its fingers. Thing is, it’s actually pretty fun to hang out with C, someone who can tell good stories and get its hands dirty.

PHP

Looked a lot like Perl, just as promiscuous, but never said or did anything that made you think or laugh. Boring. Dumped.

Haskell

The weird kid in high school that sat alone and didn’t seem to mind be ostracized. Everything Haskell ever said in class was interesting, if cryptic. There was something attractive about Haskell, but you could never put your finger on it. In the end, you couldn’t imagine a life as such an outsider, so you never even got Haskell’s phone number.

Excel

Wore a tie starting in elementary school, Excel was set on business school. Funny thing was that beneath that business exterior, Excel was a complete slob. Excel’s apartment was a pig sty. It was amazing anything ever worked at all. Pretty boring language in the end, though. Went on a few dates, but no chemistry.

Java

Man, in the 90’s everybody was telling you to date Java. This was the language you could finally settle down with. Good thing your instincts told you to dodge that bullet, or you’d be spending your retirement years with a laggy gui for an internal app at a bank. Ick.

Javascript

You were never that impressed with Javascript, but you have to admit its career has taken off better than yours has. Seems Javascript is everywhere now, a celebrity really. Javascript has even found work on servers. At least Javascript is not hanging out with that ugly barnacle, Jquery as much as it used to.