Let's quickly review creating a new project utilizing todos.
-
Init a new Project
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c> |
#!/bin/bash | |
# | |
# Re-Open KeePassXC Database | |
# | |
# - Requests password of a KeePassXC database from the system keyring and opens | |
# it | |
# - Listens to DBUS LockedHint signals. Closes the database on lock, reopens it | |
# on unlock | |
# | |
# |
// Simple gist to test parallel promise resolution when using async / await | |
function promiseWait(time) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(true); | |
}, time); | |
}); | |
} |
Here's an example of how to debug Mocha v4 if it hangs.
Ensure you're using a Node.js 8 or newer (or any version with async_hooks support).
If you run your test, you'll notice it hangs:
$ mocha test.js
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce
method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List
is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
#!/bin/bash | |
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$') | |
do | |
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes | |
if [ $? -ne 0 ]; then | |
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint." | |
exit 1 # exit with failure status | |
fi | |
done |
Picking the right architecture = Picking the right battles + Managing trade-offs
# The first 12 digits of pi are 314159265358. We can make these digits into an expression evaluating to 27182 (first 5 digits of e) as follows: | |
# 3141 * 5 / 9 * 26 / 5 * 3 - 5 * 8 = 27182 | |
# or | |
# 3 + 1 - 415 * 92 + 65358 = 27182 | |
# Notice that the order of the input digits is not changed. Operators (+,-,/, or *) are simply inserted to create the expression. | |
# Write a function to take a list of numbers and a target, and return all the ways that those numbers can be formed into expressions evaluating to the target. Do not use the eval function in Python, Ruby or JavaScript |
import decamelize from 'decamelize'; | |
import { fromGlobalId } from 'graphql-relay'; | |
import pluralize from 'pluralize'; | |
import getItem from '../api/getItem'; | |
const types = {}; | |
const endpoints = {}; | |
const getItemOverrides = {}; |