Skip to content

Instantly share code, notes, and snippets.

View edw's full-sized avatar

Edwin Watkeys edw

View GitHub Profile
@edw
edw / schass.scm
Created May 4, 2011 21:51
SASS-like Thing in Scheme
;; Let's you do this:
;;
;; (make-css
;; '(("body.loading"
;; (font-size "12px")
;; (color "#fff")
;; (" ul#sidenav"
;; (" li"
;; (blah "blah"))))))
;;
@edw
edw / sassesque.scm
Created May 5, 2011 14:22
Sass in Scheme, Take 2
;;
;; Sass in Scheme, Take 2
;; Copyright 2011 Edwin Watkeys. All rights reserved.
;;
;; [Imagine the two-clause MIT license inserted here.]
;;
;; CSS can be a pain. There is apparently a tool called Sass that some
;; people use to deal with some of the issues that accompany non-trivial
;; applications of CSS.
;;
@edw
edw / wes.scm
Created May 5, 2011 18:03
Write each string
(define-syntax wes
(syntax-rules ()
((_ p s)
(write-string s p))
((_ p s t ...)
(let ((nbytes (write-string s p)))
(+ nbytes (wes p t ...))))))
@edw
edw / css.scm
Created May 6, 2011 14:20
Sane CSS in Scheme (SASS Clone, Take 3)
;;
;; Sass in Scheme, Take 3
;; Copyright 2011 Edwin Watkeys. All rights reserved.
;;
;; [Imagine the two-clause MIT license inserted here.]
;;
;; CSS can be a pain. There is apparently a tool called Sass that some
;; people use to deal with some of the issues that accompany non-trivial
;; applications of CSS.
;;
@edw
edw / json-regex-pat.clj
Created June 13, 2011 17:07
Add support for writing regex patterns to JSON-STR
(ns foo
(:use [clojure.contrib json]))
(extend java.util.regex.Pattern
json/Write-JSON
{:write-json (fn [re w] (.write w (json-str (.pattern re))))})
@edw
edw / core.clj
Created July 6, 2011 17:35
Aleph, redis, compojure
(ns cms.core
(:use [clojure [pprint :only [pprint]]]
[compojure core]
[ring.adapter jetty]
[ring.middleware reload stacktrace]
[hiccup core page-helpers]
[clojure.contrib json]
[aleph redis]
[lamina core])
(:require [compojure [route :as route]])
@edw
edw / gist:2990375
Created June 25, 2012 18:30
Lein error
bash-3.2$ lein deps
Retrieving org/mongodb/mongo-java-driver/2.6.5/mongo-java-driver-2.6.5.pom (1k)
from http://repo1.maven.org/maven2/
Could not transfer artifact org.mongodb:mongo-java-driver:pom:2.6.5 from/to central (http://repo1.maven.org/maven2): Checksum validation failed, no checksums available from the repository
Could not find artifact org.mongodb:mongo-java-driver:pom:2.6.5 in clojars (https://clojars.org/repo/)
Failed to collect dependencies for clojure.lang.LazySeq@5f8ab865
@edw
edw / pick-and-rename.clj
Created July 30, 2012 17:06
Nested DEF
(defn pick-and-rename [col pick-map]
(def undefined-value (atom :undefined-value))
(apply assoc
{}
(flatten
(filter (fn [[k v]]
(not (= v undefined-value)))
(map (fn [[k v]]
[v (get col k undefined-value)])
pick-map)))))
@edw
edw / control.clj
Created September 24, 2012 12:04
Threading macro, a variant of ->, with pre, post, and run conditions
;; MACRO -*>
;;
;; While writing Ring handlers and other sorts of code that take advantage of
;; the threading idiom, it is often useful to peer inside the values of a thread
;; of evaluation. A :run condition is introduced here, which is evaluated
;; (presumably for side effects) before each form. Due to the nature of the
;; threading idiom, you must specify an EXPR-SYM, which is the symbol which is
;; used in the run and pre condition forms to specify the incoming value of the
;; first parameter. Additional parameters are not accessible.
@edw
edw / pbcopy.el
Created October 24, 2012 15:56
Emacs OS X clipboard integration for console use.
(defun pbcopy (start end)
;; Useful for when you're doing 'emacs -nw' and you can't select
;; text in Terminal.app because you've split the terminal with
;; multiple buffers visible.
(interactive "rSend region to OS X pasteboard:")
(shell-command-on-region start end "pbcopy"))