Skip to content

Instantly share code, notes, and snippets.

(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)
(lexical-let
((curbuf 0)
(buflist '("shell1"
"shell2"
"shell3"
"shell4"
"shell5"
"shell7"
"shell8"
"shell9"
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
(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)
@GeorgeJahad
GeorgeJahad / debug.clj
Created December 14, 2009 07:40 — forked from khinsen/debug.clj
yet another debug-repl fork
;; 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])
(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)
(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
(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)))))
(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)))))
(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>