Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lehins's full-sized avatar

Alexey Kuleshevich lehins

View GitHub Profile
{-# LANGUAGE GHCForeignImportPrim #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnliftedFFITypes #-}
module MutInt
( MutInt,
newMutInt,
getMutInt,
putMutInt,
@chrisdone
chrisdone / gosper hurwitz.txt
Created October 2, 2018 15:41
precise math numerics
Appendix 2
Continued Fraction Arithmetic
by
@chrisdone
chrisdone / Do.hs
Last active November 8, 2017 18:19
Debug.Do
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE LambdaCase #-}
-- | Print out the values of all names bound by statments,
-- either x <- y, or let x = y in a do-expression.
--
-- * Enable {-# LANGUAGE TemplateHaskell #-} in your module.
-- * Import Debug.Do
-- * Prefix bindings with _ to ignore them e.g. _foo.
--
@nh2
nh2 / median-of-medians.hs
Created June 7, 2017 17:36
Fast median calculation in Haskell using the median-of-medians algorithm
-- TODO: Implement it for vectors, pull-request it into vector-algorithms
-- Based on http://austinrochford.com/posts/2013-10-29-median-of-medians-in-haskell.html
-- (which is slightly wrong because it can't deal with repeated elements,
-- see https://github.com/AustinRochford/blog-content/commit/ab32c7ab1ca1cd1555b87ec4edbeecbf03cad170#commitcomment-22433560
{-# LANGUAGE ScopedTypeVariables #-}
module Main (main) where
@nh2
nh2 / ToplevelVersionedSerialization.hs
Created April 28, 2017 14:37
Versioned serialisation in Haskell without per-value versioning overhead
-- This snippet shows an idea I had about versioned serialisation.
--
-- Many serialisation frameworks don't deal with backwards compatibility:
-- If the serialisation logic is changed, new programs can no longer
-- read data generated by old code.
--
-- This creates issues in upgradability, see e.g.
-- * https://www.reddit.com/r/haskell/comments/44w15q/psa_if_youre_serializing_floating_point_numbers/
--
-- Solutions so far included
@porjo
porjo / timelapse.md
Last active May 25, 2023 16:14
ffmpeg time-lapse

Convert sequence of JPEG images to MP4 video

Simple glob:

ffmpeg -r 24 -i '*.JPG' -s hd1080 -vcodec libx264 timelapse.mp4

Start from DSC_0079.JPG

ffmpeg -r 24 -f image2 -start_number 79 -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse2.mp4
;; Workaround the annoying warnings:
;; Warning (mumamo-per-buffer-local-vars):
;; Already 'permanent-local t: buffer-file-name
(when (and (equal emacs-major-version 24)
(equal emacs-minor-version 2))
(eval-after-load "mumamo"
'(setq mumamo-per-buffer-local-vars
(delq 'buffer-file-name mumamo-per-buffer-local-vars))))