Skip to content

Instantly share code, notes, and snippets.

@bhauman
bhauman / gist:146e067c8cc4d5aa3fd2
Last active January 7, 2017 14:39
Comments: Straightforward (Live) Functional JavaScript: Building the Yome Widget
(require 'tubular.core)
(tubular.core/connect "127.0.0.1" REPL_PORT)
@bhauman
bhauman / An_Explanation.md
Last active April 27, 2016 18:03
common cljs build format ideas

A common build configuration format that all ClojureScript tools can consume

@bhauman
bhauman / checking_safari_mem_leak.clj
Last active January 4, 2016 00:49
This runs fine in Chrome. But the channels seem to be accumulating something in Safari Version 6.1 (7537.71) The standard browser for Lion. This code crashes my browser running it quickly up to 1.7G of memory usage. This also may be a problem in Safari on iOS7. So far I have learned that it's the ->> threading operator. Comp and partial work fine.
;; in project.clj
;; [org.clojure/clojurescript "0.0-2138"]
;; [org.clojure/core.async "0.1.267.0-0d7780-alpha"]
(ns checking-safari-leak.core
(:require
[cljs.core.async :as async
:refer [<! map< put! chan]])
(:require-macros [cljs.core.async.macros :as m :refer [go alt! go-loop]]))
@bhauman
bhauman / screw_you_zerigo.rb
Last active January 2, 2016 00:49
Zerigo's recent rate increase will raise my yearly cost 5000% so I created this lovely little script to help you leave Zerigo behind. It relies on the excellent fog library http://fog.io/dns/ It is currently targeting DNSimple but fog supports many other providers. Using it is very satisfying. After setting the correct connection settings just t…
require 'rubygems'
require 'fog'
require 'zerigo_dns'
# A simple script to help you leave zerigo behind
# it relies on the excellent fog library http://fog.io/dns/
# It copies all of your Zerigo zones to DNSimple
# It is currently targeting DNSimple but fog supports many other
(defn partition-chan
([start-pred in] (partition-chan start-pred (complement start-pred) in))
([start-pred end-pred in]
(let [out (chan)]
(go
(loop []
(if-let [val (<! in)]
(if (start-pred val)
(let [next-chan (chan)]
(>! out next-chan)
(defn partition-chan
([start-pred in] (partition-chan start-pred (complement start-pred) in))
([start-pred end-pred in]
(let [out (chan)]
(go
(loop []
(if-let [val (<! in)]
(if (start-pred val)
(let [next-chan (chan)]
(>! out next-chan)
@bhauman
bhauman / tictactoe.clj
Last active December 22, 2015 15:09
This is a tic tac toe implementation by Jeff Dik
(ns tic-tac-toe)
(defn empty-board [size]
(let [row (vec (repeat size nil))]
(vec (repeat size row))))
(defn prn-board [board]
(dorun (map prn board)))
(defn place [board row col marker]
def assert(phrase, val)
puts (val && "p #{phrase}" || "FAIL #{phrase}")
end
@offsets = [[0,1], [1,0], [-1,1], [1,-1], [-1, 0], [0, -1], [1,1], [-1,-1]]
world = {}
def neighbors_coordinates(coord)
x,y = coord
@bhauman
bhauman / gist:5897002
Created June 30, 2013 21:31
dataflow question for pedestal
(ns ^:shared continue-set-focus.behavior
(:require [clojure.string :as string]
[io.pedestal.app :as app]
[io.pedestal.app.messages :as msg]
[io.pedestal.app.util.log :as log]))
(defn set-value-transform [old-value message]
(:value message))
(defn init-emitter [inputs]