Skip to content

Instantly share code, notes, and snippets.

View quassy's full-sized avatar
#MoarCoffeePlz

quassy

#MoarCoffeePlz
View GitHub Profile
@ines
ines / .zshrc
Last active February 28, 2021 19:42
Command to activate / create Python virtual environmment
function venv {
default_envdir=".env"
envdir=${1:-$default_envdir}
if [ ! -d $envdir ]; then
python -m venv $envdir
pip install ipython black flake8
echo -e "\x1b[38;5;2m✔ Created virtualenv $envdir\x1b[0m"
fi
source $envdir/bin/activate
@lopespm
lopespm / levenshtein_regex_recursion_memo.py
Last active December 28, 2021 09:25
Levenshtein distance between regex expression and target string - Recursion with memoization (Python)
# (Variant #4 for exercise 16.2 on EPI (Elements of Programming Interviews)) (September 2018 edition)
# The core idea is calculate the levenshtein distance, while taking into account the special cases of the regex expression
# *, +, ? and . were taken into account for the regex expression. Expression blocks are not supported
# This algorithm uses recursion with memoization (could be transposed to a DP solution), yielding a O(mn) time complexity, O(mn) auxiliary space for cache and O(max(m,n)) function call stack
# (m and n are the lengths of regex and target strings respectively)
#
# Version using dynamic programming: https://gist.github.com/lopespm/2362a77e7bd230a4622a43709c195826
def regex_dist(regex: str, target: str):
def regex_dist_aux(r_i, t_i):
@micahgodbolt
micahgodbolt / wsl_install_node.md
Last active December 22, 2022 09:37
WSL install Node

The apt-get version of node is incredibly old, and installing a new copy is a bit of a runaround.

So here's how you can use NVM to quickly get a fresh copy of Node on your new Bash on Windows install

$ touch ~/.bashrc
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
// restart bash
$ nvm install --lts
@carlsmith
carlsmith / automain.py
Last active December 8, 2022 22:43
Main function decorator (for Python 2 and 3).
import inspect
def main(function):
locale = inspect.stack()[1][0].f_locals
module = locale.get("__name__", None)
if module == "__main__":
locale[function.__name__] = function
function()
@Arkham
Arkham / remote.md
Last active November 25, 2023 09:34
Remote, office not required

Remote, Office Not Required

The Time is Right for Remote Work

Why work doesn't happen at work

The office during the day has become the last place people want to be when then really want to get work done.

Offices have become interruption factories: it's just one interruption after