This file contains hidden or 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 shlex | |
| import subprocess | |
| from lib_joel import fnprint | |
| class sp_error(StandardError): | |
| pass | |
| def get_out(cmd): | |
| '''execute shell command in subprocess, return result''' |
This file contains hidden or 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 os | |
| import sys | |
| def findmod(targetMod): | |
| lstOut = [] | |
| for myDir in sys.path: | |
| if os.path.isdir(myDir) and "%s.py"%targetMod in os.listdir(myDir): | |
| lstOut.append(myDir) | |
| return lstOut |
This file contains hidden or 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 | |
| from collections import namedtuple | |
| from itertools import islice as itslice | |
| def sdict(ntpl, keys, defval = None): | |
| return {k: getattr(ntpl, k, defval) for k in keys} | |
| class ParseHolder(object): | |
| attribs = {} | |
| def __init__(self): |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <string.h> | |
| int main(){int myi=1;char stout[26];char stmid[2];while(myi<=13){sprintf(stmid,"%02X",myi*2);strcat(stout,stmid);myi++;}printf("%s\n",stout);return 0;} |
This file contains hidden or 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 python | |
| # -*- coding: utf-8 -*- | |
| def myFunction(**kwargs): | |
| return attrSetter(myFunction,**kwargs) | |
| def attrSetter(target,**kwargs): | |
| for k,v in kwargs.iteritems(): | |
| setattr(target,k,v) | |
| return True |
This file contains hidden or 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 | |
| import os | |
| from subprocess import Popen, PIPE | |
| myWorkDir = '/home/jpmcgrady/workspace' | |
| def runGc(dirNameIn): | |
| os.chdir(dirNameIn) | |
| try: | |
| output = Popen(["git", "gc"], stdout=PIPE).communicate()[0] |
This file contains hidden or 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
| # -*- coding: latin-1 -*- | |
| from decimal import Decimal | |
| import re | |
| import operator as op | |
| d = lambda n: Decimal(n) | |
| lstFns=['+','-','*','/'] | |
| dictFns=dict(zip(lstFns,[op.__add__,op.__sub__,op.__mul__,op.__truediv__])) |
This file contains hidden or 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 python | |
| from Queue import Queue | |
| from threading import Thread | |
| from time import time, sleep | |
| from subprocess import Popen, PIPE | |
| class HostRangeGenerator(object): | |
| def __init__(self, lstIn): | |
| self.myList = [range(256) if x =="*" else [x] if hasattr(x,'real') else x for x in lstIn] | |
| self.A, self.B, self.C, self.D = self.myList |
This file contains hidden or 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 time | |
| class myNote(object): | |
| def __init__(self, myInt): | |
| self.name = myInt | |
| self.provided_time = None | |
| self.mytime = time.time() | |
| #we're going to consider every thing above here imported |
This file contains hidden or 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 main(): | |
| lstIn = "dog,horse,cat,trouser,shark,artichoke,constantine,Christmas,Antartica,Ninja,Sanitizer".split(",") | |
| lst1 = sorted(lstIn) #looks ok, but sorts on ord(c) | |
| print lst1 #uppers before lowers | |
| lst2 = sorted(lstIn, key=lambda x: x.lower()) #does a case insenstive sort | |
| print lst2 #what you'd expect from an alphabetic sort | |
| lstIn.sort(key=lambda x: (len(x),lst2.index(x))) #to sort on n vars, return an n-tupple | |
| print lstIn #list sorted by length of word then alphabet |