Skip to content

Instantly share code, notes, and snippets.

View toloco's full-sized avatar
🎯
Focusing

Tolo Palmer toloco

🎯
Focusing
View GitHub Profile
@toloco
toloco / move.py
Created October 10, 2023 15:09
move on move on
#!/usr/bin/env python3
import argparse
import math
import time
from datetime import datetime
import pyautogui
@toloco
toloco / Makefile
Last active September 14, 2023 12:47
Makefile template
#!make
################################################################################
# Makefile internals
################################################################################
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-6s\033[0m %s\n", $$1, $$2}'
@toloco
toloco / python.js
Last active February 21, 2023 15:00
My VSCode python snippeds
{
"PDB set trace": {
"prefix": "pdb",
"body": ["import pdb; pdb.set_trace()$0"]
},
"iPDB set trace": {
"prefix": "ipdb",
"body": ["import ipdb; ipdb.set_trace()$0"]
},
@toloco
toloco / .gitconfig
Last active February 13, 2023 17:55
Git config for the lazies
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p
publish = "!git push --set-upstream origin \"$(git rev-parse --abbrev-ref HEAD)\""
refresh = "!git pull origin \"$(git rev-parse --abbrev-ref HEAD)\""
@toloco
toloco / README.md
Last active February 13, 2023 10:05
NGINX Cors

How to allow CORS (cross-origin/domain) API calls with nginx.

For nginx see the following:

The code as per nginx docs, can be placed under: http, server or location, so you can decide how fine grane access you wish to allow.

@toloco
toloco / envs.jssonet
Last active February 13, 2023 10:05
Jsonnet example
local v1 = import "v1.libsonnet";
local env = import "env.libsonnet";
local params = v1.params;
local sentry_params = v1.valuesForEnv(
"prod", {creds: "874c6f6d8b51422b9bfc2f6524a7b5b0", uri: "/11"})
.defaults({creds: "f980cfda63194d869e7ca5e0c9bb48cb", uri: "/14"}
);
local processes = v1.valuesForEnv("prod", "8").defaults("2");
@toloco
toloco / argparse.py
Created July 6, 2022 15:37
Argparser python
import argparse
def parse_args():
log_levels = {
"info": logging.INFO,
"debug": logging.DEBUG,
"warning": logging.WARNING,
}
parser = argparse.ArgumentParser()
@toloco
toloco / shell.sh
Created June 17, 2022 07:54
Python code operations
clean: ## Remove all pyc and caches
@find . -name '*.py[co]' -exec rm -f {} +
@find . -name '\.pytest_cache' -exec rm -fr {} +
@find . -name '\.mypy_cache' -exec rm -fr {} +
@find . -name '__pycache__' -exec rm -fr {} +
@docker ps -aq | xargs -r docker rm -f
@docker volume ls -q | xargs -r docker volume rm -f
@docker images | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi -f
@docker builder prune -f
#!/usr/bin/env python3
import csv
import argparse
TRANSLATION = {
"First Name": "First Name",
"Last Name": "Last Name",
"Company": "Current Company",
@toloco
toloco / .gitconfig
Last active June 17, 2022 07:46
ZSH and git
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p
publish = "!git push --set-upstream origin \"$(git rev-parse --abbrev-ref HEAD)\""
refresh = "!git pull origin \"$(git rev-parse --abbrev-ref HEAD)\""