Skip to content

Instantly share code, notes, and snippets.

View wangwenchao's full-sized avatar
🎯
Focusing

wwc wangwenchao

🎯
Focusing
View GitHub Profile
@wangwenchao
wangwenchao / tree.md
Last active August 29, 2015 14:07 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@wangwenchao
wangwenchao / bashrc
Last active August 29, 2015 14:18
bashrc_demo
# PATH
export PATH=$PATH:$HOME/bin:usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
# 为cd命令设定路径
export CDPATH=.:$HOME:/var/www
## set PS1 ##
PS1='{\u@\h:\w }\$ '
## 设定默认权限为644 ##
umask 022
#! /usr/bin/env bash
# Variables
APPENV=local
DBHOST=localhost
DBNAME=dbname
DBUSER=dbuser
DBPASSWD=test123
echo -e "\n--- Mkay, installing now... ---\n"
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
#!/bin/bash
export LANG="en_US.UTF-8"
MC=/Users/steve/Minecraft
# Many of these options are explaiend here:
# http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html
# http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
# http://blog.ragozin.info/2011/09/hotspot-jvm-garbage-collection-options.html
@wangwenchao
wangwenchao / 0_urllib2.py
Created August 22, 2016 13:36 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@wangwenchao
wangwenchao / golang-tls.md
Created October 20, 2016 03:43 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@wangwenchao
wangwenchao / gzip.go
Created November 1, 2016 11:46 — forked from iamralch/gzip.go
Gzip archives in Go
import (
"compress/gzip"
"fmt"
"io"
"os"
"path/filepath"
"strings"
)
func gzipit(source, target string) error {