Skip to content

Instantly share code, notes, and snippets.

View prmichaelsen's full-sized avatar
🌚

Patrick Michaelsen prmichaelsen

🌚
  • Phoenix
  • 06:19 (UTC -06:00)
View GitHub Profile
@prmichaelsen
prmichaelsen / formatLetterGrade.ts
Last active July 4, 2022 07:37
formats letter grades using [threshold, character] pairs
#!/usr/bin/env ts-node
const thresholds = [
90,
80,
70,
60,
0,
];
/**
resources referred when writing this script:
- https://gitlab.com/MPuschi/lotr-skip/-/blob/main/skip.js
- https://codepen.io/wellingguzman/pen/XqYqmG
- https://stackoverflow.com/questions/5235145/changing-source-on-html5-video-tag
*/
// Create Video and Canvas-Element
var canvas = document.createElement("canvas");
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "$id$",
"description": "WidgetGroupConfig_2-15",
"type": "object",
"additionalProperties": false,
"required": [
"widgetGroupId",
"cti",
"configurations"
F
E
Am
Dm

[verse 1]
ive got
F
two cats sleepin around in this
# script
# the king
# tags power

EXT. DAY - a country side manor

-
scene:
chickens forage,

Some text

some text that should be styled as a quote, but no larger a font than normal text

Some more text

Opinion

Stop making text in your applications unselectable.

Copying and pasting is one of the most common things a user will do to any text you display in your application. Here are some things that applications do that make this difficult or impossible:

  • override mobile select function to select entire "blocks" of text for copying, for instance, news articles.
  • trigger some action on click, such as expanding a table row or launching an edit modal on click. Another example is launching a directions app on address click.
  • misusing the input html element to display summary text by adding "disabled" and therefore stopping a user from selecting the text
function getParticipantNames() {
// Because queries are cached, using the `allParticipants` query
// prevents another roundtrip to the database
const participants = database.getAllParticipants();
return participants.map(p => p.name);
}
function getParticipantNames() {
const participants = database.getAllParticipants();
return participants.map(p => p.name);
}

The Myth of Self Documenting Code

Or, how I learned to stop worrying and love the comment.

This article is a response to Joe Eames' article on self-documenting code. If you haven't read it yet or aren't familiar with the concept of self-documenting code, please check out the article [here][3].

I consider self-documenting code to be a myth and perpetuating it to be dangerous (especially to new programmers).

Before we get into why, let me summarize the two primary arguments for sefl-documented code:

  1. Comments that explain what the program are doing are redundant. As code changes, comments can also become out-of-date and stale, making the code harder to maintain overall.