Skip to content

Instantly share code, notes, and snippets.

View EricCrosson's full-sized avatar
💭
This is not my status.

Eric Crosson EricCrosson

💭
This is not my status.
View GitHub Profile
@EricCrosson
EricCrosson / example.csv
Created May 8, 2021 20:05 — forked from evanderkoogh/example.csv
Import CSV into DynamoDB
whateverId attribute1 someotherattribute
foo bar baz
hello erwin world
@EricCrosson
EricCrosson / co-contra-variance.md
Created July 26, 2020 14:24 — forked from jimblandy/co-contra-variance.md
A simple explanation of covariance and contravariance

If you say "T is a subtype of U", that means that whenever someone wants a U, a T will do: every T works as a U. It follows from this phrasing that U is a subtype of U: certainly if someone wants a U, a U will do.

So if you imagine a type as denoting a set of values, you can write: T ⊆ U.

If every T works as a U, then a function that accepts any U is certainly also a function that accepts any T: fn(U) works as a fn(T). So fn(U) is a subtype of fn(T): fn(U)fn(T).

This is interesting, because the subtypedness gets reversed: T ⊆ U implies fn(U)fn(T).

@EricCrosson
EricCrosson / auto-python-venv.md
Created November 16, 2019 21:57 — forked from purcell/auto-python-venv.md
Sane automatic python + virtualenv

Automatic python version plus venv

Goal

For easy editor integration and command-line usage, we'd like to be able to specify a Python version per project, with its own virtualenv to isolate its libraries from those of other projects.

We're willing to change $PATH globally once, but not per project. And we'd like to avoid having to run every python command invocation in a special subshell created by a shell wrapper. Instead, simply invoking "python" or "pip" etc. should do the right thing, based on the directory in which it is invoked.

It turns out this is possible!

@EricCrosson
EricCrosson / epigrams.md
Last active May 27, 2019 14:18
Epigrams in Programming
  1. One man's constant is another man's variable.
  2. Functions delay binding; data structures induce binding. Moral: Structure data late in the programming process.
  3. Syntactic sugar causes cancer of the semicolon.
  4. Every program is a part of some other program and rarely fits.
  5. If a program manipulates a large amount of data, it does so in a small number of ways.
  6. Symmetry is a complexity-reducing concept (co-routines include subroutines); seek it everywhere.
  7. It is easier to write an incorrect program than understand a correct one.
  8. A programming language is low level when its programs require attention to the irrelevant.
  9. It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures.
  10. Get into a rut early: Do the same process the same way. Accumulate idioms. Standardize. The only difference(!) between Shakespeare and you was the size of his idiom list - not the size of his vocabulary.
@EricCrosson
EricCrosson / whiteboardCleaner.md
Created December 11, 2018 15:04 — forked from lelandbatey/whiteboardCleaner.md
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@EricCrosson
EricCrosson / content.md
Created December 3, 2018 01:29 — forked from ayosec/content.md
Why Lisp macros are cool, a Perl perspective
@EricCrosson
EricCrosson / docopt-subcommand-dispatcher.js
Created August 29, 2018 17:34
Dispatcher design-pattern for docopt subcommands
const docopt = require('docopt').docopt
const docstring = `
Naval Fate.
Usage:
naval_fate ship new <name>...
naval_fate ship <name> move <x> <y> [--speed=<kn>]
naval_fate ship shoot <x> <y>
naval_fate mine (set|remove) <x> <y> [--moored|--drifting]
naval_fate -h | --help
(defun follow-this-buffer ()
"Open the current buffer in `follow-mode`. Additionally, open
as many vertical windows as possible with 80 columns in each."
(interactive)
(delete-other-windows)
(while (< 80 (window-width))
(split-window-horizontally)
(balance-windows))
(delete-window)
(balance-windows)
@EricCrosson
EricCrosson / mpsyt-dwim.el
Last active August 29, 2015 14:21
Modified mpsyt from punchagan
(defun pc/short-url-at-point ()
"Gets the short url at point.
This function is required only because
`thing-at-point-url-at-point' ignores urls (without a scheme)
that don't start with www."
(or
(ignore-errors
(let ((bounds (thing-at-point-bounds-of-url-at-point t)))
(when (and bounds (apply #'< bounds))
@EricCrosson
EricCrosson / desktop-save-advice.el
Last active August 29, 2015 14:18
mkdir -p before desktop-save-mode
(defadvice desktop-save-in-desktop-dir (before ensure-desktop-dir-exists activate)
"Ensure `desktop-dirname' exists before function
`desktop-save-in-desktop-dir' attempts to save the desktop
file."
(mkdir desktop-dirname t))