Skip to content

Instantly share code, notes, and snippets.

View mozillazg's full-sized avatar
💭
I may be slow to respond.

Huang Huang mozillazg

💭
I may be slow to respond.
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from oauthlib.oauth2 import (
FatalClientError, OAuth2Error, TokenExpiredError, MobileApplicationClient
)
from requests_oauthlib import OAuth2Session, TokenUpdated
@mozillazg
mozillazg / webpy_main.py
Last active August 29, 2015 14:05
web.py return request headers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import web
urls = (
'/', 'Index',
)
@mozillazg
mozillazg / urldecode.py
Created September 11, 2014 07:16
urldecode like urllib.urlencode
import urlparse
def urldecode(query_str):
"""
>>> urldecode('a=1&b=2')
{'a': '1', 'b': '2'}
"""
return dict(urlparse.parse_qsl(query_str))
@mozillazg
mozillazg / upload_file.go
Created December 17, 2014 05:26
Upload file by go. Don't support custom headers.
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
@mozillazg
mozillazg / upload_file.go
Created December 17, 2014 05:33
Upload file by go. Support custom headers.
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
@mozillazg
mozillazg / bobp-python.md
Created November 16, 2015 06:14 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@mozillazg
mozillazg / vim74_lua
Created November 20, 2015 07:27 — forked from jdewit/vim74_lua
Installing vim 7.4 with lua on Ubuntu 12.04
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common
sudo apt-get build-dep vim-gnome
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev
sudo rm -rf /usr/local/share/vim
sudo rm /usr/bin/vim
@mozillazg
mozillazg / supervisord.service
Last active December 1, 2023 12:59 — forked from tonyseek/supervisord.service
install and configure supervisord on centos 7.
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
@mozillazg
mozillazg / nginx-nodejs-cors
Created January 15, 2016 11:20 — forked from m4ttbrock/nginx-nodejs-cors
Nginx Nodejs CORS to subdomain
server {
listen 80;
server_name subdomain.example.com;
access_log /var/log/nginx/example.access.log;
location / {
if ($http_origin ~* "https?://.*\.example\.com(:[0-9]+)?") {
set $cors "true";
@mozillazg
mozillazg / go_coverage
Last active May 1, 2016 03:57
Generate test coverage statistics for Go packages. https://mlafeldt.github.io/blog/test-coverage-in-go/
!/bin/sh
# Generate test coverage statistics for Go packages.
#
# Works around the fact that `go test -coverprofile` currently does not work
# with multiple packages, see https://code.google.com/p/go/issues/detail?id=6909
#
# Usage: go_coverage [ [--html | html] | --coveralls | --help ]
#
# --html Additionally create HTML report and open it in browser
# --coveralls Push coverage statistics to coveralls.io