Skip to content

Instantly share code, notes, and snippets.

bhauman / reagent_errors.cljs
Created Oct 17, 2015
Fixing reagent errors
View reagent_errors.cljs
(ns devdemos.reagent-errors
[reagent.interop :refer-macros [.' .!]]
[reagent.core :as reagent]
[reagent.impl.component :as comp]
[sablono.core :as sab :include-macros true])
[cljs-react-reload.core :refer [defonce-react-class]]
[devcards.core :as dc :refer [defcard deftest]]))
View project.clj
:profiles { :dev { :dependencies [[com.cemerick/piggieback "0.2.1"]
#_[org.clojure/tools.nrepl "0.2.10"]]
:plugins [[refactor-nrepl "1.1.0"]
[cider/cider-nrepl "0.9.1"]]}}
:figwheel {
:http-server-root "public" ;; default and assumes "resources"
:server-port 3449 ;; default
:css-dirs ["resources/public/css"]
bhauman / cljs-react-reload.cljs
Last active Aug 29, 2015
cljs React Hot loader - keeping local state stable across React class changes
View cljs-react-reload.cljs
(ns cljs-react-reload.core
[cljs.env :as env]))
(defmacro def-react-class [vname body]
`(def ~vname (js/React.createClass ~body)))
(defmacro defonce-react-class
"Patches stable base react class on reload."
[vname body]
bhauman /
Last active Aug 29, 2015
Composable cljs build scripts

Independent composable build scripts for cljs

There is a need more complex build scripts for ClojureScript. It would be nice to have a minmal interface and method for composing these scripts. Somehting like:

(-> (watch-cljs ["src"])
    (watch-sass [""])
    (watch-css [""])
    (mark-macro-affected-source build-options)
bhauman / sonic_pi_music.rb
Created Jun 13, 2015
My first sonic pi creation.
View sonic_pi_music.rb
define :bass do |notes|
in_thread do
with_synth :pretty_bell do
n = if one_in(4) then choose(notes) else notes.first end
2.times do
with_synth :pretty_bell do
play (n - 8), amp: 0.1, release: 0.5
with_synth :sine do
bhauman / gist:146e067c8cc4d5aa3fd2
Last active Jan 7, 2017
Comments: Straightforward (Live) Functional JavaScript: Building the Yome Widget
bhauman / project.clj
Last active Aug 29, 2015
figwheel test runner with red/green favicon
View project.clj
:cljsbuild {
:builds [{:id "dev"
:source-paths ["src" "dev_src"]
:compiler {:output-to "resources/public/js/compiled/slides.js"
:output-dir "resources/public/js/compiled/out"
:optimizations :none
:asset-path "js/compiled/out"
:source-map true
:source-map-timestamp true
bhauman / nginx.conf
Last active Aug 29, 2015
nginx proxy
View nginx.conf
# sudo apt-get install nginx jed
# sudo crontab -e ;; 0 24 * * * service nginx restart >/dev/null 2>&1
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/;
events {
bhauman / core.cljs
Last active Jan 28, 2021
Helpful patterns when developing with ClojureScript Figwheel and Express js
View core.cljs
(ns todo-server.core
[cljs.nodejs :as nodejs]
[figwheel.client :as fw]))
(defonce express (nodejs/require "express"))
(defonce serve-static (nodejs/require "serve-static"))
(defonce http (nodejs/require "http"))
View gist:f954c4ee3611cf51494d
{:optimizations :none
:output-dir "samples/hello/out"
:output-to "samples/hello/out/hello.js"
:source-map true}
Currently print-mapped-stacktrace takes a path from the root of the project.
[{:file "samples/hello/out/hello/core.js" <-- path from project root
:function "first"