Skip to content

Instantly share code, notes, and snippets.

@4mitch
4mitch / rich-already-answered-that.md
Created February 25, 2018 22:02 — forked from reborg/rich-already-answered-that.md
Clojure Design Decisions

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats. The link below jumps at the answer in this file, the link on the question points back at the original post.

Index:

@4mitch
4mitch / 00_destructuring.md
Created February 25, 2018 22:49 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

@4mitch
4mitch / dumb_graph.js
Created February 25, 2018 23:33 — forked from grayrest/dumb_graph.js
Simple JS implementation of Prismatic's blog post about Graph
function sum (fn, xs) {
var toRet = 0;
for (var i = 0, ii = xs.length; i < ii; i++) {
toRet += fn(xs[i], i, xs);
}
return toRet;
}
function update(t, o) {
for (var k in o) {
@4mitch
4mitch / vec_compare.clj
Last active December 7, 2018 23:47
[Clojure] Compare two vectors without order
(let [a [1 1 2 3 4]
b [1 2 3 4 1]]
(and
#_(time
(and
(.containsAll a b)
(.containsAll b a)))
(time
(= (frequencies a)
@4mitch
4mitch / docker.md
Created July 11, 2018 21:14 — forked from f3l1x/aliases
Docker - installation, tips, commands, aliases

Docker

Shortcuts

$ curl -fsSL https://raw.github.com/tcnksm/docker-alias/master/zshrc >> ~/.bashrc && source ~/.bashrc
# ------------------------------------
@4mitch
4mitch / Install_Alpine_Linux_3.3_on_VirtualBox_OSX.md
Created July 12, 2018 08:46 — forked from kennwhite/Install_Alpine_Linux_3.3_on_VirtualBox_OSX.md
Howto: Install Alpine Linux 3.3 on VirtualBox OSX

Howto: Install Alpine Linux 3.3 on VirtualBox OSX

  • Latest Standard ISO version x86_64 is recommended (http://alpinelinux.org/downloads/)
  • Create new VM ("Linux 2.6 / 3.x / 4.x (64-bit)")
  • 1 CPU w/ 512BM RAM and 1 GB default (VDI) disk is more than sufficient
  • Default networking (NAT)
  • Boot and add Alpine ISO as attached virtual install media
  • Default root password is blank (though note - ssh PermitRootLogin defaults to disallow blank passwords and: prohibit-password; switch to yes for Host ssh)
  • Run setup-alpine
  • Defaults are fine, but you do want "sys" disk setup to sda, y to confirm
@4mitch
4mitch / Higher Order Functions.ps1
Created August 1, 2018 17:59
Functional programming with Powershell
function Convert-ByFilter($values, $predicate) {
return $values | where { & $predicate $_ }
}
Describe "Higher Order Functions" {
$values = @(1, 2, 3, 4)
It "Should filter even" {
$evenPredicate = { param($value) return $value % 2 -eq 0 }
$even = Convert-ByFilter $values $evenPredicate
@4mitch
4mitch / xpath-3.0.ebnf
Created September 11, 2018 21:22 — forked from eerohele/xpath-3.0.ebnf
XPath 3.0 EBNF grammar (Instaparse-compatible except for instaparse/#114)
XPath ::= Expr
ParamList ::= Param ("," Param)*
Param ::= "$" EQName TypeDeclaration?
FunctionBody ::= EnclosedExpr
EnclosedExpr ::= "{" Expr "}"
Expr ::= ExprSingle ("," ExprSingle)*
ExprSingle ::= ForExpr
| LetExpr
| QuantifiedExpr
| IfExpr
@4mitch
4mitch / xpath-3.0.ebnf
Created September 11, 2018 21:22 — forked from eerohele/xpath-3.0.ebnf
XPath 3.0 EBNF grammar (Instaparse-compatible except for instaparse/#114)
XPath ::= Expr
ParamList ::= Param ("," Param)*
Param ::= "$" EQName TypeDeclaration?
FunctionBody ::= EnclosedExpr
EnclosedExpr ::= "{" Expr "}"
Expr ::= ExprSingle ("," ExprSingle)*
ExprSingle ::= ForExpr
| LetExpr
| QuantifiedExpr
| IfExpr
@4mitch
4mitch / gist:949d3faa2dcffc2c090088ebbb2d5e46
Created September 22, 2018 22:18 — forked from noisesmith/gist:d9a804212f3759043053
start a clojure 1.8 socket repl
=> (clojure.core.server/start-server {:name "debug connection" :port 5555 :accept 'clojure.core.server/repl})
#object[java.net.ServerSocket 0x631883f0 "ServerSocket[addr=localhost/127.0.0.1,localport=5555]"]