Skip to content

Instantly share code, notes, and snippets.

View ebaxt's full-sized avatar

Erik Bakstad ebaxt

View GitHub Profile
@ebaxt
ebaxt / core.clj
Created September 15, 2014 06:11
(ns ui.core
(:require [seesaw.core :as c]
[seesaw.border :as b])
(:gen-class :main true))
(defn send-msg [event]
(let [val (-> event
(c/to-frame)
(c/select [:#msg-txt])
public class LoggingHandler : DelegatingHandler
{
public LoggingHandler(HttpMessageHandler innerHandler)
: base(innerHandler)
{
}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Debug.WriteLine("Request:");
(defn path-info
"Returns the relative path of the request."
[request]
(or (:path-info request)
(:uri request)))
(defn authentication-failed []
{:status 401
:headers {"Content-Type" "application/json;charset=UTF-8"}
:body (json/write-str {:error "Unknown username or password."})})
@ebaxt
ebaxt / Duplicate
Last active December 19, 2015 22:39
Duplicate
(defresource put-delete-get [system path id json-body {:keys [find-by-id find-versions
create update delete-by-id validation-fn
has-permission] :or {has-permission (constantly true)}}]
:allowed-methods [:put :delete :get]
:available-media-types ["application/json"]
:allowed? (fn [{{method :request-method} :request}]
{::instance (find-by-id system id)})
:exists? ::instance
:can-put-to-missing? false
:new? false
@ebaxt
ebaxt / nginx.conf
Last active December 19, 2015 16:59
$ brew install nginx
$ cd /user/local/var/www
$ ln -s /Users/ebaxt/Projects/ardoq-front/src/css
$ ln -s /Users/ebaxt/Projects/ardoq-front/src/js
$ ln -s /Users/ebaxt/Projects/ardoq-front/src/less
$ ln -s /Users/ebaxt/Projects/ardoq-front/resources/public/img img
$ ln -s /Users/ebaxt/Projects/ardoq-front/src/html/* ./
$ pwd
/usr/local/var/www
@ebaxt
ebaxt / gist:5925835
Last active December 19, 2015 08:29
Mocking out friend current-authentication
(defn with-test-auth
([] (with-test-auth {}))
([credentials]
(fn [f]
(with-redefs-fn
{#'cemerick.friend/current-authentication
(fn [] (merge {:identity "test",
:username "test",
:email "foo@bar.com"} credentials))}
f))))
@ebaxt
ebaxt / pipe.clj
Last active December 10, 2015 23:29 — forked from pingles/pipe.clj
(let [[message-seq put] (pipe)]
(letfn [(message-handler [ch msg-meta payload]
(put {:ch ch :msg-meta msg-meta :payload payload}))]
(lc/subscribe ch qname message-handler :auto-ack true))
message-seq)
@ebaxt
ebaxt / pipe.clj
Created January 11, 2013 11:18 — forked from anonymous/pipe.clj
(defn pipe
"Returns a vector containing a sequence that will read from the
queue, and a function that inserts items into the queue.
Source: http://clj-me.cgrand.net/2010/04/02/pipe-dreams-are-not-necessarily-made-of-promises/"
[]
(let [q (LinkedBlockingQueue.)
EOQ (Object.)
NIL (Object.)
s (fn queue-seq []
(def fibs
(concat (lazy-seq [0 1]) (lazy-seq (map + fibs (rest fibs)))))
;fibs: 0 1 1 2 3 5 8...
;rest: n 0 1 1 2 3 5
;res: 0 1 2 3 5 8
; A
;[0 1
; (map + [0 1] [1]) => [0 1]
<technomancy> ebaxt: the problem is that the http connector for aether (called a wagon for whatever reason) isn't found
[01:12:02] jodaro (~user@nat-225.fw1.la.vclk.net) left IRC. (Ping timeout: 246 seconds)
[01:12:14] <technomancy> ebaxt: usually you see this when you're trying to deploy to some nonstandard repository type like S3
[01:12:21] ToBeReplaced (~ToBeRepla@c-68-48-103-153.hsd1.dc.comcast.net) left the channel.
[01:12:21] <aperiodic> dakrone: it seems to me that the proxy functionality doesn't work with SOCKS (i've got a local SOCKS tunnel open that my web browser is using fine, but i get the same no response exception w/clj-http)
[01:12:33] <technomancy> the fact that aether would be unable to find a wagon that it bundles with itself is bizarre