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 retry(func, exception=Exception, num=3, wait=0.5): | |
""" | |
Example usage: | |
f = retry(open, IOError, num=3, wait=0.5)(file_path, 'w') | |
""" | |
def _retry(*args, **kwargs): | |
c = num | |
while True: | |
c = c-1 | |
try: |
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 python3 | |
# Copyright 2014 Matteo Bertini [email protected] | |
# Released as Public Domain | |
# | |
# Latest version: | |
# wget http://slug.it/backup-google-authenticator.py | |
# | |
# Requirements | |
# ============ | |
# |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Scola la pasta</title> | |
<style type='text/css'> | |
@import url(http://fonts.googleapis.com/css?family=Krona+One); | |
h1 { | |
font-family: 'Krona One', sans-serif; | |
font-size: 8em; | |
font-size: 8vm; |
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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
[ -z "$PS1" ] && return | |
# http://www.bradshawenterprises.com/blog/2008/5-ways-to-make-using-bash-more-productive/ | |
# erase old dups and skip commands starting with spaces | |
export HISTCONTROL="ignorespace:ignoredups" |
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
" naufraghi: move easily in tags | |
" tag->first, tselect->list, tjump->list-if-more-than-one | |
map <silent><C-Right> :exec("tjump ".expand("<cword>"))<CR> | |
map <silent><C-Left> :pop<CR> |
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
# This is the "normal" way | |
class C(object): | |
def __init__(self): | |
self._x = None | |
@property | |
def x(self): | |
return self._x | |
@x.setter # will copy C.x and add the setter | |
def x(self, value): | |
self._x = value |
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
package com.develer.circularsliderule; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.drawable.Drawable; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.MotionEvent; | |
import android.view.ScaleGestureDetector; | |
import android.view.View; |
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 find_implementing_classes(method): | |
""" | |
Given a method return all the classes the method is implemented in. | |
a.aaa() -> A.aaa | |
a.bbb() -> A.bbb | |
b.aaa() -> A.aaa | |
b.bbb() -> B.bbb | |
A.aaa == B.aaa -> True | |
A.bbb == B.bbb -> False | |
find_implementing_classes(b.aaa) -> [<class '__main__.A'>] |
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
git-svn-outgoing() { | |
need_stash=$(git st --por | cut -c 1-2 | grep M | cat) | |
if [ "$need_stash" ]; then | |
git stash > /dev/null | |
fi | |
git svn dcommit -n | grep diff-tree | while read line; do git show $(echo $line | cut -d' ' -f 3); done | |
if [ "$need_stash" ]; then | |
git stash pop > /dev/null | |
fi | |
} |
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 | |
from collections import defaultdict | |
def hgignore2skipped(filename): | |
localdir = os.path.dirname(os.path.abspath(os.path.expanduser(filename))) | |
def _iter_skipped(): | |
with open(filename) as lines: | |
for line in (l.strip() for l in lines): | |
if line.startswith("syntax:") or line.startswith("#") or not line: |