Skip to content

Instantly share code, notes, and snippets.

View dgutov's full-sized avatar

Dmitry Gutov dgutov

View GitHub Profile
@kurlov
kurlov / mkv embed soft subtitles
Created December 16, 2017 23:41
ffmpeg command to add .srt based subtitles to an .mkv file
ffmpeg -i in.mkv -f srt -i in.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt out.mkv
@swannodette
swannodette / example-user.clj
Created May 4, 2012 11:39 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
(defn validates-credentials [username password]
(let [uc (count username)
pc (count password)]
(match [username uc password pc]
[(:or nil "") _ _ _] {:error "No username given" :field "name"}
[_ _ (:or nil "") _] {:error "No password given" :field "pass"}
[_ (_ :guard #(< % 3)) _ _] {:error "Username less than 3 characters" :field "pass"}
[_ _ _ (_ :guard #(< % 4))] {:error "Password less than 4 characters" :field "pass"}
[#"^([a-z0-9-_]+)$" _ _ _] {:error "Username contains invalid characters" :field "name"}
:else true)))
# Original blog post about Rubinius performance on the alioth mandelbrot benchmark:
# http://rfc2616.wordpress.com/2010/10/16/rubinius-vs-the-benchmark-from-hell/
#
# Problems with assumptions in the blog post:
# * The C <-> Ruby comparison is apples to oranges because the Ruby code
# is written to use blocks rather than loops. That imposes the overhead
# of additional execution contexts per pixel.
# * The output is written a byte at a time, which requires a fairly deep
# chain of methods before the byte is handed off to the OS.
# * The work is done in the script body. Unless the implementation has