Skip to content

Instantly share code, notes, and snippets.

@vladak
vladak / varmilo keyboard.md
Last active October 21, 2024 18:42
Varmilo keyboard details
#!/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
@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
development:
adapter: mysql2
encoding: utf8
database: my_database
username: root
roles:
- admin
- developer
- guest
password:
@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=' '
#!/bin/bash
save=$(bind -p; bind -X)
function clean-up {
bind -r '\C-i'
bind -f /dev/stdin <<< "$save"
}
trap 'clean-up' RETURN
function write-options {
@XVilka
XVilka / TrueColour.md
Last active October 29, 2024 09:43
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@sloria
sloria / bobp-python.md
Last active November 14, 2024 15:01
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@khayrov
khayrov / serialize.py
Last active January 26, 2022 02:17
Serializable transactions and retry in SQLAlchemy
from sqlalchemy import (create_engine, event,
Column, Integer,
ForeignKey)
from sqlalchemy import event
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy.exc import DBAPIError
import sqlite3