Skip to content

Instantly share code, notes, and snippets.

View rf's full-sized avatar

Russ Frank rf

  • Oden Technologies
  • Brooklyn, NY
View GitHub Profile
/* Another popular pager, most, detects when stdout
* is not a tty and turns into cat. This makes sense. */
if (!isatty(STDOUT_FILENO))
return bb_cat(argv);
var marked = require('marked');
console.dir(marked.lexer("this is a paragraph: `test`\n\nsecondary paragraph: `test2`"));
// [ { type: 'paragraph', text: 'this is a paragraph: `test`\n\n' },
// { type: 'paragraph', text: 'secondary paragraph: `test2`' },
// links: {} ]
06:48 PM russfrank @ clarion ~/code/marked fmt?
$ cat postbench
marked completed in 3516ms.
marked (gfm) completed in 3567ms.
marked (pedantic) completed in 3299ms.
discount completed in 5421ms.
showdown (reuse converter) completed in 9914ms.
showdown (new converter) completed in 11393ms.
markdown-js completed in 27392ms.
@rf
rf / test.js
Created May 23, 2012 17:43
'read only' closures in python
function outer () {
var foo = 'yellow';
function inner () {
foo = 'blue';
}
function out () {
console.log(foo);
}
return [inner, out];
}
var sock = require('net').createConnection(process.argv[3], process.argv[2]);
sock.on('connect', function () {
process.stdin.pipe(sock);
});
sock.on('data', function (data) {
console.log(data.toString());
});
$ curl -v http://zeitnow.nodejitsu.com/
* About to connect() to zeitnow.nodejitsu.com port 80 (#0)
* Trying 165.225.129.253...
* connected
* Connected to zeitnow.nodejitsu.com (165.225.129.253) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.25.0 (x86_64-pc-linux-gnu) libcurl/7.25.0 OpenSSL/1.0.1 zlib/1.2.6 libidn/1.24 libssh2/1.4.0 librtmp/2.3
> Host: zeitnow.nodejitsu.com
> Accept: */*
>
import scala.actors._
import scala.actors.Actor._
case object Poke
case object Idling
class Kid () extends Actor {
def act () = loop {
if (mailboxSize == 0) this ! Idling
(defn lookup
"Lookup a variable in the model. Respects inversion of the variable if it is
specified with a - symbol. Returns nil if the variable is unset."
[model v]
(if (= (get v 0) \-) ; If the first character is '-'
(if-let [[k v] (find model (subs v 1))] ; If v is defined in the map get it
(not v) ; return not v if we found it
nil) ; otherwise return nil
(get model v))) ; If it isn't inverted simply get it
(defn lookup [v model]
"Lookup a variable in the model. Respects inversion of the variable if it is
specified with a - symbol. Returns nil if the variable is unset."
(if (= (get v 0) \-) ; If the first character is '-'
(let [value (get model (subs v 1))] ; let value equal the value of the var
(if (identical? value nil) ; if the variable is unnassigned
nil ; return nil
(not value))) ; otherwise return not value
(get model v)))
(defn lookup
"Lookup a variable in the model. Respects inversion of the variable if it is
specified with a - symbol. Returns nil if the variable is unset."
[v model]
(if (= (get v 0) \-) ; If the first character is '-'
(let [value (get model (subs v 1))] ; let value equal the value of the var
(if (identical? value nil) ; if the variable is unnassigned
nil ; return nil
(not value))) ; otherwise return not value