Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
typing...

Tao He sighingnow

💭
typing...
View GitHub Profile
@sighingnow
sighingnow / Makefile
Last active May 26, 2021
Detect operating system in Makefile.
View Makefile
# Detect operating system in Makefile.
# Author: He Tao
# Date: 2015-05-30
OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG += -D WIN32
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
OSFLAG += -D AMD64
endif
@sighingnow
sighingnow / list_live_objects.py
Last active Mar 16, 2021
List live objects of certain type in current Python interpreter.
View list_live_objects.py
#!/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)
View cpp-tricks.md

Tricks in Modern C++

is_specialization_of

Whether the type is a specialization of template T.

template <template <typename...> class T, typename U>
@sighingnow
sighingnow / ffmpeg.md
Created Jun 30, 2019 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files
View ffmpeg.md

ffmpeg

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
sighingnow / Docset for LLVM and Clang.md
Last active Mar 27, 2019
Build docset for LLVM/Clang
View Docset for LLVM and Clang.md

Build LLVM/Clang Docset

  1. Modify LLVM/Clang doxygen.config.in

    • GENERATE_DOCSET = YES
    • DISABLE_INDEX = YES
    • SEARCHENGINE = NO
    • GENERATE_TREEVIEW = NO
    • GENERATE_TAGFILE =
      • LLVM: @abs_top_builddir@/doxygen/llvm(clang).tag
@sighingnow
sighingnow / .vimrc
Last active Sep 23, 2018
VIM config file.
View .vimrc
if &compatible
set nocompatible " Be iMproved
endif
set number
set confirm
set autoread
set spell
set clipboard+=unnamed
set mouse+=a
@sighingnow
sighingnow / hemispheres.mma
Created Oct 19, 2016
Night Hemispheres in Mathematica.
View hemispheres.mma
(* set geography data server *)
server := "http://www.staremapy.cz/naturalearth/`1`/`2`/`3`.png"
(* plot *)
GeoGraphics[{GeoStyling[Opacity[0.5], GeoServer -> server],
NightHemisphere[]},
GeoBackground -> GeoStyling["ReliefMap", GeoServer -> server]]
(* more simple graph *)
GeoGraphics[{NightHemisphere[Now], Red, Point[$GeoLocation]}]
@sighingnow
sighingnow / cgroup-limit-memory.c
Last active Jul 27, 2018
Limit memory usage with libcgroup interface.
View cgroup-limit-memory.c
#include <assert.h>
#include <libcgroup.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#define _GNU_SOURCE
#include <unistd.h>
@sighingnow
sighingnow / .gitconfig
Last active Jul 23, 2018
My gitconfig file.
View .gitconfig
[gui]
fontui = -family 微软雅黑Monaco -size 8 -weight normal -slant roman -underline 0 -overstrike 0
fontdiff = -family \"YaHei Consolas Hybrid\" -size 8 -weight normal -slant roman -underline 0 -overstrike 0
encoding = utf-8
warndetachedcommit = true
tabsize = 4
recentrepo = D:/Open/foundationdb-haskell
[user]
email = sighingnow@gmail.com
name = HE, Tao
@sighingnow
sighingnow / unsafe.hs
Last active Jul 6, 2018
Unsafe perform computation in some monads.
View unsafe.hs
import Control.Monad.ST
import System.IO.Unsafe
import Unsafe.Coerce
unsafePerformST :: ST s a -> a
unsafePerformST m = unsafePerformIO $
stToIO $ -- unsafely do it
unsafeCoerce m -- convert to ST Realworld a
{-# NOINLINE unsafePerformST #-}