USB-C is a Mess

The graphic below is care of Adafruit and it reveals that we still have a long way to go when it comes to USB-C being the “one cable to rule them all.”

USB-C specifications laird out in a table

Trust the People Who Do the Work

I do occasionally read in the business press, like the Inc. article linked below but also Forbes, Fast Company, and _Bloomberg. As an academic who spent some time in the business world, I think the chance to think about things from different perspectives is important, and I am especially curious about the evolving culture of business(es) as the world around us changes. I was especially struck by Inc.‘s coverage of Siemens’ new remote work policy, which comes down to two things:

  1. Focus on outcomes rather than time spent in the office.
  2. Trust and empower your employees.

This is based on Siemens assertion, to itself if no one else, that if you don’t trust your employees, then you are hiring the wrong people.

Article Link.

The Teenager’s Use of the Present Participle

Teenagers, or perhaps just my teenager, appear either not to have a grasp of what the present participle means or to have a far more expansive view of the present than I do. In our household, the teenager regularly proclaims “I am doing X” when she is patently not doing X nor even remotely in a position to start doing X. Thus, either the teenager does not understand what it means to “be in the process of” doing something OR, and here is where I think I may have made a breakthrough in my understanding, the teenager’s conception of time is fundamentally different from mine, and perhaps yours too, dear imbiber of Facebook posts. For her, the present in the present participle is an expanded horizon which clearly has concentric circles of “doingness” thus allowing her to be “doing X” even though she clearly not even considered it yet. This is the outer circle of “doingness”, the one in which the world, possibly a parental unit, has pushed an action into the awareness horizon, but it is so far away, the circle so distant, that any particular awareness is not yet triggered until the world, which may or may not be the parental unit speaking a bit more urgently now, has registered a second request — because what more can the world do but request? and it should be happy that you are even feeling receptive this fine day. This is a fuzzy boundary to be sure, one in which an action can be considered not to have actually have an existence yet since it is available to be negated by the simple rebuttal of “I didn’t hear you.” But whether the request if the first or the second, or perhaps is now made manifest by the parental unit suddenly appearing directly in your view, perhaps even blocking your way so that, no, you cannot continue to “vibe” to your current favorite song, the incipient action has perhaps moved more centrally in that it is now something you are considering and your consideration is, in fact, a form of doing. And, really, shouldn’t the peons, and by that you mean the parental units, be grateful for that? I mean, honestly, you’ve done quite a bit and you are exhausted by this processing of the request to “do X” and so maybe now is a good time to do something else…

Git and GitHub

Fateen Alam has compiled a terrific Notion page that provides overviews of version control, setting up and using git, and then using GitHub: Git and GitHub. (Notion is one of many new entrants into the note-taking app/system/omnibus category.)

Scott’s Cheap Flights

I subscribe to Scott’s Cheap Flights, mostly for aspirational reasons, but even if me and my family travel relatively rarely, the service has still saved us more than its cost of subscription in the past few years. A recent email included this reminder about optimizing your chances of finding a great deal:

Things that actually will help you get a better price: searching in the Goldilocks window (2-8 months for international flights and for 1-3 months for domestic), searching flexible dates, avoiding peak travel times, and acting fast when you find a great deal.

The link in the quotation is to a page on their website that has more details.

Gaming M/Disinformation

One of the things I had hoped to do in the next semester or so is to create a simulation of some kind that let students in my classes see for themselves how information cascades through various kinds of networks.

My idea was to build on top of some simulation/modeling scenarios I had found in order to model/simulate the way information moves into and out of various kinds of networks — and here I mean not only the kinds of networks we once considered to be social groups but also the two distinct networks that now occupy our lives: offline (aka oral, face-to-face) and online networks.

