Skip to content

Instantly share code, notes, and snippets.

View Kungi's full-sized avatar

Andreas Klein Kungi

  • DemandFlow GmbH
  • Germany
View GitHub Profile
(defproject clj-demgen-api "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.6.0"]
[com.taoensso/timbre "3.3.1"]
[com.novemberain/validateur "2.3.1"]
[com.sun.mail/javax.mail "1.5.2"]
[metosin/compojure-api "0.16.5"]
[metosin/ring-http-response "0.5.2"]
[metosin/ring-swagger-ui "2.0.17"]]
@Kungi
Kungi / A Bit more minimal example
Last active August 29, 2015 14:10
error during clj-http/post
(let [my-cs (clj-http.cookies/cookie-store)]
(http/post (str (url) "/login") {:params {:username "login"
:password "pass"}
:form-params {:username "login"
:password "pass"}
:cookie-store my-cs})
(let [csrftoken (url-decode (get-in (clj-http.cookies/get-cookies my-cs) ["csrftoken" :value]))]
(http/post (str (url) "/action/infocenter/1/upload-offer")
@Kungi
Kungi / anonymous-gist.clj
Created November 19, 2014 15:25
leiningen profiles
:profiles {:dev {:source-paths ["dev"]
:env {:http-port 3000
:context-path ""
:demgen-home "home"
:db-path "db"
:db-user "sa"
:db-pass ""}}
@Kungi
Kungi / anonymous-gist.clj
Created November 19, 2014 09:31
namespaces?
(def ^:dynamic *db* nil)
(defn run-migrations [db files direction]
(doseq [file files]
(binding [*ns* (find-ns 'clj-sql-up.migrate)
*db* db]
(files/load-migration-file file)
(println "Up found at: " (resolve direction)))
(println "Up found at: " (resolve direction))
@Kungi
Kungi / gist:cb735bb33b117bb60a58
Created October 15, 2014 08:46
Frameworkless Web Development in Clojure
Talk Title: Frameworkless Web Programming in Clojure
Content of the Talk:
1. Why Web Frameworks?
- Everything from one source (parts fit together)
- Good tooling support (see Django)
- Easy to set up
- Easy to use
@Kungi
Kungi / Querying the Uberjar
Last active August 29, 2015 14:07
Example /bootstrap//bootstrap.min.css
> $ curl -I 'http://localhost:40400/bootstrap/css/bootstrap.min.css' -H 'Accept: text/css,*/*;q=0.1' -H 'Cache-Control: max-age=0' -H 'X-DevTools-Emulate-Network-Conditions-Client-Id: A35742C9-1C67-620E-7D73-629A1F5B18B9' -H 'Referer: http://localhost:40400/login' -H 'If-Modified-Since: Tue, 07 Oct 2014 14:36:50 GMT' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36' --compressed
HTTP/1.1 304 Not Modified
Set-Cookie: ring-session=f6e2b275-1ccb-41fa-b6b8-1a59994e7426;Path=/
Set-Cookie: csrftoken=1pYlnSWA7Dmr1S7vBkpdSjNrd0x%2FH91cbpNBaPVfpjFvGEWHUMebCGSQGbaNSnHkqpeGD3VCz6YVsVc%2F;Path=/
Content-Type: text/css
Last-Modified: Tue, 07 Oct 2014 14:36:50 GMT
Content-Length: 101595
Content-Length: 0
Server: http-kit
(ns clj-demgen.plugin-test
(:require [clj-demgen.plugin :refer :all]
[clojure.test :refer :all]
[immutant.dev]))
(defn can-resolve? [symbol]
(not (nil? (resolve symbol))))
(defn can-not-resolve? [symbol]
(not (can-resolve? symbol)))
@Kungi
Kungi / anonymous-gist.
Created September 5, 2014 12:16
(immutant.dev/add-dependencies! '[incanter.core "1.5.5"])
1. Unhandled java.lang.IllegalArgumentException
Don't know how to create ISeq from: clojure.lang.Keyword
RT.java: 505 clojure.lang.RT/seqFrom
RT.java: 486 clojure.lang.RT/seq
RT.java: 578 clojure.lang.RT/first
core.clj: 55 clojure.core/first
dependency_exclusions.clj: 32 immutant.dependency-exclusions/exclude-immutant-deps/fn/fn
core.clj: 1370 clojure.core/complement/fn
core.clj: 2605 clojure.core/filter/fn
@Kungi
Kungi / anonymous-gist.clj
Last active August 29, 2015 14:05
fntest 2
(defmacro build-test-call [nses format to-file output-file]
(let [format-fn (cond (= format "tap")
'clojure.test.tap/with-tap-output
(= format "junit")
'clojure.test.junit/with-junit-output
:else 'identity)]
(if to-file
`(quote (with-open [results#
(java.io.FileWriter. ~output-file)]
(binding [clojure.test/*test-out* results#]
@Kungi
Kungi / anonymous-gist.clj
Created August 22, 2014 16:00
fntest 2
(defmacro build-test-call [nses format to-file output-file]
(let [format-fn (cond (= format "tap")
'clojure.test.tap/with-tap-output
(= format "junit")
'clojure.test.junit/with-junit-output
:else 'identity)]
(if to-file
`(quote (with-open [results#
(java.io.FileWriter. ~output-file)]
(binding [clojure.test/*test-out* results#]