Skip to content

Instantly share code, notes, and snippets.

View csukuangfj's full-sized avatar
👀
I may be slow to respond.

Fangjun Kuang csukuangfj

👀
I may be slow to respond.
  • Xiaomi Corporation
  • Peking
View GitHub Profile
@csukuangfj
csukuangfj / gist:24f04f881c61ff5a79d7b13d8f011cce
Created September 19, 2023 14:19 — forked from Jackarain/gist:ecc6594ef6930db7fa7f
Linking libstdc++ statically
Linking libstdc++ statically
Christopher Baus writes about his problems linking libstdc++ statically. Yes, making C++ binaries that will work properly in different Linux distributions is somewhat painful. The problem is not so much linking libstdc++ statically – it is just a library, after all – but the runtime support required by C++ code in general, to enable features like RTTI and exception handling.
The runtime support code used by different parts of a C++ application needs to be compatible. If one part of the program needs to dynamic_cast or catch objects provided by another, both parts must agree on certain implementation details: how to find vtables, how to unwind the stack, and so on.
For C++ and a few other GCC-supported languages with similar features, such details are specified by a C++ ABI. Whenever the ABI used by GCC changes you'll end up with incompatible libraries produced by the different GCC versions. The same is true for plain C, but the C ABI is much simpler and has been around a lot lon
@csukuangfj
csukuangfj / QGraphicsSceneTest.cpp
Last active June 23, 2023 19:30 — forked from benjbaron/QGraphicsSceneTest.cpp
Qt QGraphicsScene click, select, move, resize, delete QGraphicsItems
// Copyright 2017. All Rights Reserved.
// Author: csukuangfj@gmail.com (Fangjun Kuang)
#include <QtGui>
#include <QGraphicsRectItem>
#include <QGraphicsView>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
class CustomItem : public QGraphicsEllipseItem

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@csukuangfj
csukuangfj / ffmpeg.md
Created April 7, 2023 03:14 — forked from whizkydee/ffmpeg.md
using ffmpeg to extract audio from video files

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:

@csukuangfj
csukuangfj / project_1.md
Created October 17, 2017 10:41 — forked from anonymous/project_1.md
Project READMEs - 3D Reconstruction with Computer Vision

Project 1: Panorama stitching

Due: 23 Sept 2014, 11:59pm

In this project, you'll write software that stitches multiple images of a scene together into a panorama automatically. A panorama is a composite image that has a wider field of view than a single image, and can combine images taken at different times for interesting effects.

Your image stitcher will, at a minimum, do the following:

@csukuangfj
csukuangfj / spline.c
Last active July 6, 2019 16:53 — forked from svdamani/spline.c
Natural Cubic Spline Interpolation in C
/** Numerical Analysis 9th ed - Burden, Faires (Ch. 3 Natural Cubic Spline, Pg. 149) */
#include <stdio.h>
int main() {
/** Step 0 */
int n, i, j;
scanf("%d", &n);
n--;
float x[n + 1], a[n + 1], h[n], A[n], l[n + 1],
u[n + 1], z[n + 1], c[n + 1], b[n], d[n];
@csukuangfj
csukuangfj / toggle_keybindings.tmux.conf
Created December 7, 2018 02:25 — forked from samoshkin/toggle_keybindings.tmux.conf
tmux.conf excerpt to toggle on/off session keybindings and prefix handling
bind -T root F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\
set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\
set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off F12 \
@csukuangfj
csukuangfj / BingConvert.cs
Created July 28, 2018 04:08 — forked from RosaryMala/BingConvert.cs
Functions to convert between WGS84 and bing mercator
using System;
public class BingConvert
{
public static double[] WGS84toGoogleBing(double lon, double lat)
{
double x = lon * 20037508.34 / 180;
double y = Math.Log(Math.Tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return new double[] { x, y };
@csukuangfj
csukuangfj / FindMKL.cmake
Created July 9, 2018 02:58
FindMKL.cmake
################################################################################
#
# \file cmake/FindMKL.cmake
# \author J. Bakosi
# \copyright 2012-2015, Jozsef Bakosi, 2016, Los Alamos National Security, LLC.
# \brief Find the Math Kernel Library from Intel
# \date Thu 26 Jan 2017 02:05:50 PM MST
#
################################################################################
@csukuangfj
csukuangfj / tmux-cheatsheet.markdown
Created May 28, 2018 12:58 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname