Skip to content

Instantly share code, notes, and snippets.

@tarruda
tarruda / micro_events.py
Last active February 28, 2025 07:54
Micro event loop library to teach the basic concepts of python coroutines and how event loop libraries might be implemented
"""
A micro event loop library implementation from scratch.
This library provides a minimal but feature-complete asynchronous event loop
implementation for educational purposes. It demonstrates the core concepts of
asynchronous programming including:
- Task scheduling and management
- I/O multiplexing with non-blocking sockets
- Timeouts and sleep functionality
@Kartones
Kartones / postgres-cheatsheet.md
Last active February 28, 2025 07:54
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
On OSX Yosemite and above, in a terminal window:
1. Switch to the root user.
$ sudo su -
2. Create a Dummynet pipe that represents a slow, unreliable network:
# dnctl pipe 1 config bw 10Kbit/s delay 300 plr 0.1 noerror
import Combine
import SwiftUI
struct CountdownView: View {
@State private var countdown: Int = 15 * 60
@State private var displayedTime = "15:00"
@State private var countdownTimer: AnyCancellable?
@State private var isShowingLaurels = false
@State private var isShowingExpiry = false
@t3dotgg
t3dotgg / try-catch.ts
Last active February 28, 2025 07:46
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@n0ctu
n0ctu / arch-linux-n0ctu.md
Last active February 28, 2025 07:41
Multi-Boot: Arch Linux & Windows with GRUB, LUKS2, and Btrfs on UEFI

Multi-Boot: Arch Linux & Windows with GRUB, LUKS2, and Btrfs on UEFI

0.1. Abstract

This document expands upon the official Arch Linux Wiki installation guide by covering some more steps:

  • Arch Linux installation on a LUKS2 container on Btrfs
  • Microsoft Windows 10/11 installation with BitLocker
@MarioCarrion
MarioCarrion / tests.sh
Created July 4, 2019 18:29
Go coverage + test for each and all packages
#!/bin/bash
#
# scripts/test.sh
#
# * Generates `coverage/index.html`: HTML artifact for download,
# * Generates `coverage/report.xml`: report of failed tests in Junit format, and
# * Validates the minimum code coverage still applies.
#
# Depends on:
# * github.com/jstemmer/go-junit-report
KFZUS-F3JGV-T95Y7-BXGAS-5NHHP
T3ZWQ-P2738-3FJWS-YE7HT-6NA3K
KFZUS-F3JGV-T95Y7-BXGAS-5NHHP
65Z2L-P36BY-YWJYC-TMJZL-YDZ2S
SFZHH-2Y246-Z483L-EU92B-LNYUA
GSZVS-5W4WA-T9F2E-L3XUX-68473
FTZ8A-R3CP8-AVHYW-KKRMQ-SYDLS
Q3ZWN-QWLZG-32G22-SCJXZ-9B5S4
DAZPH-G39D3-R4QY7-9PVAY-VQ6BU
KLZ5G-X37YY-65ZYN-EUSV7-WPPBS
@eestrada
eestrada / sqlite_regex.py
Last active February 28, 2025 07:31
How to do regular expressions in sqlite3 (using python).
#!/usr/bin/env python
"""How to do regular expressions in sqlite3 (using python)."""
from __future__ import division, absolute_import, print_function, unicode_literals
import re
import sys
import time
import datetime
import sqlite3