Skip to content

Instantly share code, notes, and snippets.

View anmonteiro's full-sized avatar

Antonio Nuno Monteiro anmonteiro

View GitHub Profile

Demo of the new "require outside NS" feature in ClojureScript

Given the following directory structure, where cljs.jar is a ClojureScript uberjar built from source (the feature is currently unreleased, follow these instructions and build the compiler with script/uberjar):

project
├─ src
│  └─ foo.cljs
└─ cljs.jar
@anmonteiro
anmonteiro / merge-sends.cljs
Created September 16, 2016 17:00
custom-merge-sends
(defn custom-merge-sends [a b]
(let [a (cond->> a
(not (every? (set (keys a)) (keys b)))
(merge (zipmap (keys b) (repeat []))))]
(merge-with #(into %1 (mapcat identity) %2) a b)))
@anmonteiro
anmonteiro / om-next-bootstrap.sh
Last active September 9, 2017 06:33
Use Om Next from Planck.
#!/bin/bash
set -e
if [ ! -d "om" ]; then
git clone -b self-host --depth=1 https://github.com/anmonteiro/om.git
fi
if [ ! -e "om/react-dom-server.jar" ]; then
curl -s -L https://clojars.org/repo/cljsjs/react-dom-server/15.3.0-0/react-dom-server-15.3.0-0.jar -o om/react-dom-server.jar

Keybase proof

I hereby claim:

  • I am anmonteiro on github.
  • I am anmonteiro (https://keybase.io/anmonteiro) on keybase.
  • I have a public key whose fingerprint is 6E21 4AFF 1F0F 7E8E 1F14 6E8B 3EF0 52D0 A849 4FE9

To claim this, I am signing this object:

@anmonteiro
anmonteiro / dump-1469571111827.cljs
Created July 26, 2016 22:11
ClojureScript REPL dump
cljs.user=> (in-ns 'user)
user is a single segment namespace
cljs.user=> (+ 1 1)
2
cljs.user=> (in-ns 'user)
nil
@anmonteiro
anmonteiro / # emacs - 2016-07-08_14-19-59.txt
Created July 8, 2016 13:23
emacs on Mac OS X 10.12 - Homebrew build logs
Homebrew build logs for emacs on Mac OS X 10.12
Build date: 2016-07-08 14:19:59
@anmonteiro
anmonteiro / bug.cljs
Last active March 23, 2016 14:06
`defprotocol` in advanced compilation bug
(ns bug.core)
(defprotocol IBug
(bug [this other] "A sample protocol"))
(defn MyBug [])
(specify! (.-prototype MyBug)
IBug
(bug [this other]
"bug")
@anmonteiro
anmonteiro / simulated-tempids.cljs
Last active January 18, 2016 20:53
tempids + Simulated server
(def init-data
{:list/one [{:id 0 :name "John" :points 0}
{:id 1 :name "Mary" :points 0}
{:id 2 :name "Bob" :points 0}]
:list/two [{:id 1 :name "Mary" :points 0 :age 27}
{:id 3 :name "Gwen" :points 0}
{:id 4 :name "Jeff" :points 0}]})
;; =============================================================================
@anmonteiro
anmonteiro / composite_pathopt.cljs
Created January 12, 2016 21:03
Composite with mutations & path optimization
(def composite-data
{:composite/item {:id 0
:width 400
:height 400
:color "#428BCA"
:value 0
:children [{:id 1
:width 200
:height 200
@anmonteiro
anmonteiro / composite.cljs
Last active November 5, 2018 16:59
Code for the series of posts "An exploration of object recursion design patterns in Om Next recursive queries"
;; =============================================================================
;; Composite
(def composite-data
{:composite/item {:id 0
:width 400
:height 400
:color "#428BCA"
:children [{:id 1
:width 200