Skip to content

Instantly share code, notes, and snippets.

@micmarsh
micmarsh / dopromise.coffee
Last active August 29, 2015 14:01
Haskell Do Notation for JavaScript Promises
COMPILED_COFFEE = ' < -'
PLAIN_JS = '<-'
thenify = (lines) ->
[line, rest...] = lines
if rest.length is 0
line
else if line.search(PLAIN_JS) > 0 or line.search(COMPILED_COFFEE) > 0
[value, promise] = line.split if line.search(PLAIN_JS) > 0 then PLAIN_JS else COMPILED_COFFEE
noSemiColon = promise.slice(0, -1)
@staltz
staltz / introrx.md
Last active May 15, 2025 10:37
The introduction to Reactive Programming you've been missing
@deanrad
deanrad / cors.js
Last active April 9, 2021 09:26
Using CORS-Anywhere via AJAX
/*
If you are attempting to call an AJAX API, via GET which responds:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
You can modify the way you query it to go through a server which will add the header.
Basically, you add the URL you want (with query string parameters) at the end of
'https://cors-anywhere.herokuapp.com/'
, and ensure that your ajax call is done with some additional options as shown below
See CORS-Anywhere documentation here for more: