Skip to content

Instantly share code, notes, and snippets.

View myselfhimself's full-sized avatar
🍫
Happy

Jonathan-David Schröder myselfhimself

🍫
Happy
  • France
View GitHub Profile
@DIYer22
DIYer22 / Detection Python Environment, Especially distinguish Spyder, Jupyter notebook, Qtconsole.py
Created May 8, 2018 12:46
Detection Python Environment, Especially distinguish Spyder, Jupyter notebook, Qtconsole
#!/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
@jubel-han
jubel-han / di-xquartz.sh
Created February 15, 2017 06:48
Installation or update xquartz on OS X
#!/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`
@ms5
ms5 / verbos-argpary-example.py
Last active August 24, 2023 13:37
manipulating log level with python argparse
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',
@uppfinnarjohnny
uppfinnarjohnny / container.py
Created April 14, 2012 16:59
Simple DI Container for Python, inspired by Pimple (http://pimple.sensiolabs.org/)
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]