Skip to content

Instantly share code, notes, and snippets.

View hailiang-wang's full-sized avatar
🌴
On vacation

Hai Liang W. hailiang-wang

🌴
On vacation
View GitHub Profile
@hailiang-wang
hailiang-wang / pandoc.template.zh.tex
Created June 21, 2017 05:15 — forked from farawayboat/pandoc.template.zh.tex
Chinese LaTeX template (using Ctex) for pandoc.
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$]{$documentclass$}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{euler}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use microtype if available
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
@hailiang-wang
hailiang-wang / example.cs
Created May 17, 2017 17:24 — forked from brandonmwest/example.cs
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));
@hailiang-wang
hailiang-wang / mk-opensource-license.sh
Created May 11, 2017 09:22
Script to make opensource license
#! /bin/bash
# Copyright 2017 hai liang wang <hailiang.hl.wang@gmail.com>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
#! /bin/bash
###########################################
# Test Wav file for xfyun api
# https://hub.docker.com/r/samurais/xfyun-api/
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
hostUri=localhost
port=9666
@hailiang-wang
hailiang-wang / Dockerfile.nvm
Created April 25, 2017 10:35
Install nvm inside docker
# install dependencies
RUN apt-get update && apt-get install -y \
curl \
npm \
nodejs \
git;
# compatibility fix for node on ubuntu
RUN ln -s /usr/bin/nodejs /usr/bin/node;
@hailiang-wang
hailiang-wang / pkl_to_json.py
Created April 20, 2017 02:12
Convert python pickle file to json
#!/usr/local/bin/python3
'''
Convert a pkl file into json file
'''
import sys
import os
import _pickle as pickle
import json
@hailiang-wang
hailiang-wang / deploy
Created April 4, 2017 07:37
shipyard-project.com
docker run \
-ti \
-d \
--restart=always \
--name shipyard-swarm-manager \
swarm:latest \
manage --host tcp://0.0.0.0:3375 etcd://172.29.31.152:4001
https://shipyard-project.com/docs/deploy/manual/
@hailiang-wang
hailiang-wang / database.service.ts
Created March 31, 2017 10:38
TypeScript Mongoose
/**
* Database management
*/
import * as mongoose from 'mongoose';
import logging from './logging.service';
import config from '../config/environment';
const logger = logging.getLogger('database.service');
mongoose.Promise = Promise;
// 链接数据库
@hailiang-wang
hailiang-wang / index.html
Created March 22, 2017 08:45 — forked from anonymous/index.html
React wrapper for Ace.js
<div id="app"></div>
@hailiang-wang
hailiang-wang / _service.md
Last active February 22, 2017 15:21 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)