This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue May 8 20:40:30 2018 | |
@author: yanglei | |
""" | |
''' | |
# Detection Python Environment, Especially distinguish Spyder, Jupyter notebook, Qtconsole |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -f | |
# Download and install (or update) Xquartz | |
APP_PATH='/Applications/Utilities/XQuartz.app' | |
UPDATES_URL='http://xquartz.macosforge.org/downloads/sparkle/release.xml' | |
DOWNLOAD_ACTUAL=`curl -sL "$UPDATES_URL" | tr '"' '\012' | egrep '^http.*\.dmg' | head -1` | |
REMOTE_VERSION=`curl -sL "$UPDATES_URL" | awk -F'"' '/sparkle:version=/{print $4}' | head -1` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import logging | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--verbose', '-v', action='count', default=1) | |
args = parser.parse_args() | |
args.verbose = 70 - (10*args.verbose) if args.verbose > 0 else 0 | |
logging.basicConfig(level=args.verbose, format='%(asctime)s %(levelname)s: %(message)s', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Container(dict): | |
def __init__(self, *args, **kwargs): | |
super(Container, self).__init__(*args, **kwargs) | |
self._shared = set() | |
self._instances = {} | |
def __getitem__(self, key): | |
if key in self._instances: | |
return self._instances[key] | |