Things I learned while doing Advent of Code 2022
itertools.accumulate
string.ascii_letters
complex
typemax
functionlocals
- Modular arithmetics
- Basic regex to find numbers
# Open the current cmd path to the current VS Code window | |
code . -r | |
# Print the result of a command in bash | |
echo $(operation) | |
# Pretty print json output in bash | |
echo '{"first_name":"Antoine","last_name":"Delia"}' | python -m json.tool |
{ | |
"python.pythonPath": "/Users/antoine.delia/.pyenv/versions/3.9.0/bin/python", | |
"python.formatting.autopep8Args": ["--max-line-length", "100"], | |
"python.linting.pylintEnabled": false, | |
"python.linting.flake8Enabled": true, | |
"python.linting.enabled": true, | |
"python.linting.flake8Args": [ | |
"--max-line-length", "200" | |
], | |
"autoDocstring.docstringFormat": "sphinx", |
pm.sendRequest({ | |
url: "https://YOUR_COGNITO_DOMAIN_NAME_HERE.auth.eu-west-1.amazoncognito.com/oauth2/token", | |
method: 'POST', | |
header: { | |
'Content-Type': 'application/x-www-form-urlencoded' | |
}, | |
body: { | |
mode: 'urlencoded', | |
urlencoded: [ | |
{ |
import logging | |
import os | |
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") | |
LOG_FILE_NAME = os.getenv("LOG_FILE_NAME", "log.txt") | |
class Color: | |
"""An enum for the different colors available for printing | |
""" |
from timeit import repeat | |
setup = 'x = ("a", "b", "c", "d"); idx = 2' | |
stmt_range = """ | |
[x[i] for i in range(len(x)) if i != 2] | |
""" | |
stmt_slice = """ | |
list(x[:2] + x[3:]) |
service: service-name | |
provider: | |
name: aws | |
stage: ${opt:stage, 'prod'} | |
runtime: ${opt:runtime, 'python3.8'} | |
region: ${opt:region, 'eu-west-1'} | |
deploymentBucket: | |
name: deployment_bucket_name | |
iamRoleStatements: |
fields @timestamp, @message, @logStream | |
| parse @message "[*][*] *" as loggingTime, loggingType, loggingMessage | |
| filter loggingType in ["ERROR", "WARNING", "DEBUG", "INFO"] | |
| display loggingTime, loggingType, loggingMessage | |
| filter loggingMessage like "my search criteria" | |
| sort @timestamp desc | |
| limit 1000 |
// ==UserScript== | |
// @name Force 1080p60 (Source) video quality on Twitch | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match *://*.twitch.tv/* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// @author Antoine Delia |
itertools.accumulate
string.ascii_letters
complex
typemax
functionlocals
# https://www.fosshub.com/MKVToolNix.html | |
$ sudo apt install mkvtoolnix | |
# Update the default audio track to the second one in all the files in the current directory | |
$ for i in *; do if [[ $i == *.mkv ]]; then mkvpropedit "$i" --edit track:a1 --set flag-default=0 --edit track:a2 --set flag-default=1; fi; done | |
# If you have a single subtitle, and you want it to be default, then do: | |
$ for i in *; do if [[ $i == *.mkv ]]; then mkvpropedit "$i" --edit track:s1 --set flag-default=1; fi; done | |
# Merge two files into one |