Collected TILs
By: . Published: . Categories: today-i-learned. Tags: tips tools how-tos.This post collects a number of “Today I Learned” messages I’d previously sent into a Slack workspace.
Git
-
TIL: Two ways to change git’s default comment handling so I can write Markdown headings:
- Use the –cleanup flag for git commit to set a different cleanup approach, like git commit –cleanup=scissors
- Change the comment character to something else with git config core.commentChar ; https://stackoverflow.com/questions/2788092/start-a-git-commit-message-with-a-hashmark
-
TIL: You can ask git to show a file as of a specific version
REVSPEC
, andless
to add line numbers and jump right to your target line, like so:git show REVSPEC:PATH_RELATIVE_TO_GIT_ROOT \ | less -N +164g
-
TIL: how to see a merge’s conflicts & resolutions: if
hash
is the merge commit, run eithergit diff hash hash^1 hash^2
orgit diff-tree --cc hash
. (for me, former will paginate, latter will not.) -
TIL: I could have just aimed
core.hooksPath
to a shared hook folder, rather than linking-in myprepare-commit-message
hook script to many folders. (Though I do wonder if Husky handles that bit of git configurability at all.) -
TIL: git comes with a perl module, and git add –interactive (and so –patch) is a perl script.
why did i learn this? because i wondered how to sniff the comment char in use. even the git perl module punts and falls back to
#
when it’sauto
, though. -
TIL:
git whatchanged
is a thing. it’s likegit log --name-status
only less typing, and with file modes in your face. -
TIL: VSCode’s GitLens has a “heat map” feature that shows Edit Wear in your editor.
-
TIL: to force an update with pull without it trying to do some derpy merge, i can
git fetch
thengit reset --hard FETCH_HEAD
, without needing to worry about what the actual branch name is that i’m on. -
TIL: Mercurial has a nifty “ignore this reformatting” cue to its blame engine. throw
# skip-blame reason
in the commit message, andhg praise
will ignore that commit.a sub-issue of adding all the
b
prefixes and reformatting code is that it would break annotate/blame more than was tolerable. The latter issue was addressed by teaching Mercurial’s annotate/blame feature to skip revisions. The project now has a convention of annotating commit messages with# skip-blame <reason>
so structural only changes can easily be ignored when performing an annotate/blame.https://gregoryszorc.com/blog/2020/01/13/mercurial%27s-journey-to-and-reflections-on-python-3/
-
TIL:
git blame
since v2.23 can ignore a list of commits. pass the list one-by-one with--ignore-rev=REV
, or en masse with--ignore-revs-file FILE
, which admits comments. you can automate the process by configuringblame.ignoreRevsFile
; a popular filename is.git-blame-ignore-revs
. (i went looking for git functionality after the hg one and found this summary.) -
TIL: git log at last applies the
.mailmap
rewrites previously only applied by shortlog. ah, a tidy history. -
TIL: to list your branches ordered from most-recently committed to to least:
git branch --sort=-committerdate
(handy when you need to go 2 branches back, so can’t just use
git checkout -
) -
TIL: how to word-wrap commit messages in Fork: Preferences > Show page guideline then Right click on commit description field -> Wrap Paragraph at Ruler https://github.com/ForkIssues/Tracker/issues/879
GitHub
-
TIL: you can use .gitattributes to fix up weird language use listings on GitHub https://github.com/github/linguist/blob/master/README.md#overrides
- fixes: x is language Y: someGlob linguist-language=Y
- ignores: treat x as vendored, generated, or docs: someGlob linguist-{vendored,generated,documentation}=true - or just skip detecting it for whatever reason: linguist-detectable=false
- missed: x should be considered detectable linguist-detectable=true
-
TIL: there are a lot of restrictions on code search on github, which is why its code search always seems so lousy next to cloning and searching locally https://help.github.com/articles/searching-code/#considerations-for-code-search
-
TIL: if you use AsciiDoc on GitHub, you can just write :toc: to get a table of contents. beats the pants off manual doctoc’ing!
-
TIL: github knows how to attribute commits to multiple authors via a
\r\rCo-authored-by: NAME2 <EMAIL2>\rCo-authored-by: NAME3 <EMAIL3>\r…
convention in the commit message body. https://help.github.com/en/articles/creating-a-commit-with-multiple-authorsvia: https://tuple.app/pair-programming-guide/template#4-configure-git-to-share-credit
-
TIL: github has pretty nice web preview for CSV files. renders as a table, bolds the first line, and lets you search within the table.
-
TIL: github now supports multiple issue & pr templates. but really, i’m just here to link you to a CYOA template builder: https://www.talater.com/open-source-templates/#/
-
TIL: if you fork a GitHub repo using large file storage, the parent repo gets to pay for all the storage & bandwidth.
- note to self: never GLFS in a public repo.
In forks, bandwidth and storage usage count against the root of the repository network. (https://help.github.com/en/articles/about-storage-and-bandwidth-usage)
Trivia
-
TIL: The origin story of Hamcrest (an anagram of “matchers”): Folks wanted to use jMock2’s Matchers in production code, but felt weird having to pull in a test-centric lib as part of their prod code. http://www.natpryce.com/articles/000662.html
-
TIL: Lewis Carroll found a workaround for burning the midnight oil. “Carroll invented Nyctography because he was often awakened during the night with thoughts that needed to be written down immediately, and didn’t want to go through the lengthy process of lighting a lamp just to have to extinguish it shortly thereafter. (https://en.wikipedia.org/wiki/Nyctography)"
-
TIL: the US actually minted some half-cent coins https://en.wikipedia.org/wiki/Half_cent_(United_States_coin)
-
TIL: JIRA is a shortened form of “Gojira” derived after riffing on Bugzilla https://confluence.atlassian.com/pages/viewpage.action?pageId=223219957
-
TIL: Poor ventilation in conf rooms can have cognitive impacts:
three people quietly sitting in a mid-size conference room produced CO2 levels that within 60 minutes, reached concentrations high enough to impair their ability to make the right decisions. In a corporate world where Directors regularly pile into closed-door conference rooms for hours on end, making the most important planning decisions for their companies, this was a disturbing realization. (http://blog.gigabase.org/en/contents/132)
-TIL: inst, ult, and prox http://worldwidewords.org/weirdwords/ww-ult2.htm (this month, last month, next month). they were disturbingly common in 19th century business letters, and shorthand learning materials of the same period. “i am in receipt of your esteemed favor of 13th ult.”
-
TIL: you can get little bumpers for your keys to deafen the thunderous typing. everyone i video call with will benefit from this. >.<
-
TIL: “to be across” is Aussie biztalk for “know about, be informed of, understand” or similar https://english.stackexchange.com/questions/122379/usage-of-to-be-across
-
TIL: How to use Seyès paper: caps go up 3, loops go up 3, sticks go up 2, x-height is 1, stick descenders down 1, loop descenders down 2. https://www.crapaud-chameau.com/2017/04/apprendre-a-bien-ecrire-en-cursive.html (the vertical lines are tabstops, if you’re laying out tables)
-
TIL: sometimes a pug is a moth https://en.wikipedia.org/wiki/Foxglove_pug
ominous:
Soon after hatching it seals the mouth of the flower with silk and feeds on the reproductive parts of the flower.
-
TIL: “After many incidents of serious flooding throughout the 19th century, the owners of the two-, three-, and four-story buildings in Sacramento simply abandoned the ground floors and constructed raised sidewalks level with the first floor. Over the years the roadways were also raised to just below the new sidewalk level, effectively elevating the entire town.” https://www.atlasobscura.com/places/the-original-street-level-of-sacramento-sacramento-california
h/t David M. Deller
-
TIL: some new sales jargon:
- PBO: positive business outcome
- EB: economic buyer - the person who can release funding to pay for your services
- RC: required capabilities - skills/resources needed to reach a PBO
- proof point: a fact you can point to to support a claim about your capabilities and differentiators, such as a case study or customer reference
(most of these seem pretty self-explanatory to me, but that someone is motivated to abbreviate these specific things vs others makes me re-evaluate the importance of those terms, and my fluency with them, in sales thinking.)
-
TIL: https://en.wikipedia.org/wiki/Kin-Ball is a thing. 48-inch ball, three teams on the floor.
-
TIL: there’s a book of quotes roasting french authors, the “dictionary of literary insults” https://www.amazon.com/Dictionnaire-Injures-Litteraires-French-Chalmin/dp/2253162361/
“Mallarmé, untranslatable, even in French”
-
TIL: “ratioing”: when you get twice as many replies as retweets. https://www.merriam-webster.com/words-at-play/words-were-watching-ratio-ratioed-ratioing
(if anything ever said “twitter is not a platform for discussion”, considering replies as a negative may be that…)
CLI Fun
-
TIL: a bash
for
loop defaults to iterating over the positional arguments if you omit thein
part. thanks, perplexing example from getopt(1)!also, argparsing in bash is bad enough that https://argbash.io/ to generate all the boilerplate for you exists.
there’s also a bash-builtin
getopts
vs standalonegetopt
utility low-stakes holy war apparently. i’ll chuck that in the bin next to emacs vs vi and tabs vs spaces for a later date. -
TIL: Bash will only load aliases in an interactive shell, not just a login shell:
bash -lc "some-alias"
gives “bash: some-alias: command not found”.bash -ilc "some-alias"
works a treat.
-
TIL: the “run alpine/socat to bridge to an exposed but unpublished container port” Docker trick. lets you basically retroactively publish it without having to re-run the container with new config. See: https://stackoverflow.com/a/49903374/72508 (which may have my edits applied already)
-
TIL the xnu kernel has 3 flavors of use-after-free detection in addition to its own guard malloc support. neat subsystem. :)
-
TIL: If all else fails for entering something into vim, you can use
Ctrl-V u codepoint
to enter it interactively, or if you’re composing a regex, you can encode it using something like\%u1234
. (That last one is handy for copy-paste or scripted use.)and you can re-learn the first one in
:help unicode
or more specifically:help utf-8-typing
, and the second one in:help regex
, specifically:help pattern-overview
. (as i have done several times now. here’s hoping TILing it makes it stick. >.<) -
TIL: ld (the linker) still has cool tricks up its sleeve. ld can just…wrap a binary into a .o with start and end pointers as its symbols: embedding binary objects in c
-
TIL: Powershell aliases
wget
andcurl
toiwr
akaInvoke-Web-Request
. That plus help is enough to nudge you the right direction.
Postgres
-
TIL: DBFiddle is a thing. gives you an online workbench/demo of querying using a specific DB engine, like jsfiddle, but for databases.
-
TIL:
allballs
is a special value that Postgres hardcodes to the UTC time of day 00:00:justkeepwriting0 https://www.postgresql.org/docs/8.3/datatype-datetime.html#AEN5025 (edited) -
TIL: using
psql
variables (h/t Liv Vitale for prompting me to review this)\set variable [blah…]
– create or update a variable. multiple args will be concatenated. no arg sets to empty string or, for control variables, is equivalent to\set VAR on
.\echo :variable
– view the value of that variable\set
– view all variables and their values:{?variable}
– returns TRUE if variable exists, FALSE if not:'variable'
– quoted as a literal, such as a string or number:"variable"
– quoted as an identifier, such as a table name\unset variable
NOTE: psql reserves variables comprising only uppercase alphanumerics. stick to lowercase and you’ll be fine.
Bulk insert trick:
\set content `cat my_file.txt` INSERT INTO my_table VALUES (:'content');
References: https://www.postgresql.org/docs/11/app-psql.html#APP-PSQL-VARIABLES https://www.postgresql.org/docs/11/app-psql.html#APP-PSQL-INTERPOLATION
Webdev
-
TIL: TypeScript’s
Record<KeyType, ValueType>
can be used to statically require an enum lookup table be exhaustive. https://www.typescriptlang.org/docs/handbook/advanced-types.html#mapped-typesso this enum decl + incomplete map declared as a Record:
export enum EventCode { Click = 'email_click', Reply = 'email_reply', } export const Color: Record<EventCode, string> = { [EventCode.Click]: 'purple', }
produces a compiler error due to the missing enum case:
EventCode.ts:24:14 - error TS2741: Property
'email_reply'
is missing in type'{ [EventCode.Click]: string; }'
but required in type'Record<EventCode, string>'
.24 export const Color: Record<EventCode, string> = { ~~~~~
-
TIL: you can do all kinds of evil things with VSCode tasks (like rig ‘em up to ssh into a vagrant vm and run a docker exec command to trigger your tests)
-
TIL: android chrome, when typed into using google’s software keyboard, doesn’t on providing any meaningful info on the key pressed to
onkeydown
andonkeyup
, which sure seem like they ought to be getting some info about a key. the events are still sent, but not anything about the keys involved. further eroding the foundations on which my precarious frontend web reality is built. https://bugs.chromium.org/p/chromium/issues/detail?id=118639#c261 -
TIL: typescript can smartly narrow the type after type-checking the discriminator in a discriminated union, but only if the discriminator is a single type in each branch. it’s not smart enough to handle a union in one case.
so this plays nice:
@typedef { {flavor: 'date', value: Date} | {flavor: 'time', value: Date} | {flavor: 'text', value: string} } Filter
and you get this desirable smartcast behavior:
if (it.flavor === 'date') { /* now it.value is a Date here */ }
but this otherwise equivalent version does not:
@typedef { {flavor: 'date' | 'time', value: Date} | {flavor: 'text', value: string} } Filter
in this case, you get:
if (it.flavor === 'date') {/* it.value is still 'date' | 'time' | 'text' :( */ }
-
TIL: OpenAPI specs can handle XML pretty well these days. you can rename something by adding a child
{xml: {name: 'whatevs'}}
, and flag a property as an attribute with{xml: {attribute: true}}
. https://swagger.io/docs/specification/data-models/representing-xml/ -
TIL: how YAML’s many string syntaxes play out in practice through a convenient single-issue site: https://yaml-multiline.info/
(In the past, I’ve looked at https://camel.readthedocs.io/en/latest/yamlref.html. That’s still really valuable for YAML in general, but for string formatting, this new site is much more to the point.)
Slack
-
TIL: Slack now reminds you of the other party’s current time in a DM. (Not in a group DM, though, so ping the heck out of a combined Pacific and Mountain Time crowd at 0900 Eastern if you want.)
-
TIL: In Slack,
/remind snooze DURATION
is a thing. should be handy for my next pto. -
TIL: slack will keep a specific whitelist of apps alive even after the member who wired them into a workspace leaves. this whitelist includes mission-critical apps like CI, performance alerting, communication tooling, and the one your workspace clearly cannot survive without for even a second: giphy. >.> https://slack.com/help/articles/360000446446-Manage-deactivated-members-apps-and-integrations-Manage-deactivated-members-apps-and-integrations
-
TIL: that Slack finally added actual hyperlinks. (at least with their new text editor - not with markdown.) the niftiest way is to select a region of the message you’re editing, then paste a URL to linkify it.
-
TIL: creating a scheduled time and date workflow in Slack is dead easy. (but you can’t use the fancy new markup in the messages you send from a workflow, so no pretty hyperlinks, alas. and unlike with reminders, mentions don’t work, so no @here to wake up the channel for a scheduled meeting.)
-
TIL: the secret slack shortcut to pick up a search where you left off is Cmd-g:
When you find yourself in a situation where you need to return to a recent search, a function you may find useful would be to use the keyboard shortcut: CMD+G. This shortcut opens the previous search results screen if there was a cached search within the last 5 minutes. If there is no recent search cached, the search window will be pulled up blank for a quick clean search.
-
TIL: Cmd-. opens/closes the right sidebar in Slack. (Not what I would have guessed, being used to that keycombo’s “cancel current operation” classic Mac mapping.)
(There’s no menu item, but at least this one is actually doc’d in the in-app Cmd-? list, unlike the Cmd-g one to reopen the search dialog with the contents of a recent search.)
Other Software
-
TIL: If you click on a label swatch in Trello, they expand to show the text for the label on the cards. So much more readable at a glance!
-
TIL: Exchange encrypted messaging is darn clever. “Non-Office 365 message recipients can authenticate and read protected messages using their consumer Google or Yahoo accounts, in addition to a One-Time Passcode and a Microsoft account.” (you click a link in the email, get bounced to a webpage, auth, and boom, there’s your message) https://products.office.com/en-us/exchange/office-365-message-encryption
-
TIL: how to boss jira around with commit messages like i do pivotal: https://confluence.atlassian.com/jirasoftwarecloud/processing-issues-with-smart-commits-788960027.html
(didn’t know you could do that with pivotal, either? check out https://www.pivotaltracker.com/help/articles/github_integration/#using-the-github-integration-commits )
want to automate that by copying it in from the branch name? look into the
prepare-commit-msg
git hook -
TIL: Vivaldi has named tab session support https://help.vivaldi.com/article/session-management/ (resembles tab groups in firefox when uing the simple tab groups extension)
-
TIL: i misunderstood SalesForce relative date filters - the relative times are ranges, not instants:
- mistaken instant interpretation: i thought “date < NEXT 3 WEEKS” meant “date is before 3 weeks from now”, which would include events happening during the next 3 weeks. :x:
- but actually “date < NEXT 3 WEEKS” means “date is before the time range beginning midnight of the first day of next week and stretching for the 3 weeks after”, so “< NEXT 3 WEEKS” actually means “does not happen during the next 3 weeks.” !
(= with these ranges acts like “falls in” or “is during”, so trading < out for <= fixed my reporting bug.)
-
TIL: you can get focus follows mouse on macOS if you use voiceover. Open VoiceOver Utility, pick Navigation from the sidebar, then check “Synchronize keyboard focus and VoiceOver cursor” and pick “Mouse pointer: Moves VoiceOver cursor”.
-
TIL: zoom supports chatbots for zoom chat https://marketplace.zoom.us/docs/guides/chatbots/sending-messages
-
TIL: if you search for “followup:actionitems” in Drive, it’ll list all the docs with comments assigned to you for action.
-
TIL: Pro Mouse’s overlays survive screensharing, so if you regularly need to do callouts on your screen, that might be handy. h/t Jacob Bullock
-
TIL: how to submit a Cigna Vision claim online. “Find a Form” only gives you a paper PDF. instead:
- log into cigna.com
- select Coverage > Vision
- Visit Cigna Vision
- select tab Claims & Reimbursement
- expand the third accordion, “Customer Reimbursement Form”
- click “Continue”
if you’re lucky, this’ll just jump you straight to the start of the form: https://cigna.vsp.com/out-of-network1.html there’s an attachment limit of 3 files with a max of 5 MB per file and some filename restrictions (they don’t like $). but it’s way easier than mailing a paper form.
-
TIL: Pivotal Tracker can be told about deployments. https://www.pivotaltracker.com/blog/2020-01-24-ci-cd-integrations (The setup tool will write Jenkins Pipeline or Bash snippets for you, then you just paste ‘em into the right places.)
Bad Jokes
- TIL: https://meet.google.com/ia-cthulhu-phtagn 404s. alas, He slumbers still.