I hereby claim:
- I am pedramamini on github.
- I am pedram (https://keybase.io/pedram) on keybase.
- I have a public key whose fingerprint is 0724 E980 0B61 5F47 F78E 850C 3232 2632 B543 8A67
To claim this, I am signing this object:
function parse_git_dirty() { | |
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "*" | |
} | |
function parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" | |
} | |
# requires the following in .gitconfig under [alias] section: | |
# unpushed = !GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD) && git log origin/$GIT_CURRENT_BRANCH..$GIT_CURRENT_BRANCH --oneline |
######################################################################################################################## | |
def levenshtein_distance (first, second): | |
""" | |
Provides the Levenshtein distance between two strings. ie: The number of transformations required to transform | |
one string to the other. | |
@type first: String | |
@param first: First string. | |
@type second: String | |
@param second: Second string. |
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env python | |
""" | |
What | |
Break an mbox file out into multiple files by year. | |
Written to chunk my GMail Takeout into manageable pieces. | |
Will prefix YEAR- to mbox name and *append* to those file names. | |
Who | |
Pedram Amini |
#!/usr/bin/env python | |
""" | |
Desktop Background Rotater | |
Background images: | |
http://bitday.me | |
Crontab entry: | |
# min hr mday month wday command |
#!/usr/bin/env python | |
# Extract URLs and related contact information from your OSX Messages.app database. | |
# | |
# TODO | |
# - automatically resolve username and discover contacts database (by largest item count if there is more than one). | |
# - make a machine parseable format. | |
# - keep track of last found URL (by hash?), allow for periodic run of script and addition to output. | |
# - update to latest gruber regex. |
class proxy: | |
""" | |
Hack to get Ruby methodmissing functionality. | |
""" | |
#################################################################################################################### | |
def __getattr__ (self, method_name): | |
''' | |
This routine is called by default when a requested attribute (or method) is accessed that has no definition. | |
Unfortunately __getattr__ only passes the requested method name and not the arguments. So we extend the |
# how to attach a function as a method instance to an arbitrary object. | |
class person: | |
def __init__ (self): | |
self.name = "" | |
def beast (self): | |
if self.name == "pedram": | |
return True | |
else: | |
return False |
import re | |
######################################################################################################################## | |
def blend_colors (first, second, scale=.5): | |
''' | |
Takes 2 RGB color hex values and blend them together. | |
''' | |
rold = (first & 0xFF0000) >> 16 | |
gold = (first & 0x00FF00) >> 8 |
import random | |
def random_fact (): | |
return facts[random.randint(0, len(facts)-1)] | |
facts = \ | |
[ | |
"Chuck Norris' tears cure cancer. Too bad he has never cried. Ever.", | |
"Chuck Norris does not sleep. He waits.", | |
"Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.", |