This Web Components keeps the year in your copyright notice up-to-date.
export { CopyrightYearElement }
const name = "copyright-year";
class CopyrightYearElement extends HTMLSpanElement {| Severity | Method | Appropriate for |
|---|---|---|
| MAX | mark() |
a) Temporary only, while developing; never on master or in production |
| 5 | fatal() |
a) Every uncaught exception |
| 4 | error() |
a) Every throw, swallowed or not |
| 3 | warn() |
a) Any debug or info that contains bad news |
| 2 | info() |
a) Side effects after success; b) task progress; see warn |
| 1 | trace() |
a) Upon entry into every routine, sig & values |
| From: https://github.com/atom/atom/issues/1669#issuecomment-135503562 | |
| create the following file at `~/Library/KeyBindings/DefaultKeyBinding.dict` (or add these entries to the existing file): | |
| ``` | |
| { | |
| "^@\UF701" = "noop:"; | |
| "^@\UF702" = "noop:"; | |
| "^@\UF703" = "noop:"; | |
| } |
These are listed in no particular order, but are numbered so they can referenced more easily.
if / else statements is hard to follow and re-organize. Bail early using return instead of nesting subsequent code.| console.clear() | |
| const FS = require('fs') | |
| async function readdir(path) { | |
| return new Promise((resolve, reject) => { | |
| FS.readdir(path, (err, data) => { | |
| if(err) reject(err) | |
| else resolve(data) | |
| }) |
| // Step 1: open somafm player | |
| // Step 2: click "Favorite Songs" | |
| // Step 3: drag-select all the text from the first song title to shopping cart on last row | |
| // Step 4: copy & paste that text into text2tsv in JS console | |
| // Step 5: paste result into Google Docs and you have a spreadsheet | |
| const text2tsv = (text) => text.split('\n\n \n') | |
| .map( r => r.trim().split('\n\n') ) | |
| .map( t => ({ artist: String(t[0]).trim(), title: String(t[1]).trim() }) ) | |
| .map( t => `${t.artist}\t${t.title}` ) |
| // x : lean back | |
| // y : revolving door from front | |
| // z : twist clockwise | |
| // transform: rotate3d(0,1,1,45deg); |
one of those moments of programming eloquence you hope for, discovered to be unneeded immediately upon finishing it
the final code:
handleWordClick = (word, event) => {
let isShiftClick = (this.state.shiftActive);
let [ hasClickFn , hasShiftClickFn ] = [ 'onClick', 'onShiftClick' ].map((p) => (typeof this.props[p] === 'function'));
| import Path from 'path'; | |
| import AppPaths from 'app-paths'; | |
| import Persist from 'auto-persister'; | |
| let settings = Persist.manageFile({ | |
| path: Path.join(ApPaths.ConfigFile, 'default.myapp-settings'), | |
| json: true, // read & write will marshall JSON automatically | |
| autocreate: true, // file (and parent dirs) will be immediately created if they don't already exist | |
| initialData: DefaultSettings, // value that will be returned if file doesn't exist, and that will be written if autocreate true |
| /** | |
| * Map HTTP error codes to fetch's .then/.catch behavior | |
| * List based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Status | |
| */ | |
| let codes = [ | |
| {"code": "100", "text": "Continue"}, | |
| {"code": "101", "text": "Switching Protocol"}, | |
| {"code": "200", "text": "OK"}, | |
| {"code": "201", "text": "Created"}, |