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
| #!/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
| #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
| 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
| 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 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
| with openHDFS('/my/path/filename','w') as HFO: | |
| HFO.write('string A') | |
| ### on inpect /my/path/filename == 'string A' | |
| with openHDFS('/my/path/filename','w') as HFO: | |
| HFO.write('string B') | |
| ### on inpect /my/path/filename == 'string B' | |
| with openHDFS('/my/path/filename','a') as HFO: |
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
| /* | |
| * Copyright 2012 Twitter Inc. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
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 powerSet[A](s: Set[A]) = | |
| s.foldLeft(Set(Set.empty[A])) { | |
| (set, element) => | |
| set union (set map (_ + element)) | |
| } |
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
| from twisted.internet import reactor, defer, task | |
| import random | |
| from contextlib import contextmanager | |
| def dummyLRP(choices, max_wait = 30): | |
| """ | |
| dummy long running sort and select proces. | |
| """ | |
| d = defer.Deferred() | |
| to_wait = random.uniform(0, max_wait) |