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 monthdelta(date, delta): | |
m, y = (date.month+delta) % 12, date.year + ((date.month)+delta-1) // 12 | |
if not m: m = 12 | |
d = min(date.day, [31, | |
29 if y%4==0 and not y%400==0 else 28,31,30,31,30,31,31,30,31,30,31][m-1]) | |
return date.replace(day=d,month=m, year=y) |
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
num = 100 | |
people = list(range(1,num+1)) | |
index = 0 | |
while len(people) > 1: | |
people.pop((index+1) % len(people)) | |
index = 0 if (index >= len(people)-1) else (index+1) | |
print people[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
# bash command to uninstall all pip installed packages | |
sudo pip uninstall -y $(pip freeze | sed 's;==.*;;g' | tr '\n' ' ') | |
# bash command to list top 5 large files/directories | |
du -a / | sort -n -r | head -n 5 |
OlderNewer