Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / .gitconfig
Last active December 16, 2015 21:49
My ~/.gitconfig file.Includes general configurations, alias and difftools
[user]
name = First Last
email = foo@example.com
[core]
excludesfile = ~/.gitignore
autocrlf = true
[alias]
ci = commit