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
FILE = 'input.txt' | |
DIRECTION_TO_DELTA = { | |
'L': (-1, 0), | |
'R': (1, 0), | |
'U': (0, 1), | |
'D': (0, -1), | |
} | |
def parse_moves(): |
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 collections import deque | |
from dataclasses import dataclass | |
import re | |
from typing import List, Optional, Tuple | |
FILE_METADATA_PATTERN = re.compile('^(?P<filesize>\d+)\s+(?P<filename>.+)') | |
DIR_METADATA_PATTERN = re.compile('^dir\s+(?P<dirname>.+)') | |
@dataclass |
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 collections import deque | |
from input import INPUT | |
def _detect_start_of_msg(s: str, n: int) -> int: | |
d = deque(s[0:n]) | |
i = n | |
while len(set(d)) < n: | |
d.popleft() | |
d.append(s[i]) |
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 re | |
from typing import List, Tuple | |
def get_lines() -> List[str]: | |
with open('input.txt', 'r') as f: | |
return f.readlines() | |
def parse_stacks() -> List[List[str]]: |
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
bar |
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
# ruby 2.5.0, rails 5.1.4 | |
key = SecureRandom.hex(32) # Need 256 bits = 32 bytes of entropy. Since in hex it will be 64 characters long. | |
data = 'example data that I want to hmac could be json string of a big Hash for example' | |
hmac_bytes = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, data) # raw bytes (in string representation) | |
hmac_base64 = Base64.urlsafe_encode64(hmac_bytes) # often sending in a link so I use urlsafe version |
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
export EDITOR='emacs' | |
# meta | |
alias eb='emacs ~/.bash_profile' | |
alias sb='source ~/.bash_profile' | |
# nav | |
alias ..='cd ..' | |
alias ~='cd ~' | |
alias ls='ls -G' |