Skip to content

Instantly share code, notes, and snippets.

@leoleozhu
leoleozhu / .gitconfig
Last active December 16, 2015 21:49
My ~/.gitconfig file.Includes general configurations, alias and difftools
[user]
name = First Last
email = [email protected]
[core]
excludesfile = ~/.gitignore
autocrlf = true
[alias]
ci = commit
@leoleozhu
leoleozhu / git with proxy.md
Last active December 21, 2016 15:48
use Git with proxy

install socat

sudo apt-get install socat

edit ~/.ssh/config

host github.com
    proxycommand socat - PROXY:localhost:%h:%p,proxyport=8080

###If you want to use SOCKS proxy, edit it like this. host bitbucket.org ProxyCommand socat - SOCKS:localhost:%h:%p,socksport=7070

@leoleozhu
leoleozhu / Foo.java
Created July 10, 2013 08:39
Use gson to parse integer array
package com.foo;
import java.util.Arrays;
import java.util.List;
import com.google.gson.Gson;
public class Foo {
private static List<Integer> toList(String json, Gson parser) {
@leoleozhu
leoleozhu / random-str.py
Last active December 23, 2015 19:49
Generate random string with python. Charset used can be specified via parameters.
#!/usr/bin/env python
import getopt
import sys
import random
import string
DEFAULT_LENGTH = 16
def main():
@leoleozhu
leoleozhu / change-iptables.sh
Created January 26, 2014 05:40
iptables setting
#! /bin/bash
# Set the default policies to allow everything while we set up new rules.
# Prevents cutting yourself off when running from remote SSH.
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# Flush any existing rules, leaving just the defaults
iptables -F
@leoleozhu
leoleozhu / http-server.py
Created January 26, 2014 05:48
SimpleHTTPServer different port
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
# minimal web server. serves files relative to the
# current directory.
PORT = 8080
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
@leoleozhu
leoleozhu / python-server.py
Created March 5, 2014 09:20
Python Simple HTTP Server
import os
import posixpath
import urllib
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
# modify this to add additional routes
ROUTES = (
# [url_prefix , directory_path],
['', 'E:\Dropbox\Other\python-server'], # empty string for the 'default' match
VM=`docker-machine ls 2>/dev/null | sed -n 2p | awk '{print $1}'`
[ -z "$VM" ] && VM=default
@leoleozhu
leoleozhu / AffineTransformTests.java
Last active August 17, 2019 06:24
Affine Transform Example
package document.transform;
import com.itextpdf.kernel.geom.AffineTransform;
import com.itextpdf.kernel.geom.Point;
import junit.framework.TestCase;
import org.junit.Test;
public class AffineTransformTests extends TestCase {
@leoleozhu
leoleozhu / fonttools_fontinfo.py
Created August 16, 2019 14:41
Get FontFamily, Styles from a TTFont object (python fonttools lib)
class TTFontInfo(object):
bold_names = ("bold", "demibold", "demi-bold", "demi bold", "negreta", "demi",)
italic_names = ("italic", "cursiva", "oblique", "inclined",)
bold_italic_names = ("bolditalic", "bold-italic", "bold italic", "boldoblique", "bold-oblique",
"bold oblique", "demibold italic", "negreta cursiva", "demi oblique",)