Skip to content

Instantly share code, notes, and snippets.

@harlantwood
harlantwood / index.md
Created September 27, 2012 07:32 — forked from runlevel5/gist:2866534
Spree 1.0.x deployment on Heroku
layout title date comments categories tags author
post
Spree 1.0 deployment on Heroku
2012-02-21 06:40
true
spree, heroku, ruby, deployment, cedar stack
Trung Lê
@semperos
semperos / clojure-deftype-scaffolding.clj
Created October 4, 2012 18:16
Clojure Scaffolding for deftype (Christophe Grand) - Show which methods a class implements and for which interfaces
;; Big thanks to Christophe Grand - https://groups.google.com/d/msg/clojure/L1GiqSyQVVg/m-WJogaqU8sJ
(defn scaffold [iface]
(doseq [[iface methods] (->> iface .getMethods
(map #(vector (.getName (.getDeclaringClass %))
(symbol (.getName %))
(count (.getParameterTypes %))))
(group-by first))]
(println (str " " iface))
(doseq [[_ name argcount] methods]
(println
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(dedupe)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
@chinshr
chinshr / Jenkinsfile
Last active May 20, 2025 13:10
Best of Jenkinsfile, a collection of useful workflow scripts ready to be copied into your Jenkinsfile on a per use basis.
#!groovy
# Best of Jenkinsfile
# `Jenkinsfile` is a groovy script DSL for defining CI/CD workflows for Jenkins
node {
}
@brianfay
brianfay / my-assoc-in.clj
Created November 22, 2015 00:57
my-assoc-in
(defn my-assoc-in
[m [k & ks] v]
(if (empty? ks)
(assoc m k v)
(assoc m k (my-assoc-in (k m) ks v))))
@oliyh
oliyh / clj-sse.clj
Last active June 19, 2025 07:41
Clojure client for Server Sent Events (SSE)
(require '[clj-http.client :as http])
(require '[clojure.core.async :as a])
(require '[clojure.string :as string])
(require '[clojure.java.io :as io])
(import '[java.io InputStream])
(def event-mask (re-pattern (str "(?s).+?\r\n\r\n")))
(defn- parse-event [raw-event]
(->> (re-seq #"(.*): (.*)\n?" raw-event)
@raymcdermott
raymcdermott / decoding-jwt.clj
Last active October 26, 2022 05:47
Simple JWT Decoder in Clojure
(defn base64-decode
"Utility function over the Java 8 base64 decoder"
[to-decode]
(String. (.decode (Base64/getDecoder) ^String to-decode)))
(defn string->edn
"Parse JSON from a string returning an edn map, otherwise nil"
[string]
(when-let [edn (json/decode string true)]
(when (map? edn)
@jogo3000
jogo3000 / vdottii.clj
Last active April 2, 2025 13:14
Some formulas for finding equivalent performances based on a reference
;; Adaptations of equations found in Jack Daniels - Daniels' Running Formula in clojure
(import (java.lang Math))
(defn %VOmax
"Returns the percentage of VOmax a runner can sustain for the given duration"
[seconds]
(let [mins (/ seconds 60)]
(+ 0.8
(* 0.1894393
(Math/exp (* -0.012778 mins)))