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
console.log 'fixing keybindigs' | |
atom.keymaps.keyBindings.forEach (x) -> | |
if x.keystrokes == 'g ^' | |
x.keystrokes = 'g shift-6' | |
x.keystrokeArray = ['g', 'shift-6'] |
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
;; -*- mode: emacs-lisp -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Configuration Layers declaration. | |
You should not put any user code in this function besides modifying the variable | |
values." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory |
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
// a basic 'scope' for our language... | |
// it will never have globals... | |
// so it will thorw by default. | |
function ctx(name){ | |
throw name + " is undefined"; | |
} | |
/** |
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
//the interperter | |
e=(s,c)=>s/s?s:s.trim?c(s):(S=s[0],S=="if"?e(s[1],c)?e(s[2],c):e(s[3],c):S=="f"?a=>e(s[2],n=>s[1]==n?a:c(n)):e(S,c)(e(s[1],c))); | |
//global ctx | |
function global_scope(name){ | |
if(name === "log") | |
return item => console.log(item); | |
if(name === "+") | |
return a => b => a + b; | |
if(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
// example of get the position of the cursor in a line of a text buffer from a click event | |
function clickPositionToCharIndex(clickX){ | |
return comp( | |
map(measureCharWidth), | |
reductions((a,b) => a + b, 0), | |
takeWhile(x => x < clickX), | |
mapIndexed((idx, item) => idx) | |
); | |
} |
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
require("./array.js"); | |
const { reduce, reduced } = require("./reduce.js"); | |
const { map, dropWhile, dedupe, window, comp } = require("./transducers.js"); | |
const { into } = require("./into.js"); | |
function pair_items(items){ | |
items = into([], dropWhile(x => x.hasOwnProperty("pair_id")), items); | |
var first = items[0]; | |
items.shift(); |
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
(defn- -create-react-component | |
"create a 'inline' component and set the display name to the same name as the function" | |
[f] | |
(let [component (fn [js-props] | |
(let [args (.-uixprops js-props)] | |
(hiccup->react (apply f args))))] | |
(set! (.-displayName component) (.-name f)) | |
component)) | |
;; obvious optimization if obvious |
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 run(fsm, stateRunner, state){ | |
let runner = stateRunner[state.currentState]; | |
return Promise.resolve(runner(state)).then(function(transition){ | |
if(transition.transitionTo === "done"){ | |
return transition.data; | |
} | |
return run(fsm, stateRunner, { | |
...transition, | |
currentState: fsm[state.currentState][transition.transitionVia] | |
}); |
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 checkLogin(state){ | |
if(state.data.username == "admin"){ | |
return { | |
...state, | |
transitionTo: "valid" | |
}; | |
}else { | |
return { | |
...state, | |
transitionTo: "invalid" |
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
//define the finite state machine data structure... | |
let fsm = { | |
"checkLogin" : {"valid" : "login", | |
"invalid" : "showError"} | |
}; | |
//create the handler functions... | |
function checkLogin(state){ | |
if(state.data.username == "admin"){ | |
return { |