Skip to content

Instantly share code, notes, and snippets.

@notgba
notgba / trace_decorator.py
Created December 1, 2015 17:23
Trace装饰器
import sys
import os
import linecache
def trace(f):
def globaltrace(frame, why, arg):
if why == "call":
return localtrace
return None
@notgba
notgba / timeout_decorator.py
Created December 1, 2015 17:20
timeout装饰器
import signal
import functools
# 定义一个Exception,后面超时抛出
class TimeoutError(Exception):
pass
def timeout(seconds, error_message='Function call timed out'):
@notgba
notgba / log_example.py
Created November 30, 2015 21:00
log to file and also print it to console
import logging
log_path = '/tmp'
log_name = 'log_example'
logFormatter = logging.Formatter('%(asctime)s %(message)s')
logger = logging.getLogger('log_example')
logger.setLevel(logging.INFO)
@notgba
notgba / ssl.rules
Created October 30, 2015 14:45 — forked from konklone/ssl.rules
nginx TLS / SSL configuration options for konklone.com
# Basically the nginx configuration I use at konklone.com.
# I check it using https://www.ssllabs.com/ssltest/analyze.html?d=konklone.com
#
# To provide feedback, please tweet at @konklone or email eric@konklone.com.
# Comments on gists don't notify the author.
#
# Thanks to WubTheCaptain (https://wubthecaptain.eu) for his help and ciphersuites.
# Thanks to Ilya Grigorik (https://www.igvita.com) for constant inspiration.
server {
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additonal system variables
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3
@notgba
notgba / network_diagnose.md
Created June 15, 2014 03:14
Useful Mac OS X network diagnose commands

some tools such as arping, arp-scan may need to be installed by homebrew.

####ifconfig ifconfigshows network interface information, such as interface name, tpye, IP address, Mac address, etc.

####host host www.google.com return domain's ip address.

@notgba
notgba / brew_cask_upgrade.md
Last active August 29, 2015 14:02
some brew-cask tips about upgrade apps.

####upgrade all apps(this will update ALL apps though they are the latest version)

sudo rm -rf "$(brew --cache)"
brew update

for app in $(brew cask list); do
  brew cask install --force "${app}"
done

Python 代码规范

Changelog:

  • 2014-05-12, v0.1, copied from previously worked project.

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt