Skip to content

Instantly share code, notes, and snippets.

View gdamjan's full-sized avatar

Дамјан Георгиевски gdamjan

View GitHub Profile
@gdamjan
gdamjan / future-vs-task.py
Created December 23, 2021 13:40
futures are lazy, tasks are eager (in async python)
import asyncio
async def test(s, n):
print(f' {s} started')
await asyncio.sleep(n)
print(f' {s} ends')
async def main():
[Unit]
Description=soju IRC bouncer service
After=network.target
[Service]
Type=simple
DynamicUser=yes
StateDirectory=soju
LogsDirectory=soju
ConfigurationDirectory=soju
# ~/.ssh/config
Host *
ControlMaster auto
TCPKeepAlive yes
ServerAliveInterval 30
ControlPath ${XDG_RUNTIME_DIR}/ssh-%C.ctl
IdentityAgent ${XDG_RUNTIME_DIR}/ssh-agent.socket
AddKeysToAgent 60m
@gdamjan
gdamjan / sqlalchemy-rds-iam-pgsql.py
Last active February 3, 2022 13:38
SQLAlchemy with RDS IAM Authentication
'''
Example of IAM Authentication to Postgres RDS from Python and SQLAlchemy. Uses SQLAlchemy events to
run a callback just before making a db connection and adding it to the internal pool. The callback
sets the connection parameters including the password/token.
https://docs.sqlalchemy.org/en/14/core/events.html#sqlalchemy.events.DialectEvents.do_connect
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.Python.html
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html#RDS.Client.generate_db_auth_token
@gdamjan
gdamjan / README.md
Last active November 11, 2021 21:28
WoWLAN
$ sudo iw phy0 wowlan enable magic-packet
$ sudo iw phy0 wowlan show
WoWLAN is enabled:
 * wake up on magic packet
 
$ sudo systemctl suspend
…
$ sudo iw phy0 wowlan show
WoWLAN is enabled:
@gdamjan
gdamjan / README.md
Last active January 11, 2024 09:07
Install a NixOS for a systemd-nspawn container … from podman

Install

Run a nix container with podman, with the container destination mounted as /mnt:

DEST=~/containers/nixos
mkdir -p $DEST/{dev,proc,etc/nixos}

podman run -v $DEST:/mnt -it --rm --cap-add SYS_ADMIN docker.io/nixos/nix:latest
@gdamjan
gdamjan / demo.py
Created August 1, 2021 11:40
asyncio concurrent get
import asyncio
import aiohttp
async def request(session, url):
resp = await session.get(url)
return await resp.text()
async def main():
session = aiohttp.ClientSession()
@gdamjan
gdamjan / aliases
Last active November 27, 2021 01:23
my $HOME files
# ~/.aliases
# Some usefull shortcuts
alias ls='LC_COLLATE=C ls --color=auto -F --group-directories-first'
alias diff='diff --color -u'
alias d=ls
alias cd..="cd .."
alias cd...="cd ../.."
alias v="ls -l"
alias ..="cd .."
alias ...="cd ../.."
@gdamjan
gdamjan / README.md
Last active October 3, 2021 18:14
Arch install with tpm2/luks/secureboot notes

Инсталација

  1. Arch инсталиран
  • pacstrap /mnt base linux linux-firmware sudo vim openssh networkmanager iwd
  • UEFI vm
  • /dev/vda1 ESP (vfat)
  • /dev/vda2 crypt luks root
  • systemctl enable --now sshd NetworkManager
  1. јузер damjan
@gdamjan
gdamjan / XCompose
Created February 25, 2021 21:31
my own $HOME/.XCompose
include "%L"
# see also https://github.com/kragen/xcompose/
<Multi_key> <y> <y> : "✓" U2713 # checkmark
<Multi_key> <x> <x> : "✗" U2717 # BALLOT X
<Multi_key> <o> <minus> <plus> : "♀" U2640 # FEMALE SIGN
<Multi_key> <o> <minus> <greater> : "♂" U2642 # MALE SIGN
<Multi_key> <t> <e> <l> : "☎" U260E # BLACK TELEPHONE