Skip to content

Instantly share code, notes, and snippets.

View huwan's full-sized avatar

Hu Wan huwan

  • City University of Hong Kong
  • 21:05 (UTC +08:00)
View GitHub Profile
@huwan
huwan / pdf2eps.sh
Created April 7, 2016 10:10
pdf2eps: A shell script for easy and efficient conversion pdf figures to eps
#! /bin/bash
# Alireza Haghdoost pdf2eps converter
# http://ce.sharif.edu/~haghdoost/mypages/pdf2eps.html
# http://tex.stackexchange.com/questions/20883/how-to-convert-pdf-to-eps
#
# Need xpdf(pdftops) and texlive-extra-utils(pdfcrop) package to work on Linux OS
#
# Usage: $ pdf2eps foo.pdf
# or $ pdf2eps *.pdf
function timer()
@huwan
huwan / bdcurl.sh
Created May 4, 2016 01:59 — forked from meoow/bdcurl.sh
百度云命令行(bash)上传下载脚本
#!/bin/bash
# Baidu Yun Command Line Interface
# Depends: bash, curl, grep, awk, sed, od
# (They are basicly builtin tools of any *nix system.)
# Additionally, fastupload depends: head, wc, md5sum or md5, cksum
# (Which are also builtin tools)
#### Variables ####
@huwan
huwan / bitbucket-pipelines.yml
Last active April 15, 2018 03:50 — forked from adujardin/bitbucket-pipelines.yml
Bitbucket pipeline file for latex document (including bibtex and upload to dropbox)
# SETTING UP :
# Generate an application token for your dropbox account and set it as environment variable named "DROPBOX_TOKEN"
# - https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/
# - https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html
# Set environment variable TEX_FILE according to the main tex file name
image: wanhu/texlive-basic:latest
pipelines:
default:
@huwan
huwan / bitbucket-pipelines.yml
Created April 24, 2018 12:35
Git+LaTeX+gitinfo2+dropbox
# SETTING UP :
# Generate an application token for your dropbox account and set it as environment variable named "DROPBOX_TOKEN"
# - https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/
# - https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html
# Set environment variable TEX_FILE according to the main tex file name
image: wanhu/texlive-basic:latest
pipelines:
default:
@huwan
huwan / extract-zhihu-answer-link.md
Last active February 18, 2019 15:07
从剪贴板提取知乎分享中的答案链接
@huwan
huwan / benchmark_time.c
Last active May 14, 2020 02:50
Calculates average time required to get the current time from the system in nanoseconds (from pmem/pmdk)
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define NSECPSEC 1000000000
/*
* benchmark_time.c -- benchmark_time module definitions
@huwan
huwan / tmpname.h
Created April 14, 2019 08:12
tmpname
#ifndef TMP_NAME_H
#define TMP_NAME_H 1
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <sys/time.h>
#include <string.h>
@huwan
huwan / .bashrc
Created April 14, 2019 13:06
BASH configuration
# https://unix.stackexchange.com/a/368927
prompt_command() {
# initialize the timestamp, if it isn't already
_bashrc_timestamp=${_bashrc_timestamp:-$(stat -c %Y "$HOME/.bashrc")}
# if it's been modified, test and load it
if [[ $(stat -c %Y "$HOME/.bashrc") -gt $_bashrc_timestamp ]]
then
# only load it if `-n` succeeds ...
if $BASH -n "$HOME/.bashrc" >& /dev/null
then
@huwan
huwan / thesis.sublime-project
Last active May 13, 2019 07:38
Sublime Text 3 project definition for LaTeX project
{
"folders":[
{
"path":".",
"name":"thesis",
"file_exclude_patterns":[
"*.blg",
"*.bbl",
"*.aux",
"*.log",
@huwan
huwan / install-gpu.sh
Created September 14, 2019 02:25
Install NVIDIA driver and CUDA toolkit (Ubuntu 18.04 + CUDA 10.0)
#! /bin/bash
# from https://www.tensorflow.org/install/gpu
# Add NVIDIA package repositories
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo apt-get update
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb