Skip to content

Instantly share code, notes, and snippets.

View xuhdev's full-sized avatar

Hong Xu xuhdev

View GitHub Profile
@xuhdev
xuhdev / ascii2fits.py
Last active August 29, 2015 14:00
Convert an ascii table to a fits table
# convert an ascii table to a fits table
from astropy.table import Table
import sys
t = Table.read(sys.argv[1], format='ascii')
t.write(sys.argv[2], format='fits')
@xuhdev
xuhdev / example_input.conf
Last active August 29, 2015 14:01
Plot 2D histogram and its contour
# This is an example of input parameters
# the first plot starts here
plot1 = {}
# Path to the data file
plot1['data_file'] = 'bayes1.dat'
# which columns to plot?
plot1['col1'] = 2
plot1['col2'] = 3
@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') .
@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 / 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();
#compdef setup.py
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for setup.py (http://docs.python.org/distutils/).
#
# ------------------------------------------------------------------------------
# Authors
# -------
@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 / 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: