This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defpartial | |
"Create a function that returns html using hiccup. The function is | |
callable with the given name." | |
[fname params & body] | |
`(defn ~fname ~params | |
(h.core/html | |
~@body))) | |
(defmacro fn-partial | |
"Create a function that returns html using hiccup." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
running: | |
(clojure.java.shell/sh "sh" (str "-c " "\"ls -l\"")) | |
returns: | |
{:exit 2, :out "", :err "sh: - : invalid option\nUsage:\tsh [GNU long option] [option] ...\n\tsh [GNU long option] [option] script-file ...\nGNU long options:\n\t--debug\n\t--debugger\n\t--dump-po-strings\n\t--dump-strings\n\t--help\n\t--init-file\n\t--login\n\t--noediting\n\t--noprofile\n\t--norc\n\t--posix\n\t--protected\n\t--rcfile\n\t--restricted\n\t--verbose\n\t--version\nShell options:\n\t-irsD or -c command or -O shopt_option\t\t(invocation only)\n\t-abefhkmnptuvxBCHP or -o option\n"} | |
readably: | |
{:exit 2, :out , :err sh: - : invalid option | |
Usage: sh [GNU long option] [option] ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Location /svn> | |
DAV svn | |
SVNParentPath /var/www/svn | |
SSLRequireSSL | |
AuthType Basic | |
AuthName "Restricted Files" | |
AuthUserFile "/etc/bugzilla/passwords" | |
AuthGroupFile "/etc/bugzilla/groups" | |
# Require group Bugzilla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro to-map [] | |
(let [keys# (keys &env) | |
keywords# (map keyword keys#)] | |
`(zipmap [~@keywords#] [~@keys#]))) | |
;-> (let [c 1] (let [a 1 b (inc a)] (to-map))) | |
;{:c 1, :a 1, :b 2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn diff-vals | |
[old new] | |
(let [new-minus-old (difference (into #{} (vals new)) | |
(into #{} (vals old)))] | |
(map-invert (select-keys (map-invert new) new-minus-old)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro let-map | |
"Avoids having to build maps from let bindings manually" | |
[bindings] | |
(let [names (->> (tree-seq #(or (vector? %) (map? %)) identity bindings) | |
(filter symbol?)) | |
bindings (destructure bindings)] | |
`(let [~@bindings] | |
(zipmap [~@(map (comp keyword name) names)] | |
[~@names])))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pomoclojo.core | |
(:import [org.apache.commons.exec | |
PumpStreamHandler | |
DefaultExecutor | |
ExecuteWatchdog | |
CommandLine] | |
[java.io ByteArrayOutputStream]) | |
(:use [clj-time.core :only [in-secs in-minutes now interval plus minus within? minutes secs]])) | |
(defn execute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Books I've read that I recommend, pretty much in the order that I read them, I'm not listing books that I | |
considered to be too specific, without any generic and fundamental knowledge, or that could easily be replaced by other, similar books: | |
Code Complete 2 | |
Programming Pearls (didn't finish it yet) | |
The Pragmatic Programmer | |
Mythical Man Month | |
Effective C++ Scott Meyers | |
Design Patterns (Gang of Four) (good reference, but pretty dry) | |
Pattern Hatching (explains how they came up with them) | |
Refactoring (Martin Fowler, (google for the pdf, read the first few |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns swanker.core | |
(:require [swank.swank :as swank])) | |
(gen-class | |
:name swanker.core.ServletFilter | |
:prefix servlet- | |
:implements [javax.servlet.ServletContextListener]) | |
(comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.AbstractMethodError: null | |
at clojure.core.protocols/fn (protocols.clj:73) | |
clojure.core.protocols$fn__5828$G__5823__5841.invoke (protocols.clj:13) | |
clojure.core$reduce.invoke (core.clj:6030) |