Skip to content

Instantly share code, notes, and snippets.

@izabera
izabera / try-catch.sh
Last active March 5, 2017 01:56
silly try/catch
# try catch for bash/mksh/zsh/dash/busybox
[ "$BASH_VERSION" ] && shopt -s expand_aliases
alias try='tryblock ()'
alias throw='return'
alias catch='if tryblock; then :; else '
alias end_try='fi'
alias exceptions:='case $? in x) '
alias except=';;'
alias end_exceptions='esac'
alias always=' '
development:
adapter: mysql2
encoding: utf8
database: my_database
username: root
roles:
- admin
- developer
- guest
password:
@thehesiod
thehesiod / async_worker_pool.py
Last active September 26, 2024 03:14
Asynchronous Worker Pool, allows for limiting number of concurrent tasks
import asyncio
from datetime import datetime, timezone
import os
def utc_now():
# utcnow returns a naive datetime, so we have to set the timezone manually <sigh>
return datetime.utcnow().replace(tzinfo=timezone.utc)
class Terminator:
pass
#!/bin/bash
shopt -s extglob
declare -A signal=(
[1]=sighup [2]=sigint [3]=sigquit [4]=sigill [5]=sigtrap
[6]=sigabrt [7]=sigbus [8]=sigfpe [9]=sigkill [10]=sigusr1
[11]=sigsegv [12]=sigusr2 [13]=sigpipe [14]=sigalrm [15]=sigterm
[16]=sigstkflt [17]=sigchld [18]=sigcont [19]=sigstop [20]=sigtstp
[21]=sigttin [22]=sigttou [23]=sigurg [24]=sigxcpu [25]=sigxfsz
[26]=sigvtalrm [27]=sigprof [28]=sigwinch [29]=sigio [30]=sigpwr
@vladak
vladak / varmilo keyboard.md
Last active April 28, 2025 18:38
Varmilo keyboard details