Skip to content

Instantly share code, notes, and snippets.

View chetmancini's full-sized avatar

chet chetmancini

View GitHub Profile
@chetmancini
chetmancini / method_missing.py
Created May 11, 2016 16:49
Make a python class wrap another composed object
def _wrap_fn(params)
return params # do whatever here
def __getattr__(self, method_name):
return lambda msg: getattr(self._subobject, method_name)(self._wrap_fn(params))
@chetmancini
chetmancini / fetch_all.sh
Created February 19, 2016 13:36
A script to git-fetch all the repositories in a single directory.
#!/bin/bash
for dir in */;
do
dir=${dir%*/}
echo "###############################################################################"
echo ${dir##*/}
cd $dir
git fetch --all
git merge --ff-only
### Keybase proof
I hereby claim:
* I am chetmancini on github.
* I am chet (https://keybase.io/chet) on keybase.
* I have a public key whose fingerprint is 8C75 B5CF 1A1C D211 C5A4 34D3 0CD4 D498 9549 EA0A
To claim this, I am signing this object:
@chetmancini
chetmancini / random_words.py
Created December 20, 2013 14:55
Get a random list of 5 words. Imagine the possibilities.
#!/usr/bin/python
from random import shuffle
with open("/usr/share/dict/words") as f:
content = f.readlines()
shuffle(content)
for word in content[:5]:
print word
@chetmancini
chetmancini / countLinesOfCode.py
Last active October 3, 2015 14:47
Count the lines of code in Python dir.
def countLinesOfCode(path):
"""Procedure to count total lines of code in each file
"""
total = 0
listing = os.listdir(path)
for fname in listing:
if fname[-2:] == "py":
with open(fname) as f:
for i, l in enumerate(f):
if len(l) > 80:
@chetmancini
chetmancini / gist:866194
Created March 11, 2011 17:00
Compare the MD5 hashes of two files and return if their data is equal.
uses SysUtils, Classes, IdHashMessageDigest, idHash;
function TTesterApp.CompareHashes(const File1: string; const File2: string): Boolean;
function MD5(const FileName: string): string;
var
IDMD5: TIdHashMessageDigest5;
FileStream: TFileStream;
begin
idmd5 := TIdHashMessageDigest5.Create;