This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " General | |
| set nocompatible | |
| filetype on | |
| filetype plugin on | |
| filetype indent plugin on | |
| set ofu=syntaxcomplete#Complete | |
| set modeline | |
| set history=1000 | |
| set clipboard+=unnamed | |
| set ffs=unix,dos,mac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env php | |
| <?php | |
| $app = function($request) { | |
| $body = <<<EOS | |
| <!DOCTYPE html> | |
| <html> | |
| <meta charset=utf-8> | |
| <title>Hello World!</title> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function escape_mb_chars($str) { | |
| $first = preg_replace_callback('/\p{C}/u', function ($m) { | |
| $char = current($m); | |
| return substr(json_encode($char), 1, -1); | |
| }, $str); | |
| return rtrim($first, '\n'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; vim: set ft=clojure | |
| ; Joseph McCarthy's diff function | |
| ; see: | |
| ; J. McCarthy, Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I, April 1960 | |
| ; | |
| ; diff [y; x] = [atom[y] → | |
| ; [eq[y; x] → ONE; T → ZERO]; | |
| ; eq[car [Y]; PLUS] → cons [PLUS; maplist[cdr[y]; λ[[z]; diff[car [z]; x]]]]; | |
| ; eq[car [y]; TIMES] → cons[PLUS; maplist[cdr[y]; | |
| ; λ[[z]; cons [TIMES; maplist[cdr [y]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _common_section | |
| printf $c1 | |
| printf $argv[1] | |
| printf $c0 | |
| printf ":" | |
| printf $c2 | |
| printf $argv[2] | |
| printf $argv[3] | |
| printf $c0 | |
| printf ", " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; from https://aan.io/dumping-datomic-schema/ | |
| (let [dbval (d/db conn)] | |
| (->> (d/q '[:find ?ident | |
| :in $ ?p | |
| :where | |
| [:db.part/db :db.install/attribute ?attr] | |
| [?attr :db/ident ?ident]] | |
| dbval :db.part/user) | |
| (map (fn [attr] [(d/entity dbval (first attr))])) | |
| (map (fn [attr] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ws.eval( | |
| ['defmacro', 'let', ['form'], | |
| ['do', | |
| ['def', 'bindings', | |
| ['map', ['pair', ['form', 1]] , ['fn', ['x'], ['.concat', ['array', '`def'], 'x']]]], | |
| ['def', 'exprs', ['.slice', 'form', 2]], | |
| ['.concat', ['array', '`do'], 'bindings', 'exprs']]]); | |
| ws.eval( | |
| ['defmacro', 'deftype', ['form'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (def fib | |
| (memoize | |
| (fn [n] | |
| (cond (=== n 0) 0 | |
| (=== n 1) 1 | |
| :else (+ (fib (- n 1)) (fib (- n 2))))))) | |
| (let [fibs (map (range 20) fib) | |
| pairs (pair fibs) | |
| ratios (reduce pairs (fn [memo xs] (.concat memo (apply div (.reverse xs)))) [])] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Expression | |
| OPTS = { | |
| :+ => :add, | |
| :- => :sub, | |
| :* => :mult, | |
| :/ => :div, | |
| :** => :exp | |
| } | |
| def +(other) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Hash | |
| def to_proc | |
| lambda { |x| self[x] } | |
| end | |
| end | |
| class Array | |
| def to_proc | |
| lambda { |x| self[x] } | |
| end |