Skip to content

Instantly share code, notes, and snippets.

View craigbro's full-sized avatar

Craig Brozefsky (MIGRATED TO CODEBERG) craigbro

View GitHub Profile
Clojure Developer for Malware Analysis Product
The ThreatGRID team at Cisco is looking for experienced clojure
developers to work on our large scale, malware analysis product. Our
entire platform is built on Clojure, from the Clojurescript UI,
through the API services, around the event processing subsystem, and
down to the core.logic analysis engine.
Our system runs as a distributed cluster in the cloud, and shrunk
down to a single on-premises appliance. This keeps us focused on
@craigbro
craigbro / gist:5067961
Created March 1, 2013 21:30
stacktrace of clj-http catching a 406 but leaving a conn manager up
clojure.lang.ExceptionInfo: clj-http: status 406 {:object {:trace-redirects ["http://localhost:2280/artifact"], :status 406, :headers {"content-type" "text/plain; charset=utf-8", "date" "Tue, 26 Feb 2013 06:15:34 GMT", "transfer-encoding" "chunked"}, :body "could not access sandbucket\n"}, :environment {client #<client$wrap_output_coercion$fn__14723 clj_http.client$wrap_output_coercion$fn__14723@684a8f4b>, req {:request-method :get, :url "http://localhost:2280/artifact", :as :string, :conn-timeout 1000, :sock-timeout 1000, :query-params {:sample "e18a1a17d640e8160ad56013329dafad", :artifact "report.html"}}, resp {:trace-redirects ["http://localhost:2280/artifact"], :status 406, :headers {"content-type" "text/plain; charset=utf-8", "date" "Tue, 26 Feb 2013 06:15:34 GMT", "transfer-encoding" "chunked"}, :body "could not access sandbucket\n"}, status 406}}
at clj_http.client$wrap_exceptions$fn__14664.invoke(client.clj:87)
at clj_http.client$wrap_accept$fn__14740.invoke(client.clj:255)
at
user=> (doc read)
(01:30:31 PM) rhickey: -------------------------
(01:30:31 PM) rhickey: clojure.core/read
(01:30:32 PM) rhickey: ([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?])
(01:30:32 PM) rhickey: Reads the next object from stream, which must be an instance of
(01:30:32 PM) rhickey: java.io.PushbackReader or some derivee. stream defaults to the
(01:30:33 PM) rhickey: current value of *in*.
(01:30:33 PM) rhickey: Note that read can create arbitrary Java objects etc (controlled by *read-eval*),
(01:30:33 PM) rhickey: and as such should be used only with trusted sources.
(01:30:34 PM) rhickey: For data structure interop use edn-read
@craigbro
craigbro / immutant-deploy
Created January 25, 2013 18:51
A shell script for deploying an Immutant archive as if it was a regular unix daemon
#!/bin/sh
#
# This allows the deploy/undeploy/redeploy of an Immutant archive as
# if it was a daemon. The start/stop/restart methods block until that
# operation is done, so it works as init scripts are expected too.
set -e
IMA=/sandcastle/face/face.ima
DEPLOYDIR=/sandcastle/immutant/jboss/standalone/deployments
@craigbro
craigbro / gist:4636429
Created January 25, 2013 17:47
immutant cannot find itself
.StartException in service jboss.deployment.unit."face.ima".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "face.ima"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.x.incremental.129.jar:7.1.x.incremental.129]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
Caused by: java.io.FileNotFoundException: Could not locate immutant/utilities__init.class or immutant/utilities.clj on classpath:
at clojure.lang.RT.load(RT.java:432)
at clojure.la
@craigbro
craigbro / gist:4477860
Last active December 10, 2015 18:58
example for clj-http wrapper for testing web apps
(defn test-url [url & {:keys [login password require-auth]
:or {login "admin"
password "cha"
require-auth true}}]
(let [sess (session-for-root root-url)]
(when require-auth
(is (= (normalize-url sess "/login")
(last (:trace-redirects
(:last-response (session-get sess url)))))
"Request not redirected to login when unauthenticated."))
@craigbro
craigbro / gist:4445369
Created January 3, 2013 17:56
abstract draft
The Relational programming model provided by core.logic frees
developers from the impedance mismatch, and other limitations of
Object Relational Mapping systems (ORMs). This allows for massive
gains in write speed, schema flexibility, avoids the cost of
priviledging one set of entities or identities within the system, and
greatly reduces the complexities of modeling time and change.
(declare ^{:dynamic true} *request-hooks*)
(defn add-request-hook [fun]
(swap! *request-hooks* conj fun))
(defn request-hooks-handler
"Middleware that lets you set up a hook that is called on exit"
[handler]
(fn [request]
(binding [*request-hooks* (atom [])]
(defproject one "1.0.0-SNAPSHOT"
:description "Getting Started with ClojureScript."
:dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/clojurescript "0.0-1443"]
[domina "1.0.0-beta4"]
[ring "1.0.0-RC1"]
[compojure "0.6.4"]
[enlive "1.0.0"]
[org.mozilla/rhino "1.7R3"]
[com.google.javascript/closure-compiler "r1592"]