Skip to content

Instantly share code, notes, and snippets.

@bhauman
bhauman / core.cljs
Last active August 29, 2015 14:01
The code from the Devcards introduction video
(ns hello-there.core
(:require
[devcards.core :as dc :include-macros true]
[sablono.core :as sab :include-macros true]
[om.core :as om :include-macros true])
(:require-macros
[devcards.core :refer [defcard is are= are-not=]])
)
(devcards.core/start-devcard-ui!)
{: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.
(print-mapped-stacktrace
[{:file "samples/hello/out/hello/core.js" <-- path from project root
:function "first"
@bhauman
bhauman / nginx.conf
Last active August 29, 2015 14:18
nginx proxy
# 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/nginx.pid;
events {
@bhauman
bhauman / project.clj
Last active August 29, 2015 14:19
figwheel test runner with red/green favicon
: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
:main slides.dev
:asset-path "js/compiled/out"
:source-map true
:source-map-timestamp true
@bhauman
bhauman / sonic_pi_music.rb
Created June 13, 2015 02:46
My first sonic pi creation.
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
end
with_synth :sine do
@bhauman
bhauman / composable_build.md
Last active August 29, 2015 14:23
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 [""])
    (compile-sass)
    (watch-css [""])
 (mark-macro-affected-source build-options)
@bhauman
bhauman / cljs-react-reload.cljs
Last active August 29, 2015 14:24
cljs React Hot loader - keeping local state stable across React class changes
(ns cljs-react-reload.core
(:require
[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]
module ApplicationHelper
def body_tag_class(more_class = "")
"#{params[:controller]}_cont #{params[:action]}_action #{'logged_in' if logged_in?} #{more_class}"
end
end
#usage
%html
%body{:class => open_body_tag}
.user_controls { display:none; }
body.logged_in .user_controls { display:block; }
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
exit!