Skip to content

Instantly share code, notes, and snippets.

@ChunMinChang
ChunMinChang / remove_c_style_comments.py
Last active March 12, 2024 16:42
Python: Remove C/C++ style comments #parser
#!/usr/bin/python
import re
import sys
def removeComments(text):
""" remove c-style comments.
text: blob of text with comments (can include newlines)
returns: text with comments removed
"""
pattern = r"""
@ChunMinChang
ChunMinChang / Linux.md
Last active February 28, 2024 18:35
Building gecko

Building Firefox on Linux

Get [mozilla-central][mozilla-central] via [git-cinnabar][cinnabar]

  1. Check if git is installed in your system
  2. Open terminal
    # Clone your own gecko repository
    git clone https://github.com/<your_username>/gecko-dev.git
    
@ChunMinChang
ChunMinChang / dav1d-install.md
Created November 9, 2023 01:16
one-stop manual for dav1d installation

How to install dav1d

Here is the one-stop manual. For more details (or latest information), please check https://code.videolan.org/videolan/dav1d.

Prerequirement

dav1d relies on meson build system (and ninja), so meson installation is required. It might be best to see https://mesonbuild.com/ to know how to do it, but here are the steps:

  1. Run $ sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build
  2. Run $ pip3 install meson (as root)
    • This is the best way to get the latest version of Mesonbuild. Due to our frequent release cycle and development speed, distro packaged software may quickly become outdated.
@ChunMinChang
ChunMinChang / README.md
Last active June 8, 2023 14:38
Simulate a C++ class in C for linked-list implementation

Class in C for linked-list implementation

An example to simulate a C++ class in C.

This is a comparison to [ChunMinChang/8e04130e778d77e0b30b8954cc5f2473][c++], which implement a linked-list in C++.

TODO

  • Implement delete function to remove a node from the list
  • Implement move function to move cursor to a specific node
  • Implement search function to return one specific node
@ChunMinChang
ChunMinChang / common.h
Last active February 13, 2023 08:12
Audio mixer: Downmix 5.1 to stereo or remap the channels
#ifndef COMMON
#define COMMON
#include <iostream>
#include <unistd.h>
#define DEBUG false // Set true to log the debugging messages.
#define LOG(...) DEBUG && fprintf(stdout, __VA_ARGS__)
template<typename T, size_t N>
@ChunMinChang
ChunMinChang / gdb.md
Last active December 19, 2022 17:10
Debugging gecko with gdb

Debugging gecko with gdb

Setup gecko-dev/.gdbinit

Suppose the gecko folder is /home/cm/Work/gecko-dev

Add the following lins to your /home/cm/Work/gecko-dev/.gdbinit

add-auto-load-safe-path /home/cm/Work/gecko-dev/build/.gdbinit
@ChunMinChang
ChunMinChang / testing-multi-gum.html
Created October 19, 2022 18:03
Test page for multi-mics in WebAudio, created by Paul Adenot
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta charset="utf-8">
<style>
* {
box-sizing: border-box;
}
.wrapper {
border: 1px dashed black;
padding: 1em;
max-width: 50vw;
@ChunMinChang
ChunMinChang / README.md
Last active March 6, 2022 13:23
Implementation of different methods to calculate the _Fibonacci_ numbers by fast doubling #recursion #dynamic_programming #Fibonacci #math

Calculating Fibonacci Numbers by Fast Doubling

Implementation of different methods to calculate the Fibonacci numbers by fast doubling.

Please read my blog post for more detail.

Reference

@ChunMinChang
ChunMinChang / Makefile
Last active October 18, 2021 07:02
opaque or transparent interface of the external library
all:
# Build a static library from the Rust file
rustc --crate-type=staticlib ext.rs
# Compile the C file with the static library
# gcc -o sample-c sample.c libext.a
gcc -o sample-c sample.c -L. -lext
./sample-c
# g++ -o sample-cpp sample.cpp libext.a
g++ -o sample-cpp sample.cpp -L. -lext
./sample-cpp
@ChunMinChang
ChunMinChang / alsa_channel_map.c
Last active September 26, 2021 12:03
Set channel map on ALSA
#include <alsa/asoundlib.h> // for ALSA APIs
#include <stddef.h> // for offsetof
#include <stdio.h> // for fprintf
#include <stdlib.h> // for calloc
#include <string.h> // for strcmp
#define DEBUG 1 // Set 1 to log the debugging messages.
#define LOG(...) DEBUG && fprintf(stdout, __VA_ARGS__)
#define ALSA_DEFAULT_DEVICE_NAME "default"