Skip to content

Instantly share code, notes, and snippets.

View HerringtonDarkholme's full-sized avatar

Herrington Darkholme HerringtonDarkholme

View GitHub Profile
// import gif.js
(function(c){function a(b,d){if({}.hasOwnProperty.call(a.cache,b))return a.cache[b];var e=a.resolve(b);if(!e)throw new Error('Failed to resolve module '+b);var c={id:b,require:a,filename:b,exports:{},loaded:!1,parent:d,children:[]};d&&d.children.push(c);var f=b.slice(0,b.lastIndexOf('/')+1);return a.cache[b]=c.exports,e.call(c.exports,c,c.exports,f,b),c.loaded=!0,a.cache[b]=c.exports}a.modules={},a.cache={},a.resolve=function(b){return{}.hasOwnProperty.call(a.modules,b)?a.modules[b]:void 0},a.define=function(b,c){a.modules[b]=c};var b=function(a){return a='/',{title:'browser',version:'v0.10.26',browser:!0,env:{},argv:[],nextTick:c.setImmediate||function(a){setTimeout(a,0)},cwd:function(){return a},chdir:function(b){a=b}}}();a.define('/gif.coffee',function(d,m,l,k){function g(a,b){return{}.hasOwnProperty.call(a,b)}function j(d,b){for(var a=0,c=b.length;a<c;++a)if(a in b&&b[a]===d)return!0;return!1}function i(a,b){function d(){this.constructor=a}for(var c in b)g(b,c)&&(a[c]=b[c]);return d.proto
// import gif.js
(function(c){function a(b,d){if({}.hasOwnProperty.call(a.cache,b))return a.cache[b];var e=a.resolve(b);if(!e)throw new Error('Failed to resolve module '+b);var c={id:b,require:a,filename:b,exports:{},loaded:!1,parent:d,children:[]};d&&d.children.push(c);var f=b.slice(0,b.lastIndexOf('/')+1);return a.cache[b]=c.exports,e.call(c.exports,c,c.exports,f,b),c.loaded=!0,a.cache[b]=c.exports}a.modules={},a.cache={},a.resolve=function(b){return{}.hasOwnProperty.call(a.modules,b)?a.modules[b]:void 0},a.define=function(b,c){a.modules[b]=c};var b=function(a){return a='/',{title:'browser',version:'v0.10.26',browser:!0,env:{},argv:[],nextTick:c.setImmediate||function(a){setTimeout(a,0)},cwd:function(){return a},chdir:function(b){a=b}}}();a.define('/gif.coffee',function(d,m,l,k){function g(a,b){return{}.hasOwnProperty.call(a,b)}function j(d,b){for(var a=0,c=b.length;a<c;++a)if(a in b&&b[a]===d)return!0;return!1}function i(a,b){function d(){this.constructor=a}for(var c in b)g(b,c)&&(a[c]=b[c]);return d.proto
@HerringtonDarkholme
HerringtonDarkholme / parser.scala
Last active August 29, 2015 14:06
Parser Combinator requires every regex is initialized before usage
import scala.util.parsing.combinator._
import scala.util.matching.Regex.Match
import scala.util.matching.Regex
import scala.annotation.{switch, tailrec}
object T extends RegexParsers {
abstract class AbstractSelector[S <: AbstractSelector[S]]
set noautofocus
let hintcharacters = "asdfghjkl;"
@HerringtonDarkholme
HerringtonDarkholme / typescript.vim
Created November 17, 2014 17:16
typescript.vim
if exists("g:TSSloaded")
finish
endif
if !has("python")
echoerr "typescript_tss.vim needs python interface"
finish
else
python <<EOF
import vim
@HerringtonDarkholme
HerringtonDarkholme / html.scala
Created November 18, 2014 00:07
Type Level Template
trait Tag
class Concat[A <: Tag, B <: Tag](a: A, b: B) extends Tag
trait NestTag[A <: Tag] extends Tag {
val child: A
}
trait Inline extends Tag
trait Block extends Tag
case class div[T <: Tag](t :T = null) extends NestTag[T] with Block {
val child = t
}
@HerringtonDarkholme
HerringtonDarkholme / left.scala
Created December 10, 2014 15:03
foldLeft and foldRight
def retry(noTimes: Int)(block: ⇒Future[T]): Future[T] = {
val ns: Iterator[Int] = (1 to noTimes).iterator
val attempts: Iterator[Future[T]] = ns.map(_⇒ ()⇒block)
val failed = Future.failed(new Exception)
attempts.foldLeft(failed)
((a,block) ⇒ a recoverWith { block() })
}
retry(3) { block }
= unfolds to
@HerringtonDarkholme
HerringtonDarkholme / comp1.jade
Created January 21, 2015 04:46
Jade: block statement in included components
block append test
h1 from comp1
@HerringtonDarkholme
HerringtonDarkholme / dependency.sbt
Created February 18, 2015 16:26
creating a task which depends on another task
barTask := { println("tests ran!") }
barTask <<= barTask.dependsOn(test in Test)
lazy val project = Project(id = "Foo", base = file("."),
settings = Seq(afterTestTask1, afterTestTask2))
val afterTestTask1 = barTask := { println("tests ran!") }
val afterTestTask2 = barTask <<= barTask.dependsOn(test in Test)
Serving HTTP on 0.0.0.0 port 8000 ...
127.0.0.1 - - [03/Apr/2015 17:57:31] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [03/Apr/2015 17:57:32] "GET /style.css HTTP/1.1" 200 -
127.0.0.1 - - [03/Apr/2015 17:57:32] "GET /multiply.js HTTP/1.1" 200 -
127.0.0.1 - - [03/Apr/2015 17:57:32] "GET /worker.js HTTP/1.1" 200 -
127.0.0.1 - - [03/Apr/2015 17:57:38] "GET /index2.html HTTP/1.1" 200 -
127.0.0.1 - - [03/Apr/2015 17:57:38] "GET /square.js HTTP/1.1" 200 -
127.0.0.1 - - [03/Apr/2015 17:58:01] "GET /style.css HTTP/1.1" 200 -
127.0.0.1 - - [03/Apr/2015 18:00:23] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [03/Apr/2015 18:00:23] "GET /style.css HTTP/1.1" 200 -