Skip to content

Instantly share code, notes, and snippets.

sighingnow /
Last active Mar 16, 2021
List live objects of certain type in current Python interpreter.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import gc
def list_live_objects(ty=None):
def go(results, elements, bitset):
for elem in elements:
identity = id(elem)
sighingnow /
Created Jun 30, 2019 — forked from protrolium/
using ffmpeg to extract audio from video files


Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

sighingnow / Docset for LLVM and
Last active Mar 27, 2019
Build docset for LLVM/Clang
View Docset for LLVM and

Build LLVM/Clang Docset

  1. Modify LLVM/Clang

      • LLVM: @abs_top_builddir@/doxygen/llvm(clang).tag

Tricks in Modern C++


Whether the type is a specialization of template T.

template <template <typename...> class T, typename U>
sighingnow / bench-enum.hs
Created May 3, 2018
Benchmark on several implementations of `numericEnumFromThen` and `numericEnumFromThenTo`.
View bench-enum.hs
{-# LANGUAGE BangPatterns #-}
import Criterion.Main
import Weigh
numericEnumFromThen :: (Fractional a) => a -> a -> [a]
numericEnumFromThen n m = n `seq` m `seq` (n : numericEnumFromThen m (m+m-n))
numericEnumFromThenTo :: (Ord a, Fractional a) => a -> a -> a -> [a]
numericEnumFromThenTo e1 e2 e3
sighingnow / error-message
Created Apr 26, 2018
ghc treat certain kinds of warnings as errors when compile c source file.
View error-message
D:\Open>gcc test.c -Wall -c
test.c: In function 'g':
test.c:8:14: warning: passing argument 1 of 'f' from incompatible pointer type [-Wincompatible-pointer-types]
return f(cp);
test.c:1:5: note: expected 'int *' but argument is of type 'char *'
int f(int *a) {
D:\Open>stack exec -- ghc -c test.c -Wall
sighingnow /
Last active Dec 31, 2017 — forked from gyglim/
Logging to tensorboard with manually generated summaries (not relying on summary ops)
"""Simple example on how to log scalars and images to tensorboard without tensor ops.
License: Copyleft
__author__ = "Michael Gygli, Tao He"
import tensorflow as tf
from StringIO import StringIO
sighingnow / misc.hs
Created Jan 2, 2017
concatMap and filter using Foldable and Traversable.
View misc.hs
concatMap :: (Foldable f, Monoid (f b)) => (a -> f b) -> f a -> f b
concatMap = foldMap
filter :: (Applicative f, Foldable f, Monoid (f a)) =>
(a -> Bool) -> f a -> f a
filter p = foldMap (\a -> if p a then pure a else mempty)
sighingnow / Makefile
Last active Dec 27, 2016
Expose C++ API to Haskell via FFI.
View Makefile
all: libacpp.dll app.exe
GHC := stack ghc --
%.o: %.cpp
$(CXX) -c $< -o $@
libacpp.dll: acpp.o acpp_capi.o
$(CXX) $^ -shared -o $@ # On Linux/Unix, -fPIC is needed.
sighingnow / T.hs
Created Dec 27, 2016
Haskell's $ operator for types.
View T.hs
{-# LANGUAGE TypeOperators #-}
module T where
-- | Infix application.
-- @
-- f :: IO $ Maybe Int
-- =