Skip to content

Instantly share code, notes, and snippets.

@bhauman
bhauman / core.cljs
Last active Aug 29, 2015
The code from the Devcards introduction video
View core.cljs
(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!)
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.
(print-mapped-stacktrace
[{:file "samples/hello/out/hello/core.js" <-- path from project root
:function "first"
@bhauman
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/nginx.pid;
events {
@bhauman
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
:main slides.dev
:asset-path "js/compiled/out"
:source-map true
:source-map-timestamp true
@bhauman
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
end
with_synth :sine do
@bhauman
bhauman / composable_build.md
Last active Aug 29, 2015
Composable cljs build scripts
View composable_build.md

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 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
(: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]
View using body tag class to set state for css rendering
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}
View css that plays off of state in the body tag
.user_controls { display:none; }
body.logged_in .user_controls { display:block; }
View lark_template.rb
# 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!
You can’t perform that action at this time.