An /r/science subreddit thread collects up a number of games focused on disinformation, collected here for ready reference:

  • Harmony Square is based on “inoculation theory”: that exposing people to a weak “dose” of common techniques used to spread fake news allows them to better identify and disregard misinformation when they encounter it in future (University of Cambridge press release. More on the game can be found in this article in Misinformation Review. (MR is published by the Harvard Kennedy School.)
  • Headliner: NoviNews is an “adventure where you control the news and its impact on society, your friends and career. Different choices lead to unique combinations of endings.” Right now it’s part of Steam’s “Bundle of Consequences,” which includes four other titles where you play the grim reaper, Death & Taxes; a digital voyeur, Do Not Feed the Monkeys; someone interned in a relocation camp, Not Tonight; and a border control agent, Papers Please. (Let the dystopian games begin?!)
  • In Orwell: Keeping an Eye On You, “Big Brother has arrived – and it’s you. Investigate the lives of citizens to find those responsible for a series of terror attacks. Information from the internet, personal communications and private files are all accessible to you.”
  • NewsFeed Defenders is a clearly educational game that puts users in charge of a fictional social media site focused on news and information: “Your mission? Maintain the site, grow traffic, and watch out! You’ll also need to spot fake posts that try to sneak in through hidden ads, viral deception, and false reporting.”
  • In Bad News users “take on the role of fake news-monger. Drop all pretense of ethics and choose a path that builds your persona as an unscrupulous media magnate. But keep an eye on your ‘followers’ and ‘credibility’ meters. Your task is to get as many followers as you can while slowly building up fake credibility as a news site. But watch out: you lose if you tell obvious lies or disappoint your supporters!”
  • Go Viral appears to be the simplest of the lot, billing itself as “a 5-minute game that helps protect you against COVID-19 misinformation. You’ll learn about some of the most common strategies used to spread false and misleading information about the virus. Understanding these tricks allows you to resist them the next time you come across them online.” Interestingly, they link to an article in the Journal of Cognition: Good News about Bad News: Gamified Inoculation Boosts Confidence and Cognitive Immunity Against Fake News.
  • There is also The Westport Independent “a censorship simulator taking place in a post-war country, governed by the recently elected Loyalist Party.As the editor of one of the last independent newspapers in the country, your job is to remove and edit the content of your paper, affecting the people’s opinion of both the rebels and the Loyalist government.”

I plan on exploring these games/simulations over the holiday break, and I hope to post notes on their game play and how well they both achieve the goals they set for themselves and how well I think they capture the nature of information flows on- and offline.

Cognitive Biases

Your Bias Is compresses 24 cognitive biases into a very small user interface. The definitions are very brief, but it may be useful as a way to introduce people to the notion of cognitive bias. A PDF and a poster of the biases are also available as well as other materials.

Compare Lists in Python

If you search for how to compare two lists in Python, you will find a lot of helpful pages in a lot of places, many of which assume you are working with numbers or you want exact matches. But what if you want to compare all the items in one list with all the items in another list and you want to be able to set some arbitrary measure of similarity or difference?

The problem arose for me recently when I was trying to compare two lists of different lengths. The two lists represented keyword sets derived from a corpus using NMF, which I had run with two different component values. As part of wanting to discover a probable “best fit” I wanted to compare which strings had remained the same and which had changed to some degree.

My first impulse was to try the Jaccard coefficient, and I used some simple code to make that work:

def jaccard_similarity(query, document):
    intersection = set(query).intersection(set(document))
    union = set(query).union(set(document))
    return len(intersection)/len(union)

I then embedded that bit of code, but it could be any code you wanted, in the following:

for jk, jv in enumerate(second_list):
    for ik, iv in enumerate(first_list): 

The logic is pretty simple, but it is a leap, at least for me, in terms of how I think about things. When I started work on this, I kept trying to pack everything in one for loop: after all, I wanted to compare one list to another. But I wanted to compare all of one list with all of another list, which means I needed to iterate through both lists. A simpler version of this would be:

for j in second_list:
    for i in first_list:

The addition of enumerate above was so that I could keep track of which string in each list was matching without necessarily having to see the string itself — I could use the index values that enumerate produces to call those, if I needed. enumerate is one of those functions I regularly forget, and it is very convenient: essentially it takes a list of items and transforms it into a list of tuples where the first value is the item’s index and the second value is the item itself, so [‘a’] becomes [(0,’a’)]. You can call the parts of the tuple by any variable name you like, but I tend to stick with k and v, for key and value, because … well, because. (It could easily be anything else, and I’ve even written code that called three-item tuples with rather bland, and thus also not advisable, t, u, v. Do not do this.)

So essentially both the for loops above are transforming each of the lists involved into a list of tuples and then walking through the list, comparing the items themselves but reporting only their indices.

It doesn’t really matter which list is which, so far as I can tell, so long as you keep the variables correctly aligned. My final code block looked like this:

print("Jc = Jaccard coefficient")
for jk, jv in enumerate(topics_45):
    for ik, iv in enumerate(topics_35):
        if jaccard_similarity(iv.split(" "), jv.split(" ")) > 0.5:
            print(f"35-{ik} and 45-{jk} have a Jc of {jaccard_similarity(iv,jv):.2f}.") 

My next step is to determine how to transform this into a network or tree so that I can see which keyword clusters continues (relatively) unchanged — where I set the threshold for relatively (and perhaps end up using something other than the Jaccard coefficient which doesn’t seem terribly discriminating — and also where clusters split or, in a few cases, disappear/die.

These Books

At least two newsletters arrived in my inbox this week using this stock photo of books. I’ve seen the image used elsewhere, but seeing it twice on the same day made me wonder “Whose books are these?” @ me on Twitter if you know.

The Power of a bash Script

Every time I run it, I am delighted by how much work the bash script for the COVID dashboard works.

~ % sh ./
remote: Enumerating objects: 35, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 29 (delta 18), reused 5 (delta 2), pack-reused 0
Unpacking objects: 100% (29/29), done.
   3ad1afa..f06d614  master     -> origin/master
Updating 67b320c..f06d614
Fast-forward            |     2 +-
 live/us-counties.csv |  6395 ++++++++++++------------
 live/us-states.csv   |   110 +-
 live/us.csv          |     2 +-
 us-counties.csv      | 12803 ++++++++++++++++++++++++++++++++++++++++++++++++-
 us-states.csv        |   226 +-
 us.csv               |     6 +-
 7 files changed, 16287 insertions(+), 3257 deletions(-)
INFO    -  Cleaning site directory 
INFO    -  Building documentation to directory: /Users/johnlaudun/Developer/COVID-Acadiana/site 
INFO    -  Documentation built in 0.10 seconds 
~ %

I will admit that the dashboard is still primitive, but the idea of it was what was important at the time, and so many dashboards have popped up since then. I mostly keep running the script for a sense of the historical depth it provides.

Quick Labels with Python’s f-string

Sometimes I need a list of titles or labels for a project on which I am working. E.g., I am working with a toy dataset and I’ve created a 10 x 10 array and I want to give the rows and columns headers so I can try slicing and dicing. I prefer human-readable/thinkable names for headers, loc over iloc in pandas-speak. And this one-liner works a treat, as they say:

labels = [label{item}' for item in range(1,11)]

Done. Place it into your dataframe creation (as below) and you are good to go.

df = pd.DataFrame(data=scores, index=names, columns=labels)