Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
barbietunnie / file-contents-dump-ansible.md
Created November 25, 2022 12:09
How to dump file contents to console with Ansible

How to dump file contents to console with Ansible

-  name: Display content of resolv.conf
  hosts: localhost
  tasks:
    - name: Display resolv.conf contents
      command: cat resolv.conf chdir=/etc
      register: command_output
@diegostamigni
diegostamigni / retry.go
Created November 2, 2022 15:09
Golang generic retry
func Retry[T any](effector func(ctx context.Context) (T, error), retries int, delay time.Duration) func(context.Context) (*T, error) {
return func(ctx context.Context) (*T, error) {
for r := 0; ; r++ {
response, err := effector(ctx)
if err == nil || r >= retries {
// Return when there is no error or the maximum amount
// of retries is reached.
return &response, err
}
@adilkhash
adilkhash / exception_groups.py
Created October 25, 2022 08:54
Python 3.11 Exception Groups
from urllib.request import urlopen
from urllib.error import HTTPError
from concurrent.futures import ThreadPoolExecutor, as_completed
class HttpError(Exception):
def __init__(self, url: str, code: int) -> None:
self.url = url
self.code = code
@emidoots
emidoots / ramblings.md
Last active December 25, 2024 04:39
Because cross-compiling binaries for Windows is easier than building natively

Because cross-compiling binaries for Windows is easier than building natively

I want Microsoft to do better, want Windows to be a decent development platform-and yet, I constantly see Microsoft playing the open source game: advertising how open-source and developer friendly they are - only to crush developers under the heel of the corporate behemoth's boot.

The people who work at Microsoft are amazing, kind, talented individuals. This is aimed at the company's leadership, who I feel has on many occassions crushed myself and other developers under. It's a plea for help.

The source of truth for the 'open source' C#, C++, Rust, and other Windows SDKs is proprietary

You probably haven't heard of it before, but if you've ever used win32 API bindings in C#, C++, Rust, or other languages, odds are they were generated from a repository called microsoft/win32metadata.

@joshbduncan
joshbduncan / spinner_simple.py
Created April 1, 2022 15:18
Simple Progress Spinner Using Python Generators
import sys
import time
def spinner(msg="working..."):
i = 0
ticks = ["-", "\\", "|", "/"]
try:
while True:
tick = ticks[i % len(ticks)]
@Preethi-Dev
Preethi-Dev / git__stash__commands.md
Created March 31, 2022 15:19
Cheat sheet for git stash commands

Stash the changes

  1. git stash
  2. git stash save

Stash the untracked files

  1. git stash --include-untracked
  2. git stash -u

List the stashes

  1. git stash list

show the latest stash

  1. git stash show
@angely-dev
angely-dev / logger-exithandler.py
Last active December 30, 2024 09:49
Python logging exit on error or critical levels
import logging
import logging.handlers
import sys
#
# The logger and the logging level
#
logger = logging.getLogger('mylogger')
logger.setLevel(logging.DEBUG)
@kolypto
kolypto / generators.py
Created July 27, 2021 15:21
Advanced examples for Python generators: next(), send(), throw(), yield
# https://docs.python.org/3/library/typing.html#typing.Generator
# 💥💥💥 Simple generator: yield values one by one
# This function pauses to return a value to the outer scope, then proceeds
DICTIONARY = {
'a': 'apple',
'b': 'banana',
'c': 'cat',
@ryanorsinger
ryanorsinger / installing_anaconda_on_mac.md
Last active June 19, 2025 01:44
Installing Homebrew and Anaconda

Installing Homebrew and Anaconda on a Mac

Install Homebrew

Run the following command on your terminal to install Homebrew. Homebrew is a package manager for Macs and is used to install useful development tools and software.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Anaconda through Homebrew

  1. Run brew install --cask anaconda to install Anaconda
@davidteren
davidteren / nerd_fonts.md
Last active July 2, 2025 14:14
Install Nerd Fonts via Homebrew [updated & fixed]