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
| > clj | |
| Clojure 1.3.0 | |
| user=> (def rands (repeatedly rand)) | |
| #'user/rands | |
| user=> (def ^doubles tmp (take 300000 rands)) | |
| #'user/tmp | |
| user=> (time (reduce + tmp)) | |
| "Elapsed time: 433.227 msecs" | |
| 149973.6787182885 | |
| user=> (time (reduce + tmp)) |
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
| (add-hook 'js-mode-hook 'coding-hook) | |
| (add-to-list 'auto-mode-alist '("\\.js$" . js-mode)) | |
| (when (load "flymake" t) | |
| (defun flymake-jslint-init () | |
| (let* ((temp-file (flymake-init-create-temp-buffer-copy | |
| 'flymake-create-temp-inplace)) | |
| (local-file (file-relative-name | |
| temp-file | |
| (file-name-directory buffer-file-name)))) |
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 node | |
| // based on node's jslint-strict and douglas crockfords jslint | |
| var JSLINT = (function () { | |
| 'use strict'; | |
| function array_to_object(array, value) { | |
| // Make an object from an array of keys and a common value. |
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
| (defun smart-tab () | |
| "If mark is active, indents region. Else if point is at the end of a symbol, | |
| expands it. Else indents the current line. Acts as normal in minibuffer." | |
| (interactive) | |
| (cond (mark-active (indent-region (region-beginning) (region-end))) | |
| ((and (looking-at "\\_>") (not (looking-back "end\\|\\}"))) | |
| (hippie-expand nil)) | |
| (t (indent-for-tab-command)))) | |
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
| \d .q | |
| /each: +-*%&|^<>=$ <= >= <> @ ? in within bin div abs log exp sqrt sin cos tan f' f\: f/: | |
| neg:-:;not:~:;null:^:;string:$:;reciprocal:%:;floor:_:;ceiling:-_-:;signum:{(x>0)-x<0} | |
| mod:{x-y*x div y};xbar:{x*y div x:$[16h=abs[@x];"j"$x;x]};xlog:{log[y]%log x};and:&;or:|;each:{x'y};scan:{x\y};over:{x/y};prior:{x':y} | |
| mmu:$;lsq:!;inv:!:;md5:-15!;ltime:%:;gtime:{t+x-%t:x+x-%x}; /xnull:{$[0>@y;(,y)@~x=y;x=y;y 0N;y]} | |
| /aggr: last sum prd min max avg wsum wavg f/ /beta:{cov[x;y]%var x} | |
| count:#:;first:*:;var:{avg[x*x]-a*a:avg x:"f"$x};dev:{sqrt var x};med:{avg x(<x)@_.5*-1 0+#x,:()} | |
| cov:{avg[x*y]-avg[x]*avg y:"f"$y};cor:{cov[x;y]%dev[x]*dev y};all:min"b"$;any:max"b"$;rand:{$[0h>@x;?x;x@?#x]} |
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
| desc "migrate", "Runs Sequel migrations" | |
| def migrate(version=nil, database_url=DATABASE_URL) | |
| require 'sequel' | |
| Sequel.extension :migration | |
| db = Sequel.connect(database_url, :test => true) | |
| puts 'Running migrations...' | |
| Sequel::Migrator.apply(db, 'db/migrate', version && version.to_i) | |
| dump_schema |
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 mote(template, params = {}) | |
| variables = mote_process_variables(mote_cache, template, params) | |
| mote_cache[template] ||= Mote.parse(template, self, variables) | |
| mote_cache[template][params] | |
| end | |
| def mote_file(filename, params = {}) | |
| variables = mote_process_variables(mote_files, filename, params) | |
| mote_files[filename] ||= Mote.parse(File.read(filename), self, variables) | |
| mote_files[filename][params] |
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
| (defun smart-tab () | |
| "If mark is active, indents region. Else if point is at the end of a symbol, | |
| expands it. Else indents the current line. Acts as normal in minibuffer." | |
| (interactive) | |
| (cond (mark-active (indent-region (region-beginning) (region-end))) | |
| ((and (looking-at "\\_>") (not (looking-at "end"))) | |
| (hippie-expand nil)) | |
| (t (indent-for-tab-command)))) |
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 admin_of?(project) | |
| case v = membership_for(project) | |
| when Some then v.value.admin? | |
| when None then false | |
| end | |
| end |
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
| bool level_db_get(leveldb::DB *db, | |
| const leveldb::ReadOptions *options, | |
| const leveldb::Slice *key, | |
| char **value, | |
| size_t *n) { | |
| std::string result; | |
| leveldb::Status status = db->Get(*options, *key, &result); | |
| if (status.IsNotFound()) { | |
| return false; |