Skip to content

Instantly share code, notes, and snippets.

async function () {
const files = await fs.readdir('a');
await Promise.all(files.map(async (filename) => {
const data = await fs.readFile(filename);
await fs.writeFile('b/' + filename, data);
console.log(filename);
}));
}();
@thejohnfreeman
thejohnfreeman / one.ts
Last active September 4, 2018 05:08
Typescript puzzle
// This first solution mostly works,
// but if I think of the Pair in RecordOfPairs as mapping an input A to an output B,
// then I want RecordOfPairs to take as its type parameters
// a record of input As and a record of output Bs,
// the return types of `ays` and `bees`.
// Then, RecordOfPairs is mapping its first type parameter to its second,
// just like Pair.
function pluck<T extends { [k1 in K1]: { [k2 in K2]: T[k1][k2] } }, K1 extends keyof T, K2 extends keyof T[K1]>
(key: K2, obj: T): { [k in K1]: T[k][K2] } {

I'm a budding fan of @SamHarrisOrg's podcast. Listened to one with @andrewyang2020 and was disappointed with his lack of scrutiny on the affordability numbers for universal basic income. Here are my thoughts.

Cost

A Freedom Dividend of $1000 per adult between 18 and 64 would cost about $1.5 trillion. - 54:08

Kaiser Family Foundation (these numbers rounded down):

 29.8 million adults 19 - 25 
@thejohnfreeman
thejohnfreeman / app.component.html
Last active May 1, 2018 13:18
Kendo Grid abstraction
<!-- This use actually shows all 12 properties in my object instead of just two. -->
<my-grid
[sort]="[{ field: 'name', dir: 'asc' }]"
[service]="myService">
<kendo-grid-column field="id" title="ID">
</kendo-grid-column>
<kendo-grid-column field="name" title="Name">
</kendo-grid-column>
</my-grid>
The Conda recipe is used to build a package for distribution. It builds a temporary environment with the dependencies in `recipe/meta.yaml`, then runs `python setup.py install` to install the package into that environment. setuptools will install any additional dependencies in `install_requires`, but Conda will be unaware of them (or include them in the distribution?).
setuptools dependencies refer to PyPI package names, and Conda dependencies refer to Conda package names, which are the same when developers consistently put the same name in their `setup.py` and `recipe/meta.yaml`. In theory, when they don't, then using the same dependency lists for both tools can make your build fail, but in practice, they seemingly always do.
If a developer has published their Python package to PyPI but not Conda, you might be able to [find it an alternative channel](https://stackoverflow.com/a/38065334/618906).
The `setup.py` is used to install a package into a development environment (with `python setup.py develop`) or
git init
yarn init

JavaScript

# Initial build directory should just be '.'. If and when you start using
# a build tool, change it to the output directory.
BUILD_DIR ?= build
# Default installation directory is specific to the development environment
# of the primary contributor.
INSTALL_DIR ?= /home/jfreeman/shared/reload-extension
# Recursively list all of the Git-visible files in the current directory.
# Effectively ignores temporary files and Git objects.
@thejohnfreeman
thejohnfreeman / feedback.md
Last active January 20, 2018 00:58
Tight feedback loop
watchexec --ignore dist/ --exts ts,js,json npm test
while true; do ls build/manifest.json | entr bash -c 'rsync --archive --delete build/ ~/shared/mint-ui/ && date'; done
@thejohnfreeman
thejohnfreeman / instructions.md
Last active January 5, 2023 02:15
Semantic UI fonts with Webpack in a Chrome extension

To get Semantic UI fonts working:

  1. npm install semantic-ui-css

  2. Import 'semantic-ui-css/semantic.css' in your entry script. The exact syntax for this varies depending on your chosen module format: import for ES6, require for CommonJS, etc. This tells Webpack to pull the CSS into your bundle.

  3. npm install --save-dev style-loader css-loader

@thejohnfreeman
thejohnfreeman / investigate.md
Last active January 14, 2017 07:10
Automated code quality tools