Skip to content

Instantly share code, notes, and snippets.

View peterrus's full-sized avatar
🐧

peterrus peterrus

🐧
View GitHub Profile
@peterrus
peterrus / flask-websocket-log-stream.py
Created March 13, 2022 11:56
Runs a scheduled job in a background thread using APScheduler and streams it's output to a web client using websockets.
# Runs a scheduled job in a background thread using APScheduler and streams
# it's output to a web client using websockets. Communication between the Flask
# thread and APScheduler thread is being done through (blinker) signals.
#
# Install dependencies (preferably in your virtualenv)
# pip install flask apscheduler sqlalchemy blinker flask-socketio simple-websocket
# and then run with:
# python this_script.py
from time import sleep
@peterrus
peterrus / tilix_backup.sh
Created June 17, 2021 20:06
Backs up and restores Tilix settings
#!/usr/bin/env bash
# Backs up and restores tilix settings
set -e
if [[ $1 == 'backup' ]]; then
dconf dump '/com/gexperts/Tilix/' > tilix-settings.dconf
echo "backup done"
exit 0
@peterrus
peterrus / gnome3_keybind_backup.sh
Last active October 18, 2023 05:58
Backs up and restores gnome3 keybindings
#!/usr/bin/env bash
# Backs up and restores gnome3 keybindings
# Tested with Gnome 3.36.8
# by peterrus
set -e
mkdir -p gnome3-keybind-backup
@peterrus
peterrus / bw-export.sh
Created May 22, 2021 15:27
Bitwarden full export (with attachments)
#!/usr/bin/env bash
set -e
FOLDER_NAME=bw-export-$(date "+%Y%m%d-%H%M%S")
mkdir $FOLDER_NAME
cd $FOLDER_NAME
export BW_SESSION=$(bw unlock --raw)
@peterrus
peterrus / bash_colors.sh
Last active January 21, 2022 02:32
Simple status colors in Bash with tput
# Colors and fonts
# Only loaded on interactive terminals
if [ -t 0 ]; then
T_ERROR=$(tput setaf 7; tput setab 1)
T_INFO=$(tput setaf 7; tput setab 4)
T_WARNING=$(tput setaf 0; tput setab 3)
T_SUCCESS=$(tput setaf 0; tput setab 2)
T_BOLD=$(tput bold)
T_RESET=$(tput sgr0)
fi
@peterrus
peterrus / docker-compose.yml
Last active November 1, 2022 23:16 — forked from smashnet/docker-compose.yml
Docker-Compose: Mastodon v3.1.3 with Traefik v2
version: "3.5"
# Setup:
# Create .env file containing (without the #'s)
# TRAEFIK_DASHBOARD_DOMAIN=dashboard.domain.com
# TRAEFIK_DASHBOARD_ADMIN_PASSWORD=generate_this_with_htpasswd
# POSTGRES_PASSWORD=s3cr3tstr1ng
# DOMAIN=wow.domain.com
# LETS_ENCRYPT_EMAIL=admin@admin.tld
@peterrus
peterrus / netdata.sls
Created July 2, 2017 21:12
Saltstate to install netdata + requirements, tries to update netdata every time this state is applied
# Saltstate to install netdata + requirements, tries to update netdata every time this state is applied
# original by https://github.com/saivert: https://github.com/firehol/netdata/issues/798#issuecomment-242472276
# modified to work on ubuntu 14.04 and 16.04 by https://github.com/peterrus
netdatarequisites:
pkg.installed:
- pkgs:
{% if grains['os'] == 'Gentoo' %}
- sys-devel/autoconf
- sys-devel/autoconf-archive
^!h::Run "C:\Program Files\VideoLAN\VLC\vlc.exe" --intf dummy "C:\Users\user\Documents\mccree.mp3" --volume 200 --play-and-exit
^!p::Run "C:\Program Files\VideoLAN\VLC\vlc.exe" --intf dummy "C:\Users\user\Documents\zenyatta.m4r" --volume 200 --play-and-exit
^!l::Run "C:\Program Files\VideoLAN\VLC\vlc.exe" --intf dummy "C:\Users\user\Documents\lucio.m4r" --volume 200 --play-and-exit
^!j::Run "C:\Program Files\VideoLAN\VLC\vlc.exe" --intf dummy "C:\Users\user\Documents\hanzo.m4r" --volume 200 --play-and-exit
@peterrus
peterrus / AutoHotkey.ahk
Last active June 29, 2016 10:58
Maps mediakeys to page up/down home and end (Place in Documents folder and run AutoHotkey) (Special attention was given to modifier keys, because elsewise it wouldn't register the keystrokes for some reason)
Media_Next::Send {End}
Media_Prev::Send {Home}
Media_Stop::Send {PgUp}
Media_Play_Pause::Send {PgDn}
^Media_Next::Send ^{End}
^Media_Prev::Send ^{Home}
^Media_Stop::Send ^{PgUp}
^Media_Play_Pause::Send ^{PgDn}
@peterrus
peterrus / gist:4373208
Created December 25, 2012 13:19
random imgur image selector (quite a dirty approach) issues:returns ocassionaly 404's while the image in fact exists
<?php
//random imgur image selector (quite a dirty approach)
//issues:returns ocassionaly 404's while the image in fact exists
$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
while(true) {
//variables
$shuffled = str_shuffle($str);