Skip to content

Instantly share code, notes, and snippets.

@rene-d
rene-d / colors.py
Last active May 1, 2024 17:50
ANSI color codes in Python
# SGR color constants
# rene-d 2018
class Colors:
""" ANSI color codes """
BLACK = "\033[0;30m"
RED = "\033[0;31m"
GREEN = "\033[0;32m"
BROWN = "\033[0;33m"
BLUE = "\033[0;34m"
@luizomf
luizomf / settings.json
Last active May 1, 2024 17:46
VS Code Python and Code Runner Settings for Windows
{
"window.zoomLevel": 5,
"editor.formatOnSave": true,
"code-runner.executorMap": {
"python": "clear ; .\\venv\\Scripts\\python.exe"
},
"code-runner.runInTerminal": true,
"code-runner.clearPreviousOutput": true,
// Python
"[python]": {
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 1, 2024 17:42
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@vitorbritto
vitorbritto / regex.md
Last active May 1, 2024 17:41
Regex Cheat Sheet

Regular Expressions

Basic Syntax

  • /.../: Start and end regex delimiters
  • |: Alternation
  • (): Grouping
@nkaretnikov
nkaretnikov / README.md
Created September 27, 2019 15:08
lldb trace

Start debugserver:

tty0 # debugserver localhost:8000 main

Start tracing:

tty1 $ lldb
tty1 (lldb) command script import trace.py
tcp:
routers:
rou_dot:
entryPoints:
- dot
rule: HostSNI(`my.dot.domain.here`)
service: svc_dot
tls:
certResolver: le
services:
@quentint
quentint / wsl2-lando-phpstorm.md
Last active May 1, 2024 17:38
WSL2 / Lando / PhpStorm

This guide aims to be the reference for setting up Lando and PhpStorm tools on a WSL2 environment.

This assumes your project:

  • lives in a WSL2 instance (something like \\wsl$\Ubuntu\home\[user]\dev\my-demo-project)
  • Is "Lando-initialized" (lando init) and runs (lando start)
  • uses Composer, and dependencies are installed (lando composer install)

Docker

This guides relies on Docker for Windows, using the WSL2 based engine, and setup with WSL integration (Resources > WSL Integration). Unfortunately I didn't find a solution to do without it and only rely on WSL's Docker.

@clamydo
clamydo / configuration.nix
Created April 4, 2024 09:17
Minimal example how to pass a sops-nix secret into a systemd-nspawn container via systemd's credential system.
{ config, lib, pkgs, ... }:
{
imports = [
${builtins.fetchTarball
"https://github.com/Mic92/sops-nix/archive/master.tar.gz"
}/modules/sops"
];
users = {
@Widdershin
Widdershin / ssr.md
Last active May 1, 2024 17:36
The absurd complexity of server-side rendering

In the olden days, HTML was prepared by the server, and JavaScript was little more than a garnish, considered by some to have a soapy taste.

After a fashion, it was decided that sometimes our HTML is best rendered by JavaScript, running in a user's browser. While some would decry this new-found intimacy, the age of interactivity had begun.

But all was not right in the world. Somewhere along the way, we had slipped. Our pages went uncrawled by Bing, time to first meaningful paint grew faster than npm, and it became clear: something must be done.

And so it was decided that the applications first forged for the browser would also run on the server. We would render our HTML using the same logic on the server and the browser, and reap the advantages of both worlds. In a confusing series of events a name for this approach was agreed upon: Server-side rendering. What could go wrong?

In dark rooms, in hushed tones, we speak of colours.

@ckabalan
ckabalan / best_bash_history.sh
Last active May 1, 2024 17:29
The Best Bash History Settings Ever
# /etc/profile.d/best_bash_history.sh
# Save 5,000 lines of history in memory
HISTSIZE=10000
# Save 2,000,000 lines of history to disk (will have to grep ~/.bash_history for full listing)
HISTFILESIZE=2000000
# Append to history instead of overwrite
shopt -s histappend
# Ignore redundant or space commands
HISTCONTROL=ignoreboth
# Ignore more