Skip to content

Instantly share code, notes, and snippets.

# INRES="1366x768" # input resolution
# OUTRES="1366x768" # output resolution
INRES="2560x1440" # input resolution
OUTRES="2560x1440" # output resolution
FPS="15" # target FPS
GOP="30" # i-frame interval, should be double of FPS,
GOPMIN="15" # min i-frame interval, should be equal to fps,
THREADS="2" # max 6
CBR="500k" # constant bitrate (should be between 1000k - 3000k)
QUALITY="veryfast" # one of the many FFMPEG preset
@tristanstraub
tristanstraub / stack.org
Last active October 3, 2016 03:35
Capture region to separate org buffer.
(defun append-text-to-buffer (buffer text)
  "Append to specified buffer the text of the region.
It is inserted into that buffer before its point.

When calling from a program, give three arguments:
BUFFER (or buffer name), START and END.
START and END specify the portion of the current buffer to be copied."
  (interactive
   (list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t))
@tristanstraub
tristanstraub / async-apply.cljs
Created December 29, 2016 20:51
Javascript async interop between callbacks/promises and channels
(ns service.async
(:require-macros [cljs.core.async.macros :as a])
(:require [cljs.core.async :as a]))
(defn <cb [f & args]
(let [out (a/chan)]
(apply f (conj (into [] args) #(a/close! out)))
out))
(defn <promise [f & args]
@tristanstraub
tristanstraub / gist:55f96bea4eea1a6027610bac7f148e47
Created January 20, 2017 02:06
One line pull/clone and update.
(cd .deploy && git pull) || git clone git@github.com:repository/path.git .deploy
@tristanstraub
tristanstraub / cb.clj
Created January 21, 2017 21:04
In clojure, call continuation passing style function and return a channel with result.
(defn- <cb
"Call an callback style function and return a channel containing the result of calling the callback"
[f & args]
(let [out (a/chan)]
(apply f (conj (into [] args) (fn [& args]
(a/put! out args)
(a/close! out))))
out))
(a/<!! (<cb (fn [cb] (cb-style-f 1 2 3 cb))))
@tristanstraub
tristanstraub / promise-async.clj
Created January 21, 2017 21:06
In clojure, call a function returning a promise and convert it to a channel
(defn- <promise
"Call a function that returns a promise and convert it into a channel"
[f & args]
(let [out (a/chan)
done (fn [& _] (a/close! out))]
(.then (apply f args) done done)
out))
https://engineering.linkedin.com/distributed-systems/log-what-every-software-engineer-should-know-about-real-time-datas-unifying
https://www.oreilly.com/ideas/questioning-the-lambda-architecture
http://www.paperplanes.de/2011/12/9/the-magic-of-consistent-hashing.html
http://www.benstopford.com/2015/04/28/elements-of-scale-composing-and-scaling-data-platforms/
http://www.benstopford.com/2015/02/14/log-structured-merge-trees/
https://www.confluent.io/blog/data-dichotomy-rethinking-the-way-we-treat-data-and-services/
http://adrianmarriott.net/logosroot/papers/LifeBeyondTxns.pdf
http://robertgreiner.com/2014/08/cap-theorem-revisited/
http://the-paper-trail.org/blog/consistency-and-availability-in-amazons-dynamo/
https://blog.parse.ly/post/1691/lucene/
[org.apache.kafka/kafka-clients "0.11.0.0"]
[spootnik/kinsky "0.1.16"]
(ns space.kafka
(:require [kinsky.client :as client])
(:import [java.util ArrayList Properties]
org.apache.kafka.clients.consumer.KafkaConsumer
[org.apache.kafka.clients.producer KafkaProducer ProducerRecord]
[org.apache.kafka.common.serialization StringDeserializer StringSerializer]
org.apache.kafka.common.TopicPartition
@tristanstraub
tristanstraub / tree.clj
Last active February 7, 2018 00:06
Compress clojure data structure -- find common subtrees and move them into a lookup table.
(ns trees
(:require [clojure.walk :as walk]))
(defonce id (atom 0))
(defrecord Ref [id])
(defn new-id! []
(->Ref (swap! id inc)))
@tristanstraub
tristanstraub / gist:d3afd14f7223ea3350b8c24b4d92a649
Created April 12, 2018 06:49
Start clojure socket repl and connect to it with netcal
clj -J-Dclojure.server.repl="{:port 1234 :accept clojure.core.server/repl}"
rlwrap -q ^Q nc 127.0.0.1 1234