Skip to content

Instantly share code, notes, and snippets.

@ryan-williams
ryan-williams / monad-monoid.md
Last active March 14, 2020 19:51
Attempt to articulate an intuitive understanding about why "a monad is a monoid in the category of endofunctors"™️

a monad is just a monoid in the category of endofunctors

Monoid

A monoid has two components:

id (or empty)

"make an instance from nothing"

  • 0 (Unit => Int)
  • "" (Unit => String)
  • Nil (Unit => List[_])
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

NE Scala 2020: "online-only" post-mortem

2020-03-20

On Saturday we wrapped up the Northeast Scala Symposium: a community-run conference related to the Scala programming language.

Going "online-only" at the last minute

On Tuesday, having sold 170 tickets to a conference starting Thursday at a venue in DUMBO, we decided to go "online only".

It's possible we should have made the call earlier. As is, some ppl were able to cancel their travel plans, others had already traveled, and (seemingly most) others had canceled on their own (or their employers had done it on their behalf).

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ryan-williams
ryan-williams / gist-dir
Last active December 30, 2019 03:31
Script for uploading [files or directories that may contain binary data] to GitHub gists; see https://github.com/defunkt/gist/issues/191
#!/usr/bin/env bash
python3 gist_dir.py "$@"
@ryan-williams
ryan-williams / pandas.md
Last active December 3, 2019 00:56
Pandas functions for a 2-D histogram of a dataframe: one column's values become the columns, and values become counts of given {row, column} pairs)
  • Col1 is the field that will be the "rows" index
  • Col2 is the column whose values will become the new columns
  • Col3 is any other column (assuming that other columns are always filled; .count() will only count cells where Col3 has a value)
df \
.groupby(['Col1', 'Col2']) \
[['Col3']] \
.count() \
.reset_index() \
.pivot('Col1', 'Col2', 'Col3')
@ryan-williams
ryan-williams / pyenv.md
Last active December 30, 2023 15:25
install pyenv (and required OpenSSL from source, in homedir, without root/sudo)

First, install pyenv:

curl https://pyenv.run | bash

(docs)

Follow its parting instructions to make sure you have pyenv in your $PATH:

# Load pyenv automatically by adding
# the following to ~/.bashrc:
@ryan-williams
ryan-williams / git.md
Last active December 7, 2020 16:09
installing git from source (optionally in home directory / with prefix)

Install libpcre2

In some situations, I've observed make below to fail for lack of a locatable libpcre2:

v=10.36
wget https://downloads.sourceforge.net/pcre/pcre2-$v.tar.bz2
tar -xvjf pcre2-$v.tar.bz2
pushd pcre2-$v
./configure --prefix="$HOME"
make
make install
@ryan-williams
ryan-williams / openssh.md
Last active November 19, 2019 22:54
Install OpenSSH into home directory from source
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz
tar -xvzf openssh-8.0p1.tar.gz
cd openssh-8.0p1
./configure --prefix=$HOME --with-privsep-path=$HOME/var/empty
make
make install

The --with-privsep-path=$HOME/var/empty is necessary to avoid an error like:

@ryan-williams
ryan-williams / cd.py
Last active December 30, 2019 01:34
Python `cd` context manager for changing the current working directory, using pathlib; adapted from https://stackoverflow.com/a/13197763
from os import chdir, getcwd
from pathlib import Path
class cd:
"""Context manager for changing the current working directory"""
def __init__(self, path):
path = Path(path)
self.path = path.expanduser()