Skip to content

Instantly share code, notes, and snippets.

View houtianze's full-sized avatar
🎯
Focusing

Hou Tianze houtianze

🎯
Focusing
View GitHub Profile
@houtianze
houtianze / 0_reuse_code.js
Created May 13, 2014 04:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@houtianze
houtianze / keybase.md
Created January 22, 2015 14:17
keybase.md

Keybase proof

I hereby claim:

  • I am houtianze on github.
  • I am ibic (https://keybase.io/ibic) on keybase.
  • I have a public key whose fingerprint is 9C78 1504 48BD 2ADB FEAF 172A 80AC 1205 0D24 AB23

To claim this, I am signing this object:

@houtianze
houtianze / buildapk.bat
Created April 12, 2016 00:53
A simple Windows batch file to build apk from a smali directory
:: you need to have apktool in your path
if not x%1==x goto doit
:usage
echo %~n0 ^<smali dir^>
goto end
:doit
set EXTRA_SIGN_AGS=
if not x%KEYPASS%==x set EXTRA_SIGN_AGS=-storepass %KEYPASS% -keypass %KEYPASS%
@houtianze
houtianze / Docker.VM.Creation.Tweak.md
Last active June 3, 2016 14:14
Docker VirtualBox VM (boot2docker) creation tweaks (adding in port forwarding, increase vram size)

For Non-Linux OSes (Windows, OS X etc) only, on which an installation of VirtualBox is needed to run Docker.

  • Locate and open file: <Docker Toolbox Installation Direcotry>\start.sh

  • Add in the following lines after $DOCKER_MACHINE create -d virtualbox --virtualbox-memory 2048 --virtualbox-disk-size 204800 $VM

  "${VBOXMANAGE}" modifyvm default --vram 16
  "${VBOXMANAGE}" modifyvm default --natpf1 "http,tcp,127.0.0.1,2375,,2375" 
@houtianze
houtianze / Fixing.Docker.Installation.On.Windows.md
Last active June 3, 2016 14:14
Fixing Docker Toolbox installation on Windows

The following is what I need to do to get Docker working on Windows after a fresh installation of Docker Toolbox (version 1.9.0, latest as the time of writting).

  • Fix the boot2docker VM port mappings using the commands here: https://gist.github.com/houtianze/bbe6d9af9f7e21bf1eef (bascially, map local port 2375 and 2376 to the VM)
  • Copy all the *.pem files from ~\.docker\machine\certs\ to ~\.docker\
  • Copy config.json from ~\.docker\machine\machines\default\ to ~\.docker\ (Btw, the name of the VM default is hardcoded in the script, and config.josn doesn't seem to be read by Docker, see docker/compose#1590 )
  • Create the following 2 environment variables:
    • DOCKER_TLS_VERIFY=1
    • DOCKER_CONFIG=<YOUR HOME DIRECTORY>\.docker
  • Run docker ps to verify that docker is working now
@houtianze
houtianze / gitpullall.sh
Created June 24, 2016 05:01
Perform recursive git pulling at the current / given directory
#!/bin/sh
pullall() {
curdir=`pwd`
if [ -d ".git" ]
then
echo "Git pulling at $curdir"
git pull
else
echo "Skipping non git directory $curdir"
@houtianze
houtianze / enable.sysv.script.md
Created September 21, 2016 09:25
Enable a SysV Init Script

(Assuming your executable script is called foo)

  1. Create your script in /etc/init.d/foo
  2. Add it chkconfig --add foo
  3. Enable it chkconfig foo on
@houtianze
houtianze / get.cert.md
Last active March 22, 2017 03:38
Get Cert in X509
function get_cert()
{
	local host="$1"
	local port="$2"
	if [ -z "$port" ]
	then
		port="443"
	fi
'use strict';
// Code not verified / tested though. -Tianze
var express = require("express");
var fs = require("fs");
var _ = require("underscore");
var dbJsonFileName = "carts.json";
var dbJson = fs.readFileSync(dbJsonFileName, 'utf8');