Skip to content

Instantly share code, notes, and snippets.

View emidln's full-sized avatar

Brandon Adams emidln

  • Chicago, IL
View GitHub Profile
@danboykis
danboykis / file_size_rolling_appender.clj
Created July 25, 2017 16:10
a size based rolling appender
(ns example.file-size-rolling-appender
"Rolling file appender."
(:require [clojure.java.io :as io]
[taoensso.timbre :as timbre])
(:import [java.io File]
[java.text SimpleDateFormat]))
;; TODO Test port to Timbre v4
(defn- rename-old-create-new-log [^File log ^File old-log]
@divs1210
divs1210 / SLIP.py
Last active May 24, 2023 23:14
helps escape the Python's clutch
import types
# Helpers
# =======
def _obj():
'''Dummy object'''
return lambda: None
_FILLER = _obj()
@dimiro1
dimiro1 / calculator.thrift
Last active December 30, 2015 20:37
Implementation of the Thrift Servlet with Clojure Ring/compojure - A Working example https://github.com/dimiro1/thrift-clojure-example
service Calculator {
i64 sum(1: i64 a, 2: i64 b)
}
@mikeball
mikeball / core.clj
Last active June 3, 2020 13:22
Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; in project.clj dependencies
; [com.impossibl.pgjdbc-ng/pgjdbc-ng "0.5"]
(ns pglisten.core
(:import [com.impossibl.postgres.jdbc PGDataSource]
[com.impossibl.postgres.api.jdbc PGNotificationListener]))
@kendagriff
kendagriff / while.clj
Last active September 9, 2015 14:31
while->
(defmacro while->
"As long as the predicate holds true, threads
the expr through each form (via `->`). Once pred returns
false, the current value of all forms is returned."
[pred expr & forms]
(let [g (gensym)
pstep (fn [step] `(if (~pred ~g) (-> ~g ~step) ~g))]
`(let [~g ~expr
~@(interleave (repeat g) (map pstep forms))]
~g)))
@skwp
skwp / private_constants.rb
Created July 14, 2015 22:05
private_constants.rb
# A simple way to create private constants without all the noise of ruby's 'private_constant'
#
# Before:
# class Foo
# FOO = "bar"
# private_constant :FOO
# end
#
# After:
# class Foo
anonymous
anonymous / omni_mentor_trade.txt
Created July 14, 2015 02:02
4 Force of Will
4 Brainstorm
4 Ponder
4 Preordain
4 Show and Tell
4 Omniscience
4 Cunning Wish
2 Spell Pierce
4 Gitaxian Probe
4 Dig Through Time
;; extend honeysql
(defmethod honeyhelpers/build-clause :returning [ _ m cols]
(assoc m :returning (honeyhelpers/collify cols)))
(defmethod honeyfmt/format-clause :returning [[_ cols] _]
(str "RETURNING " (honeyfmt/comma-join (map honeyfmt/to-sql cols))))
(extend-protocol honeyfmt/ToSql
clojure.lang.Sequential
@MichaelDrogalis
MichaelDrogalis / gist:bc620a7617396704125b
Last active May 22, 2018 14:26
The Anatomy of an Onyx Program

The Anatomy of an Onyx Program

In this tutorial, we'll take an in-depth view of what's happening when you execute a simple Onyx program. All of the code can be found in the Onyx Starter repository if you'd like to follow along. The code uses the development environment with HornetQ and ZooKeeper running in memory, so you don't need additional dependencies to run the example for yourself on your machine.

The Workflow

At the core of the program is the workflow - the flow of data that we ingest, apply transformations to, and send to an output for storage. In this program, we're going to ingest some sentences from an input source, split the sentence into individual words, play with capitalization, and add a suffix. Finally, we'll send the transformed data to an output source.

Let's examine the workflow pictorially:

@ghadishayban
ghadishayban / weighted_rand.clj
Last active September 23, 2022 08:15
Vose's alias method for weighted randoms
(ns weighted-rand
(:import clojure.lang.PersistentQueue))
(defprotocol Rand
(nextr [_ rng]))
;; Vose's alias method
;; http://www.keithschwarz.com/darts-dice-coins/
(deftype Vose [n ^ints alias ^doubles prob]