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 chardet # https://pypi.python.org/pypi/chardet | |
import os | |
import sys | |
import fnmatch | |
def detect(arg, dir, names): | |
for name in names: | |
if fnmatch.fnmatch(name, arg): | |
fpath = os.path.join(dir, name) | |
r = chardet.detect(fpath) |
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
#------------------------------------------------------------------------- | |
# Set up access mappings here. | |
#------------------------------------------------------------------------- | |
line_updated = False | |
if device_cutsheet_manager != None: | |
# Try the device cutsheet manager first. | |
line_updated = device_cutsheet_manager.set_access_info(lineinfo) | |
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 gcd(a,b): | |
while a != 0: | |
a, b = b % a, a | |
return b | |
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 math import sqrt | |
def gcd(a,b): | |
while a != 0: | |
a, b = b % a, a | |
return b | |
def sqrt_cf(D): | |
A = [] |
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
WIDTH = 7 | |
HEIGHT = 6 | |
NULL = " " | |
def connected_4(l): | |
# Tests whether or not the list, l, has | |
# four similar characters in a row. | |
last = None | |
run = 1 | |
for item in l: |
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 random | |
import sys | |
class Segment: | |
def __init__(self, listobj, length=1): | |
self.sequence = iter(listobj) | |
self.memory = [] | |
self.length = length | |
self.start = True | |
self.end = False |
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 sys | |
print "Reading from: %s" % sys.argv[1] | |
print "----------------------------------" | |
inf = open(sys.argv[1],'r') | |
for (line_no, l) in enumerate(inf.readlines()): | |
for (pos_no, c) in enumerate(l): | |
if ord(c) > 128: |
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 cust_specific_process(): | |
for bgline in taqua_glob.bg_line_entries_list: | |
# Try to get mlhg lineinfo objects | |
mlhgs = [] | |
try: | |
bg = bgline.parent_bg | |
mlhgs = bg.lineinfo[si.BG_MLHGS] | |
except: | |
pass |
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
# Not much fun unless you have one of these: | |
# http://www.instructables.com/id/The-4x4x4-LED-cube-Arduino/ | |
# | |
import random | |
DEBUG = True # Visualize the movement. Hit/hold return to progress the snake | |
CUBESIZE = 4 | |
ouf = open("snake.txt",'w') |
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
# https://pypi.python.org/pypi/python-dateutil/2.5.3 | |
# https://dateutil.readthedocs.io/en/stable/ | |
from dateutil import parser # pip install python-dateutil | |
if __name__ == '__main__': | |
try: | |
a = parser.parse("18 Aug 2001") | |
print a | |
b = parser.parse("2016-04-05 12:33:55") | |
print b |
OlderNewer