Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dyoder on github.
  • I am danyoder (https://keybase.io/danyoder) on keybase.
  • I have a public key ASASFaBFN7Z_PYpOoDBQL9AJYcH3vd36WG32Imfz-YlZTQo

To claim this, I am signing this object:

President and Vice-President

There's been a lot of whining about “too many dependencies” in applications. This goes along with a more general trend of complaining about how borked this or that platform is.

Here's a quote from a recent example:

As I sit here, looking at a stack trace of my coffee-script code, which runs through a ruby-based javascript interpreter sitting on top of the asset pipeline which runs through rails and spits out an error via a gem which globally hooks into the exceptions bubbled up from the depths of hell, and yet the stack trace can only give me a vague file reference and the type of error it is, but not actually point me at the actual error at all, and this ajax call has no good way of debugging itself besides injecting a debugger into the runtime and breaking and poking around, and the myriad of gems we use all seem to be conflicting into —

The idea seems to be that if the autho

An effective way to think about URLs as identifiers is to just imagine that we've got a URL from prior GET request.

First, just for kicks, let's put Fairmont's reactive power to work to write a helper so we can get the parsed body from responses to GET requests.

get = async (url) ->
  JSON.parse yield collect flow [
    stream http.get url: url, headers: accept: "json"
 map toString
vertical = top, bottom
horizontal = left, right, justify
-intersects(S, T)
for s in S
if s in T
return true
flow()
15:28 < david> Dan, are you around?
15:32 < david> Well, actually this doesn't require anything dramatic, haha.
15:34 < david> I know why Tonicdev cannot use Fairmont. It lets you use the await operator from ES7 to wait on promises, but it doesn't know anything about generators. It's running Node 12 without the Harmony flag, so it's ES5 JS with that await functionality baked in because it makes things so much easier.
15:36 < david> I'm curious if you're interested in generators in Fairmont's future, since ES7 has asynchronous functions and this "await" thing. Although, does CoffeeScript support those ES7 features?
15:44 < david> It looks like work in CS is still pending, but being actively considered. https://github.com/jashkenas/coffeescript/pull/3757
15:49 < david> It's kinda weird... await and yield are similar and both need an outer, calling function. But yield's outer function must be a generator. Is one preferred over the other?
18:21 < lance> tom: cool!
19:24 < dan> david: it's a bit of a mess.
@dyoder
dyoder / multimethods.coffee
Last active August 29, 2015 14:23
multimethods in coffeescript
# Implementation...
dispatch = (method, ax) ->
match = { p: 0, f: method.default }
for [entry, f] in method.entries
if entry.length == ax.length
p = 0
for term, i in entry
if term == ax[i]
p += 3
force = async (f, args...) ->
try
yield f args...
catch e
void
http = require "http"
{promise, all} = require "when"
get = (url) ->
promise (resolve, reject) ->
http.get url
.on "response", (response) ->
resolve response
.on "error", (error) ->
resolve error