Skip to content

Instantly share code, notes, and snippets.

// As long as the functions work on Promise values, you don't need to use `.then/.chain`.
// In fact, I'd say that using `.then` directly is usually an anti-pattern, as you can easily liftN(fn)
var tweets = getTweetsFor("swannodette")
var firstUrl = expandUrl(first(parseUrls(tweets)))
var response = httpGet(firstUrl)
response.then(function(data) { console.log("Most recent link text: ", data) }
,function(error) { console.log("Error with the twitterverse: ", error) })
/* The CLJS
@kurisuwhyte
kurisuwhyte / gist:6282598
Created August 20, 2013 15:04
Representing HTML as first-class entities in Dart
// This is a really bad implementation of a simple algebraic data type in Dart please don't kill meee~
class None implements Option<None> {
map(f) => this;
operator >= (f) => this;
operator | (x) => x;
None();
}
class Option<T> {
final value;
@kurisuwhyte
kurisuwhyte / broken.ls
Created July 21, 2013 21:30
LiveScript's pygments lexer is broken for word arrays
fruits = <[ apple orange ]>
# This should be a comment
people = <[ Chris Alice ]>
# This should be another comment
@kurisuwhyte
kurisuwhyte / hof.js
Created July 21, 2013 19:13
Higher-order functions for computing the sibling of an element
function findElement(node, stepper) {
var x
return isRoot(node)? stepper(node)
: x = stepper(node)? x
: /* otherwise */ findElement(node.parentNode, stepper)
}
function findNextSibling(node) {
return findElement(node, function(el) { return el.nextSibling })
}