Skip to content

Instantly share code, notes, and snippets.

@tetra5
tetra5 / git-overwrite-on-pull.sh
Created August 7, 2013 10:46
Force git to overwrite local files on pull
View git-overwrite-on-pull.sh
git fetch --all
git reset --hard origin/master
View Has weird right-to-left characters.txt
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
View hash.py
def _hash(entity):
try:
from hashlib import md5
except ImportError:
from md5 import new as md5
return int(md5(repr(entity)).hexdigest(), 16)
View url-matching-regexp
(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.
)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)
){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F
\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?
:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-
fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-
)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?
:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!
@tetra5
tetra5 / convertseconds.py
Last active December 14, 2015 12:48
Convert seconds to hⓂ️s with divmod
View convertseconds.py
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
print "%d:%02d:%02d" % (hours, minutes, seconds)
@tetra5
tetra5 / homedirectory.py
Created February 21, 2013 05:41
Cross-platform ways of getting user's home directory
View homedirectory.py
import os
os.getenv("HOME")
os.environ["HOME"]
os.path.expanduser("~")
@tetra5
tetra5 / fizzbuzz.py
Last active August 8, 2017 03:16
FizzBuzz
View fizzbuzz.py
for i in range(1, 101):
print "Fizz" * (not i % 3) + "Buzz" * (not i % 5) or i
print " ".join("Herp" * (not i % 3) + "Derp" * (not i % 5) or str(i) for i in range(1, 101))