Skip to content

Instantly share code, notes, and snippets.

View robjens's full-sized avatar

Rob J robjens

  • Netherlands
View GitHub Profile
@robjens
robjens / 1-vim.asciidoc
Last active November 8, 2015 15:09
Some tips and tricks for Wisp, the homoiconic Clojuresque Lisp for JavaScript in Node and the browser.

Vim (editor)

Personally, I still fall back to plain-old console/println debugging output more often then I’d like. Especially when I’m a bit lukewarm, although in those cases, I tend to use browser based JS, perhaps even the Try Wisp browser editor which instantly compiles to JavaScript (unless you screw up) and helps to get the mind acquainted to the situation and syntax.

While venturing deeper in the language however, you’ll find that for example macro’s cannot be dealt with in the Try Wisp online editor/compiler and one has to move to the local machine instead to experiment further. The REPL, by the way, really isn’t half as useful as it can (and perhaps should)

@robjens
robjens / 1.asciidoc
Last active November 8, 2015 17:09
Lambda, wikipedia abstract to jog my memory every now and then on the notation, terms/words/lexicon, meaning of symbols etc.

Computable functions are a fundamental concept within computer science and mathematics. And there are analytical techniques that can only be applied to functions with a single argument.

Practical functions frequently take more arguments than this. Frege showed that it was sufficient to provide solutions for the single argument case, as it was possible to transform a function with multiple arguments into a chain of single-argument functions instead. This transformation is the process now known as `currying'.

Currying is similar to the process of calculating a function of multiple variables for some given values on paper.

For example, given the function f(x,y) = y / x:

To evaluate f(2,3), first replace x with 2 Since the result is a function of y, this new function g(y) can be defined as g(y) = f(2,y) = y/2

@robjens
robjens / gist:5e0f3527de2398d4e12f
Last active November 18, 2015 13:18
MongoDb standalone initialization script
var hosts = [
'hostname.mongo.server'
];
for( var hosti in hosts ){
var hostname = hosts[hosti];
print(hostname);
var dbo = new Mongo(hostname + ":27017").getDB('test');
@robjens
robjens / a.asciidoc
Last active November 22, 2015 19:27
Logic, math, linguistics, computing

In computing, the least significant bit (LSB) is the bit position in a binary integer giving the units value, that is, determining whether the number is even or odd. The LSB is sometimes referred to as the right-most bit, due to the convention in positional notation of writing less significant digits further to the right. It is analogous to the least significant digit of a decimal integer, which is the digit in the ones (right-most) position.

It is common to assign each bit a position number, ranging from zero to N-1, where N is the number of bits in the binary representation used. Normally, this is simply the exponent for the corresponding bit weight in base-2 (such as in 231..20). Although a few CPU manufacturers assign bit numbers the opposite way (which is not the same as different endianness), the term least significant bit itself remains unambiguous as an alias for the unit bit.

By extension, the least significant bits (plural) are the bits of the number closest to, and including, the LSB.

The least

@robjens
robjens / a.asciidoc
Last active November 22, 2015 20:56
Wisp gotchas

Wisp for Node.js

Some stuff that took me longer than it should to grok, figure out, look-up or otherwise non-intuitive or radically different from Clojure.

Functions

namespace

Operates on symbols and keywords but has a implementation which is picky. Takes keywords and symbols as follows: (namespace 'foo/bar), (namespace (keyword "foo" "bar")) or, (namespace (keyword :foo :bar)) all return foo

@robjens
robjens / one.clj
Last active November 23, 2015 13:15
NPM todays updates
(def npm (slurp "https://registry.npmjs.org/-/all/static/today.json"))
(distill* '[cheshire "LATEST"] {:verbose false})
(require '[cheshire.core :as json])
(require '[clojure.walk :refer [keywordize-keys]]
'[clojure.core.reducers :as r])
@robjens
robjens / plugins_Clojure_codemirror_clojure-mode.js
Created December 2, 2015 00:42
Clojure codemirror syntax file. Need to be tweaked to show meta-data properly.
CodeMirror.defineMode("clojure", function () {
var BUILTIN = "builtin", COMMENT = "comment", COMMENTFORM = "comment comment-form"; STRING = "string", CHAR = "char",
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", META = "meta";
var INDENT_WORD_SKIP = 2;
function makeKeywords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
@robjens
robjens / elk.zsh
Created December 7, 2015 23:02
A little ELK zsh script to make working repetive tasks a bit easier
#!/usr/bin/env zsh
emulate -L zsh || return 1
# Top level variables
eshost="http://support.internal.sevenmatches.com"
esport=9200 beat=(top packet file) beats=(${^beat}beat)
#
# Task handler
@robjens
robjens / foo.js
Created December 10, 2015 21:10
ES6 tagged template strings, this helped me grok it a bit better
var a = 5;
var b = 10;
var c = 2;
function tag(strings, ...values) {
console.log(strings[0].replace('\n', '')); // "Hello "
console.log(strings[1].replace('\n', '')); // " world "
console.log(values[0]); // 15
console.log(values[1]); // 50
@robjens
robjens / bootstrap.sh
Created December 20, 2015 20:28
Small helper to quickly create a working cljs project from scratch
#!/usr/bin/env bash %
#
# bootstrap.sh
#
# Copyright (C) 2015 Rob Jentzema <[email protected]>
#
# Distributed under terms of the MIT license.
#
# Reference(s):
# 1. https://github.com/clojure/clojurescript/wiki/Quick-Start