Skip to content

Instantly share code, notes, and snippets.

View rksm's full-sized avatar
🏗️

Robert Krahn rksm

🏗️
View GitHub Profile
@rksm
rksm / npmDo
Created June 4, 2013 02:25
using npm programmatically
function withNPMDirDo(func) {
exec('npm bin -g', function(code, out, err) {
var npmBinDir = String(out).trim(),
npmlibDir = path.join(npmBinDir, '..', 'lib', 'node_modules', 'npm');
func(null, npmlibDir);
});
}
npmDo = function npmDo(/*command, orgs..., callback*/) {
var args = Array.prototype.slice.call(arguments),
.World {
background-color: rgb(187, 180, 188);
}
.Window {
background-color: rgb(197, 200, 198);
box-shadow: none;
border-radius: 3px;
border: 1px solid rgb(220, 220, 220);
}
@rksm
rksm / gist:8037313
Created December 19, 2013 10:35
Lively localconfig for VWF prototype
var c = lively.Config;
c.set('lively2livelyAutoStart', false);
c.set('lively2livelyEnableConnectionIndicator', false);
c.set('removeDOMContentBeforeWorldLoad', false);
c.set('manuallyCreateWorld', true);
c.set('changesetsExperiment', false);
// FIXME, for compatibility with requirejs
lively.whenLoaded(function() {
setTimeout(function() {
@rksm
rksm / jsPathSplitter.js
Last active August 29, 2015 13:57
Parse a JS object path
function jsPathSplitter(string) {
// STRING -> [STRING]
// ex: 'foo["bar"].x[0] -> ['foo', 'bar', x, '0']'
// for convenience even allows non-javascripty identifiers like foo.0.bar
return (function splitter(index, string, parts, term) {
if (string.length === 0) return parts;
if (index >= string.length) return parts.concat([string]);
if (string[index] === '\\') return splitter(index+2, string, parts, term); // escape char
var newTerm, skip = 0;
@rksm
rksm / gist:562cd712cf843080cf4c
Created August 4, 2014 01:35
Conditional call in Macro with gensym binding
(defmacro foo
[& [fn]]
`(let [env# 123]
~(when fn `(~fn env#))))
;; then expanded form of env does not match:
(macroexpand '(foo identity)) ;=> (let* [env__17699__auto__ 123] (identity env__17698__auto__))

THIS DOCUMENTATION IS CURRENTLY WORK IN PROGRESS!

lively.lang Build Status

What? This project packages abstractions for JavaScript that proved to be useful in the Lively Web project. On first glance it might seem to be just another underscore.js library but apart from extensions to existing JavaScript objects and classes it also provides abstractions for asynchronous code, new object representations, and functions for inspecting JavaScript objects.

@rksm
rksm / user config
Last active August 29, 2015 14:15
cloxp dark theme
lively.morphic.CodeEditor.prototype.setTheme = lively.morphic.CodeEditor.prototype.setTheme
.getOriginal().wrap(function(proceed) { return proceed("monokai"); });
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
lively.whenLoaded(function() {
(function() {
$world.get("MenuBar").addStyleClassName("MenuBar");
$world.withAllSubmorphsDo(function(ea) { return ea.applyStyle({cssStylingMode: true, cssStyling: true}); });
@rksm
rksm / gist:3318c4431a234815ee4f
Created February 11, 2015 23:54
cloxp enable vim
module('users.YOUR-USERNAME.config').requires().toRun(function() {
lively.Config.set("useEmacsyKeys", false);
module("lively.ide.CodeEditor").runWhenLoaded(function() {
ace.config.loadModule(["keybinding", 'ace/keyboard/vim'], function(vim) {
lively.Config.codeEditorUserKeySetup = function(editor) {
editor.withAceDo(function(ed) {
ed.keyBinding.addKeyboardHandler(vim.handler);
@rksm
rksm / gist:cb1317196a1b58b9162f
Created February 17, 2015 08:32
bind keys at runtime fix
(function loadUserKeyBindings() {
// user key bindings
try {
var cust = JSON.parse(lively.LocalStorage.get("user-key-bindings"));
ace.ext.keys.addKeyCustomizationLayer("user-key-bindings", cust || {});
var h = ace.require("ace/keyboard/keybinding").KeyBinding.prototype["ace.ext.keys.customized"].detect(function(ea) {
return ea.layerName === "user-key-bindings"; })
var proto = ace.ext.keys.KeyHandlerForCustomizations.prototype
proto.handleKeyboard = proto.handleKeyboard.getOriginal().wrap(function (proceed, data, hashId, keyString, keyCode) {
@rksm
rksm / gist:4a6c0116b32046290af3
Last active August 29, 2015 14:17
testing with dynamically bound vars
(def ^:dynamic *test-subject* nil)
(defn subject-fixture [test]
(binding [*test-subject* {:foo 23}]
(test)))
(use-fixtures :each subject-fixture)
(deftest my-test
(is (= *test-subject*