-
name of the current banch
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
| GREEN="\[$(tput setaf 2)\]" | |
| RESET="\[$(tput sgr0)\]" | |
| export PS1="${GREEN}$PS1${RESET}" | |
| alias v="vim" | |
| alias ls="ls --color=auto" | |
| alias ll="ls -lah" | |
| alias grep="grep --color=auto" | |
| ainit() { source "$1"venv/bin/activate; } |
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 init | |
| echo a > a.txt | |
| git add a.txt && git commit -m "a" | |
| git checkout -b feature-b | |
| echo b > b.txt | |
| git add b.txt && git commit -m "b" | |
| git checkout master | |
| # ($) |
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
| # Python | |
| def counter(x): | |
| def f(): | |
| nonlocal x | |
| x += 1 | |
| return x | |
| return f | |
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 boto3 | |
| MAX_KEYS = 10 | |
| PAGE_SIZE_COUNT = 10 | |
| def s3_copy(src_bucket, src_prefix, dest_bucket, dest_prefix): | |
| """ | |
| Copies objects from Source Bucket Prefix to Destination Bucket Prefix. | |
| s3://srcbucket/srcprefix -> s3://destbucket/destprefix |
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 json | |
| def attach_branch(tree, branch): | |
| l = len(branch) | |
| node = branch[0] | |
| # If node doesn't exist get an empty subtree | |
| subtree = tree.get(node, {}) | |
| if l == 1: |
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 abc import ABC, abstractmethod | |
| RED = 'RED' | |
| YELLOW = 'YELLOW' | |
| GREEN = 'GREEN' | |
| class Light(ABC): | |
| @property | |
| @abstractmethod |
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 arith(a: 'initial term', d: 'common difference'): | |
| """Returns initial and subsequent arithmetic progression terms""" | |
| current = a - d | |
| def _(): | |
| nonlocal current | |
| current += d | |
| return current | |
| return _ |
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
| class MinHeap: | |
| """A min-heap using an array""" | |
| # storing tree in level-order | |
| arr = [] | |
| @staticmethod | |
| def parent(i): return (i - 1) // 2 | |
| @staticmethod | |
| def children(i): return (2*i + 1, 2*i + 2) | |
| def insert(self, 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
| # Total possible values in array | |
| # Array can only be sorted if it's in range [0, K) | |
| K = 10 | |
| def counting_sort(arr): | |
| counter = [0 for _ in range(K)] | |
| for a in arr: | |
| counter[a] += 1 |