Skip to content

Instantly share code, notes, and snippets.

View xuhdev's full-sized avatar

Hong Xu xuhdev

View GitHub Profile
@xuhdev
xuhdev / emacs-configure.sh
Last active December 18, 2024 08:15
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 \
#!/bin/bash
# Usage:
# grepl [OPTIONS] [GREP-OPTIONS] PATTERN FILE
help() {
cat <<EOF
Usage: grepl [OPTIONS] [GREP-OPTIONS] PATTERN FILE
Options:
@xuhdev
xuhdev / to-complement-dimacs.py
Last active August 6, 2016 20:19
Convert a graph in DIMACS format to its complement graph
#!/usr/bin/python3
#
# Convert a DIMACS graph to its complement graph.
#
# Usage:
#
# to-complement.py < in-dimacs > out-dimacs
import sys
@xuhdev
xuhdev / gen-editorconfig-from-gitignore.sh
Last active August 3, 2016 01:11
Generate an editorconfig file from a gitignore file.
#!/bin/bash
# Generate an editorconfig file from a gitignore file. Usage:
#
# /path/to/gen-editorconfig-from-gitignore.sh < .gitignore >> .editorconfig
while read line
do
if [[ -z $line ]]
then
# 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
@xuhdev
xuhdev / gist:abb349c97307439bda4b
Created December 21, 2015 09:38
sphinx Issue 2188
Running Sphinx test suite (with Python 3.4.2)...
.........................................................................................................................................................................................................................................................................................................................................................................................................................E...............................................................................................................................................................................................................................................................................SS.....................................SSSSS.SSSS.
======================================================================
ERROR: test_build_latex.test_latex
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/user/.local/lib/p
#compdef setup.py
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for setup.py (http://docs.python.org/distutils/).
#
# ------------------------------------------------------------------------------
# Authors
# -------
@xuhdev
xuhdev / nm-enable.c
Created December 25, 2014 08:57
Enable and disable wireless via libnm-glib
/* Compile with
* gcc nm-test.c `pkg-config --cflags libnm-glib` `pkg-config --libs libnm-glib` `pkg-config --cflags glib-2.0` */
#include <string.h>
#include <nm-client.h>
#include <glib.h>
int main(int argc, const char * argv[])
{
NMClient * nm = nm_client_new();
@xuhdev
xuhdev / gist:29c75f8d3420f2bff5c1
Created December 16, 2014 19:06
nouveau-dmesg-debug
[ 3.428733] nouveau T[ VBIOS][0000:01:00.0] 0x89e9[ ]: NV_REG R[0x00d748] &= 0xffffffff |= 0x00000000
[ 3.428735] nouveau T[ VBIOS][0000:01:00.0] 0x89f6[ ]: NV_REG R[0x00d74c] &= 0xffffffff |= 0x00000000
[ 3.428736] nouveau T[ VBIOS][0000:01:00.0] 0x8a03[ ]: NV_REG R[0x00d794] &= 0xfffffeff |= 0x00000100
[ 3.428737] nouveau T[ VBIOS][0000:01:00.0] 0x8a10[ ]: NV_REG R[0x00d798] &= 0xfffffeff |= 0x00000100
[ 3.428738] nouveau T[ VBIOS][0000:01:00.0] 0x8a1d[ ]: GPIO
[ 3.428739] nouveau T[ VBIOS][0000:01:00.0] 0x8a1e[ ]: ZM_REG_SEQUENCE 0x02
[ 3.428740] nouveau T[ VBIOS][0000:01:00.0] 0x8a24[ ]: R[0x020000] = 0x80000000
[ 3.428741] nouveau T[ VBIOS][0000:01:00.0] 0x8a28[ ]: R[0x020004] = 0x001100eb
[ 3.428742] nouveau T[ VBIOS][0000:01:00.0] 0x8a2c[ ]: SUB_DIRECT 0x868a
[ 3.428743] nouveau T[ VBIOS][0000:01:00.0] 0x8a2f[ ]: NV_REG R[0x101000] &= 0xffffffff |= 0x80000000
@xuhdev
xuhdev / a.patch
Created October 9, 2014 09:42
patch to fix live preview
diff --git a/plugin/latexlivepreview.vim b/plugin/latexlivepreview.vim
index 03a5df5..767b64e 100644
--- a/plugin/latexlivepreview.vim
+++ b/plugin/latexlivepreview.vim
@@ -90,9 +90,11 @@ vim.command("let b:livepreview_buf_data['tmp_dir'] = '" +
tempfile.mkdtemp() + "'")
EEOOFF
- let b:livepreview_buf_data['tmp_src_file'] =
- \ b:livepreview_buf_data['tmp_dir'] . '/' . expand('%:r') .