Skip to content

Instantly share code, notes, and snippets.

View noprompt's full-sized avatar
💭
The choice to have discipline is a programmer's worst enemy.

Joel Holdbrooks noprompt

💭
The choice to have discipline is a programmer's worst enemy.
View GitHub Profile
@noprompt
noprompt / google-fonts.clj
Last active December 23, 2015 05:29
Garden Google Fonts
(def google-font-url
"http://fonts.googleapis.com/css")
(def google-font-style
{:thin "100"
:thin-italic "100italic"
:light "300"
:light-italic "300italic"
:normal "400"
:normal-italic "400italic"
(ns dafuq.main
(:use-macros [secretary.macros :only [defroute]])
(:require [goog.events :as events]
[secretary.core :as secretary])
(:import goog.History))
(defroute "/users/:id" {:keys [id]}
(.log js/console (str "USER: " id)))
(defroute "/" {:as params}
@noprompt
noprompt / closure_docset.rb
Created October 2, 2013 23:18
Google Closure docset for Dash (Ruby script).
DOC_PATH = "./Closure.docset/Contents/Resources/Documents"
DB_PATH = "./Closure.docset/Contents/Resources/docSet.dsidx"
CLOSURE_GIT_URL = "https://code.google.com/p/closure-library.docs/"
ICON_URL = "http://docs.closure-library.googlecode.com/git/static/images/16px.png"
# Setup
puts "Setting up..."
system("mkdir -p #{DOC_PATH}")
puts "Downloading documentation..."
(defmacro defstyles [name & styles]
`(def ~name ~styles))
(defmacro defstylesheet [name & body]
`(def ~name
(garden.core/css ~@body)))
(defstyles base
[:* :*:after :*:before
^:prefix {:box-sizing "border-box"}])
@noprompt
noprompt / griddle.clj
Created October 8, 2013 22:36
Straight port of the Golden Grid System.
(ns griddle.core
(:refer-clojure :exclude [+ - * /])
(:require [clojure.java.io :as io]
[garden.arithmetic :refer [+ - * /]]
[garden.repl]
[garden.core :refer [css]]
[garden.stylesheet :refer [at-media]]
[garden.units :refer [px em em-div percent]]
[garden.def :refer [defstyles defstylesheet defrule defcssfn]]))
(defn watch-file [file]
(let [mtime-chan (chan 1)
mtime (fs/mod-time file)]
(go (loop [old-mtime mtime new-mtime (inc mtime)]
(when (not= old-mtime new-mtime)
(put! mtime-chan new-mtime))
(recur new-mtime (fs/mod-time file))))
mtime-chan))
(defun cider-eval-expression-at-point-in-repl ()
(interactive)
(let ((form (cider-defun-at-point)))
;; Strip excess whitespace
(while (string-match "\\`\s+\\|\n+\\'" form)
(setq form (replace-match "" t t form)))
(set-buffer (cider-find-or-create-repl-buffer))
(goto-char (point-max))
(insert form)
(cider-repl-return)))
(ns ingredient.core
(:require [clojure.browser.repl]
[om.core :as om :include-macros true]
[sablono.core :as html :refer [html] :include-macros true]
[cljs.core.async :refer [put! chan close! sliding-buffer]])
(:require-macros [cljs.core.async.macros :refer [go]]))
(enable-console-print!)
(def app-state
(defn do-tests []
(when (seq @cemerick.cljs.test/registered-tests)
(cemerick.cljs.test/run-tests)
(reset! cemerick.cljs.test/registered-tests {})))
@noprompt
noprompt / slurp.clj
Created February 19, 2014 04:52
How to use slurp from ClojureScript
(ns foo.core
(:refer-clojure :exclude [slurp]))
(defmacro slurp [file]
(clojure.core/slurp file))
;; In CLJS
(ns bar.core
(:require [foo.core :include-macros true :refer [slurp]]))