Skip to content

Instantly share code, notes, and snippets.

View xuhdev's full-sized avatar

Hong Xu xuhdev

View GitHub Profile
@xuhdev
xuhdev / ctags_with_dep.sh
Last active June 13, 2024 15:47
Generate ctags file for C or C++ files and its depedencies (included header files). This could avoid you to always generate a huge tags file.
#!/bin/sh
# https://www.topbug.net/blog/2012/03/17/generate-ctags-files-for-c-slash-c-plus-plus-source-files-and-all-of-their-included-header-files/
# ./ctags_with_dep.sh file1.c file2.c ... to generate a tags file for these files.
gcc -M "$@" | sed -e 's/[\\ ]/\n/g' | \
sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | \
ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
# Makefile template for a shared library in C
# https://www.topbug.net/blog/2019/10/28/makefile-template-for-a-shared-library-in-c-with-explanations/
CC = gcc # C compiler
CFLAGS = -fPIC -Wall -Wextra -O2 -g # C flags
LDFLAGS = -shared # linking flags
RM = rm -f # rm command
TARGET_LIB = libtarget.so # target lib
SRCS = main.c src1.c src2.c # source files
@xuhdev
xuhdev / Makefile
Created February 21, 2012 03:16
Makefile template for executable
# Makefile template for executable
CC = gcc # C compiler
CFLAGS = -Wall -Wextra -O2 -g # C flags
LDFLAGS = # linking flags
RM = rm -f # rm command
TARGET = program # target lib
SRCS = main.c \
src1.c \
@xuhdev
xuhdev / bashrc
Created February 24, 2012 10:06
Default bash prompt
export PS1='${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\$ '
@xuhdev
xuhdev / plot_ascii.py
Created March 17, 2012 08:48
Use matplotlib to plot scatter graph for ascii data
#!/bin/env python
# plot scatter graph for ascii data
#
# The file is read from stdin.
#
# data format:
#
# x0 y0
# x1 y1
@xuhdev
xuhdev / empty.tex
Created March 23, 2012 04:34
Empty latex template (For CJK)
\documentclass{article}
\usepackage{CJK}
\usepackage{indentfirst}
\usepackage[CJKbookmarks]{hyperref}
\usepackage{float}
\usepackage{amsmath,bm}
\usepackage{url}
\usepackage{graphicx}
\setlength{\parindent}{2em}
@xuhdev
xuhdev / plot_ascii.py
Created March 27, 2012 11:40
Use matplotlib to plot scatter point graph for a list of ascii data from standard input
#!/bin/env python
import matplotlib.pyplot as plt
import getopt
import sys
try:
opts, args = getopt.getopt(sys.argv[1:], 'x:y:')
except:
@xuhdev
xuhdev / zshrc
Created March 30, 2012 10:30
zsh prompt similar to the default bash prompt
export PS1='%n@%M:%~%% '
@xuhdev
xuhdev / test_liquid.rb
Created April 2, 2012 07:57
A simple command line tool to test liquid files
#!/usr/bin/env ruby
# test liquid
#
# Usage:
#
# ruby test_liquid.rb template
#
# e.g.
#
@xuhdev
xuhdev / find_pythoninterp.vim
Created April 3, 2012 06:23
A vimL function that finds python interpreter
" Find python interp. If found, return python command; if not found, return ''
function! FindPythonInterp()
if has('unix')
let l:searching_list = [
\ 'python',
\ 'python27',
\ 'python26',
\ 'python25',
\ 'python24',
\ '/usr/local/bin/python',