-
name of the current banch and nothing else (for automation)
git rev-parse --abbrev-ref HEAD -
all commits that your branch have that are not yet in master
git log master..<HERE_COMES_YOUR_BRANCH_NAME>
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
| from xml.etree import ElementTree | |
| def max_tree_depth(root): | |
| if root is None or len(root) == 0: | |
| return 0 | |
| return max([1 + max_tree_depth(child) for child in root]) | |
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
| from itertools import combinations | |
| S, N = input('').split(' ') | |
| N = int(N) | |
| def words_from_combos(s, n): | |
| # Get list of n dimensional combos | |
| combos = list(combinations(s, n)) |
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
| from itertools import groupby | |
| # Get input and convert it to list of integers | |
| list_ints = [int(i) for i in input('')] | |
| # Group ints into seperate arrays, create tuple of length, value | |
| len_val_tuples = [((len(list(g))), k) for k, g in groupby(list_ints)] | |
| for tup in len_val_tuples: |
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
| from itertools import combinations | |
| # Create ranges from X Y Z inputs | |
| X = range(int(input(''))+1) | |
| Y = range(int(input(''))+1) | |
| Z = range(int(input(''))+1) | |
| N = int(input('')) |
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
| # Get length of list | |
| N = int(input('')) | |
| # Convert string to list of letters & casted as integers | |
| INTS = (int(letter) for letter in input('').split(' ')) | |
| # Remove doubles by converting list of integers to set | |
| SET_INTS = set(INTS) | |
| # Convert back to list and sort |
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/local/bin/python3 | |
| import wikipedia | |
| if __name__ == '__main__': | |
| # Python Wikipedia article name | |
| article_name = "Python (Programming Language)" | |
| # Print first sentence from summary | |
| summary = wikipedia.summary(article_name) | |
| summary_first_sent = summary.split('.')[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
| from os import path | |
| from wordcloud import WordCloud | |
| d = path.dirname(__file__) | |
| # Read the whole text. | |
| text = open(path.join(d, 'python.txt')).read() | |
| # Generate a word cloud image | |
| wordcloud = WordCloud().generate(text) |
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 sys | |
| import crypt | |
| DICT_FILE = '/usr/share/dict/words' | |
| def main(arg): | |
| salt = '$6$Mqe5XrQt$' | |
| hashed_pass = arg | |
| with open(DICT_FILE) as f: | |
| for line in reversed(f.readlines()): | |
| if crypt.crypt(hashed_pass, salt) == line: |
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 | |
| import sys | |
| MEM_INFO_FILE = '/proc/meminfo' | |
| MEM_INFO_DELIM = ':' | |
| def main(args): | |
| mem_dict = dict() | |
| # Build mem_dict from file |
OlderNewer