Skip to content

Instantly share code, notes, and snippets.

# 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.
git init
yarn init

JavaScript

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
@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>

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 / 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] } {
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);
}));
}();
async function () {
const result1 = await step1()
const result2 = await step2(result1)
const result3 = await step3(result2)
const result4 = await step4(result3)
console.log(result4)
}()
step1(function (error, result1) {
if (error) throw error
step2(result1, function (error, result2) {
if (error) throw error
step3(result2, function (error, result3) {
if (error) throw error
step4(result3, function (error, result4) {
if (error) throw error
console.log(result4)
})
async(function* () {
const result1 = yield step1()
const result2 = yield step2(result1)
const result3 = yield step3(result2)
const result4 = yield step4(result3)
console.log(result4)
// Errors are implicitly thrown.
})()