Skip to content

Instantly share code, notes, and snippets.

View xuhdev's full-sized avatar

Hong Xu xuhdev

View GitHub Profile
@xuhdev
xuhdev / generate-matlab-functions.sh
Last active April 23, 2024 08:12
highlight all important matlab functions in Vim
find . -type f | grep '.m$' | xargs basename -s .m | grep -v '^Contents$'
@xuhdev
xuhdev / emacs-configure.sh
Last active November 27, 2023 16:44
My Emacs configure (for build)
#!/bin/sh
# Configure Emacs build options.
./autogen.sh
mkdir build && cd build
# Replace `--with-pgtk` with `--with-cairo` if building for X11.
CFLAGS='-march=native -O3' ../configure \
--with-modules \
--with-xwidgets \
@xuhdev
xuhdev / ctags_with_dep.sh
Last active November 7, 2023 15:51
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
@xuhdev
xuhdev / empty_beamer.tex
Created October 7, 2012 22:41
Empty beamer template
\documentclass[14pt]{beamer}
\usetheme{Singapore}
\begin{document}
\begin{frame}
\end{frame}
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
#!/bin/bash
echo '#!/bin/bash'
echo ''
echo 'failed_items=""'
echo 'function install_package() {'
echo 'echo EXECUTING: brew install $1 $2'
echo 'brew install $1 $2'
echo '[ $? -ne 0 ] && $failed_items="$failed_items $1" # package failed to install.'
echo '}'
# 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
#!/usr/bin/python3
# This file is licensed under CC0 <https://creativecommons.org/publicdomain/zero/1.0/legalcode>
# https://www.topbug.net/blog/2016/12/13/send-git-patches-with-gui-email-clients/
import sys
import webbrowser
try:
@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 / my-vim-configure.sh
Created July 12, 2012 04:29
My Vim source configuration script
#!/bin/sh
./configure --with-features=huge --enable-pythoninterp --enable-python3interp --enable-perlinterp --enable-rubyinterp CFLAGS='-O3 -Wall -Wextra' $*