- Run a simple web server
$ while true; do printf 'HTTP/1.1 200 OK\n\n%s' "Hello World" | nc -l 8000; done- Validate it's running
$ curl http://127.0.0.1:8000$ while true; do printf 'HTTP/1.1 200 OK\n\n%s' "Hello World" | nc -l 8000; done$ curl http://127.0.0.1:8000| import hashlib | |
| import hmac | |
| class Signature(object): | |
| """Signature Validates Github Webhook Payload""" | |
| def sign_request(self, webhook_secret, data): | |
| """Generate Payload Signature""" |
| #! /usr/bin/env python | |
| from base64 import b64decode | |
| from github import Github | |
| with open('access-token.txt') as token_file: | |
| token = token_file.read().strip() | |
| api = Github(token) | |
| site = api.get_repo('nottrobin/gh-cms-example-site') |
https://docs.github.com/en/developers/apps/authenticating-with-github-apps
pip install pyjwt
pip install cryptography
pip install pycryptodomeCreate the token from installation ID
| def solution(A): | |
| count = 0 | |
| peaks = [] | |
| for i in range(len(A)): | |
| if i > 0 and i != (len(A)-1) and A[i] > A[i-1] and A[i] > A[i+1] and A[i] not in peaks: | |
| peaks.append(A[i]) | |
| count += 1 | |
| return count | |
| from collections import Counter | |
| def solution(A): | |
| """Gets the index of the dominator of array A""" | |
| counter = Counter() | |
| for i, v in enumerate(A): | |
| counter[v] += 1 | |
| counter = counter.most_common() |
| from collections import Counter | |
| def is_unique(word): | |
| # O(N) | |
| # ASCII Table Chars | |
| chars_set = [False for i in range(128)] | |
| for char in word: | |
| val = ord(char) |
| class SingleNode(): | |
| def __init__(self, data=None, next=None): | |
| self.data = data | |
| self.next = next | |
| def __repr__(self): | |
| return repr(self.data) | |
| class DoubleNode(): |
| """" | |
| Trees | |
| Trees are well known as a non-linear Data Structure. It doesn’t store data in a linear way. It organizes data in a hierarchical way. | |
| - Root: the topmost node of the tree | |
| - Edge: the link between 2 nodes | |
| - Child: a node that has a parent node | |
| - Parent: a node that has an edge to a child node | |
| - Leaf: a node that does not have a child node in the tree |