This file contains hidden or 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
(defun gbj-backup-shell (&optional arg) | |
"makes a copy of the current shell with timestamp appended to the filename" | |
(interactive) | |
(let* | |
( | |
(save-dir "~/build/shells/") | |
(orig-file arg) | |
(mod-str nil) | |
) | |
(if (not orig-file) |
This file contains hidden or 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
(lexical-let | |
((curbuf 0) | |
(buflist '("shell1" | |
"shell2" | |
"shell3" | |
"shell4" | |
"shell5" | |
"shell7" | |
"shell8" | |
"shell9" |
This file contains hidden or 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
First create a server with a socket repl using | |
clojure.contrib.server-socket: | |
(defn start-server[host port] | |
(create-repl-server port) | |
(repl)) | |
Then create a bunch of netbots and have each use a repl to communicate | |
with the server repl. Have that repl request a new job from |
This file contains hidden or 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 gjahad.socket-repl | |
(:use clojure.main) | |
(:use clojure.contrib.server-socket) | |
(:import java.net.Socket) | |
(:import java.net.InetAddress) | |
(:import clojure.lang.LineNumberingPushbackReader) | |
(:import java.io.InputStreamReader) | |
(:import java.io.OutputStreamWriter)) | |
(def *port* 4455) |
This file contains hidden or 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
;; even more enhanced version with that allows ret val override and better prompt | |
;; Slightly enhanced version of Alex Osborne's debug-repl (http://gist.github.com/252421) | |
;; Typing () quits the debug REPL, making it possible to continue without terminating the | |
;; input stream by typing Ctrl-D. | |
;; Inspired by George Jahad's version: http://georgejahad.com/clojure/debug-repl.html | |
(ns clojure.contrib.debug | |
[:require clojure.main]) |
This file contains hidden or 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 tramp-fn [f] | |
(if (fn? f) | |
(fn [& args] #(apply f args)) | |
f)) | |
(defn tramp-fn2 [f] | |
(if (fn? f) (partial trampoline f) f)) | |
(defmacro letrec [bindings & body] | |
(let [bcnt (quot (count bindings) 2) |
This file contains hidden or 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
(use ' clojure.contrib.reflect) | |
(defn- gf [obj field] | |
[(keyword (.getName field)) (get-field (class obj) (.getName field) obj)]) | |
(defn get-all-fields [obj] | |
(into (sorted-map) (map (partial gf obj) (.getDeclaredFields (class obj))))) | |
;; user=> (def a (memoize (partial (comp inc last concat) [2]))) | |
;; #'user/a |
This file contains hidden or 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 gbj1 | |
(:require gbj2)) | |
(println "gbj1") | |
(defmacro remote-declare [name] | |
"defs the supplied ns-qualified name with no bindings, useful for creating circular dependencies" | |
(let [[ns v] (.split (str name) "/") | |
orig-ns (str *ns*)] | |
`(do (in-ns '~(symbol ns)) | |
(clojure.core/declare ~(symbol v)) | |
(in-ns '~(symbol orig-ns))))) |
This file contains hidden or 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 gbj2 | |
(:require gbj1)) | |
(println "gbj2") | |
(defmacro remote-declare [name] | |
"defs the supplied ns-qualified name with no bindings, useful for creating circular dependencies" | |
(let [[ns v] (.split (str name) "/") | |
orig-ns (str *ns*)] | |
`(do (in-ns '~(symbol ns)) | |
(clojure.core/declare ~(symbol v)) | |
(in-ns '~(symbol orig-ns))))) |
This file contains hidden or 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 remote-declare [name] | |
"declares the supplied ns-qualified name with no bindings, useful for creating circular dependencies" | |
(let [[ns v] (.split (str name) "/") | |
orig-ns (str *ns*)] | |
`(do (in-ns '~(symbol ns)) | |
(clojure.core/declare ~(symbol v)) | |
(in-ns '~(symbol orig-ns))))) | |
user> (remote-declare tmp8/a) | |
#<Namespace user> |
OlderNewer