createMessageDispatcher creates a message listener which will call a method on the
handler argument, based on the contents of the message that's passed from elsewhere.
It does this by injecting the (potentially error causing) method into a promise chain,
by sticking it inside a custom thenable,
which gives us much nicer error handling.
| #!/bin/env ruby | |
| STOP_QUOTED_RE = /(?:[^"]|"{2})(",)/ | |
| STOP_NORMAL_RE = /(,)/ | |
| # returns [chunk, rest], rest is nil at the end | |
| def read_chunk(line) | |
| quoted = line[0] == '"' | |
| start = quoted ? 1 : 0 |
| #!/bin/env ruby | |
| def octet?(str) | |
| (0...256) === str.to_i | |
| end | |
| def octets(str, current = [], output = []) | |
| # bail if there's nothing left to get | |
| if str.nil? || str.empty? |
I hereby claim:
- I am lygaret on github.
- I am lygaret (https://keybase.io/lygaret) on keybase.
- I have a public key ASCH_bCflDF9Q17IZVv7ox1t0p56et_SBdQSk5MQ-tFOYgo
To claim this, I am signing this object:
| _npmname=npm2arch | |
| _npmver=0.1.19 | |
| pkgname=nodejs-npm2arch-updated-deps-git # All lowercase | |
| pkgver=0.1.19 | |
| pkgrel=2 | |
| pkgdesc="Convert NPM package to a PKGBUILD for ArchLinux, patched for recent dependencies." | |
| arch=(any) | |
| url="https://github.com/Filirom1/npm2arch" | |
| license=(MIT) | |
| depends=('nodejs' 'npm' ) |
| # Methods for clustering data | |
| module Clustering | |
| # k-means clustering for 1d data | |
| # pass a block to project from an element into a number | |
| def self.kmeans_1d(data, k: 2, &projection) | |
| return [data] if k == 1 | |
| if data.to_a.uniq(&projection).length < 2 | |
| return [data].concat((k - 1).times.collect { [] }) | |
| end |
| confirm(new Date()) |
Hey Friendly @here,
Watching the uprisings across the country this week, and feeling a deep intertwined uncomfort at my own privilege and comfortable position, I am looking for ways to contribute that aren't simply idle cheerleading and amplification [1], and that reach further than simple bail fund donations [2].
[1]: which is perfectly fine, of course, but Twitter isn't action [2]: which, if you can, do: https://www.communityjusticeexchange.org/nbfn-directory
One piece of advice I've seen handed around is that it's my job, as a relatively rich white person, as a person who is allowed to systemically ignore issues of justice in the world around me, to educate myself and those around me on "what's going on", and that I can't expect POC to do that work for me.
So, I'd like to invite whomever would like to join to read some books I've seen mentioned, starting with:
| type MemoProps<T> = { [P in keyof T]: (this: T) => T[P] } | |
| export const MemoProto = { | |
| clone: function () { | |
| return this.define({}); | |
| }, | |
| define: function define<T>(this: T & {}, props: MemoProps<T>): MemoState<T> { | |
| // share the prototype, so we can nest but still destroy | |
| const update = Object.create(this); |
| require 'pp' | |
| class Reloader | |
| def initialize | |
| # normalized path => mtime | |
| @mtimecache = Hash.new | |
| # normalized path => load path | |
| # this will only lookup once, storing _nil_ in the cache if not found |