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
def app_path(): | |
""" | |
Return the path of the application. | |
""" | |
if getattr(sys, 'frozen', False): | |
return os.path.dirname(sys.executable) | |
return os.path.dirname(__file__) |
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
def singleton(cls): | |
""" | |
Provide a decorator for the Singleton pattern | |
""" | |
instances = {} | |
def getinstance(): | |
if cls not in instances: | |
instances[cls] = cls() |
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
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate | |
from time import sleep | |
def read_temp(): | |
""" | |
Read temperature from w1 bus. | |
""" | |
with open("/sys/bus/w1/devices/28-000004ac7761/w1_slave") as f: | |
text = f.read() | |
secondline = text.split("\n")[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
#!/usr/bin/python | |
""" | |
Read the temperature from the connected sensor on the w1 bus and write it | |
to the LCD plate. If the temperature is below TEMP_LIMIT_L the backlight | |
color changes to blue. If the temperature is above TEMP_LIMIT_H the | |
backlight color changes to red. | |
This script uses the Adafruit LCD Plate as output device. Documentation and | |
about infos for Python implementation can be found here: |
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 itertools | |
>>> list_1 = [1, 2, 3] | |
>>> list_2 = [4, 5, 6] | |
>>> list(itertools.product(list_1, list_2)) | |
[(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6)] |
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
IMAGE, NAME, SHOP = range(COLUMN_COUNT) | |
class MyItem(object): | |
def __init__(self, name, image_filename, price) | |
self.name = name | |
self.price = price | |
self.image = QPixmap() | |
self.image.load(image_filename) | |
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 re | |
import os | |
from optparse import OptionParser | |
from glob import glob | |
#Set up option parser | |
parser = OptionParser() | |
(options, args) = parser.parse_args() | |
#define regex |
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
" Vim Plug Package Manager and minimal packages | |
call plug#begin('~/.vim/plugged') | |
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } | |
Plug 'sickill/vim-monokai' | |
call plug#end() | |
" Colorscheme | |
colorscheme monokai | |
" Common tweaks |
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
#Python2 | |
execfile("./filename") | |
#Python3 | |
exec(open("./filename").read()) |
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
# Hey Emacs, this is a -*- makefile -*- | |
#---------------------------------------------------------------------------- | |
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. | |
# | |
# Released to the Public Domain | |
# | |
# Additional material for this makefile was written by: | |
# Peter Fleury | |
# Tim Henigan | |
# Colin O'Flynn |
OlderNewer