Skip to content

Instantly share code, notes, and snippets.

@fqxp
fqxp / fabfile.py
Created May 11, 2013 13:22
Set up Postgres server, user and database with fabric. Put into fabfile.py
def _run_as_pg(command):
return sudo('sudo -u postgres %s' % command)
def pg_user_exists(username):
with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
res = _run_as_pg('''psql -t -A -c "SELECT COUNT(*) FROM pg_user WHERE usename = '%(username)s';"''' % locals())
return (res == "1")
def pg_database_exists(database):
with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
@fqxp
fqxp / .gtkrc-2.0
Created June 6, 2015 19:18
Fix annoying gray bar at bottom and right side of gvim window
style "vimfix" {
bg[NORMAL] = "#242424" # this matches my gvim theme 'Normal' bg color.
}
widget "vim-main-window.*GtkForm" style "vimfix"
@fqxp
fqxp / rx_wikipedia_demo.py
Created October 3, 2016 20:19
Demo for using rx with gbulb and asyncio in python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import gbulb
import rx
import json
from rx.subjects import Subject
from rx.concurrency import AsyncIOScheduler
from tornado.httpclient import AsyncHTTPClient
from tornado.httputil import url_concat
@fqxp
fqxp / lastpass2pass
Last active August 11, 2017 14:20
Export LastPass passwords to pass (https://www.passwordstore.org/)
#!/usr/bin/env python3
#
# Prerequisites:
# * Install lpass command (ArchLinux: lastpass-cli package)
# and run `lpass login` once
# * or export passwords from Lastpass in CVS format.
# * Create a file `.lastpass2pass.blacklist` in your $HOME and optionally
# enter group names to be blacklisted, one per line.
#
# Usage:
@fqxp
fqxp / gitlab-pipeline-status
Last active June 11, 2019 08:16
gitlab-pipeline-status: outputs status of last build pipeline from gitlab (install and configure gitlab CLI from https://github.com/NARKOZ/gitlab/ first)
#!/bin/bash
if ! git status >/dev/null 2>&1 ; then
echo "not a git repository"
exit 1
fi
PROJECT_NAME=$(git remote get-url origin | sed 's#.*:\(.*\)\.git#\1#')
BRANCH=$(git branch|grep '^\*'|cut -d\ -f2)
PIPELINE_SUCCESS=$(gitlab pipelines $PROJECT_NAME "{ per_page: 100 }" | grep $BRANCH | head -1 | cut -d\| -f 5)
### Keybase proof
I hereby claim:
* I am fqxp on github.
* I am fqxp (https://keybase.io/fqxp) on keybase.
* I have a public key ASA5ljZZaKUycWUAWv7Tjt6d9kCvKrWW52utlqDNAmd9OAo
To claim this, I am signing this object:
@fqxp
fqxp / wtf
Created October 11, 2019 11:26
outputs WTF
#!/bin/bash
base64 -d <<EOF | mplayer -cache 1024 -
AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAFD+FtZGF0AAACrgYF//+q
3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE1NSByMjkxNyAwYTg0ZDk4IC0gSC4yNjQvTVBF
Ry00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxOCAtIGh0dHA6Ly93d3cudmlkZW9sYW4u
b3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFs
eXNlPTB4MzoweDExMyBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVk
X3JlZj0xIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MSBjcW09MCBk
ZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aHJlYWRzPTYg
bG9va2FoZWFkX3RocmVhZHM9MSBzbGljZWRfdGhyZWFkcz0wIG5yPTAgZGVjaW1hdGU9MSBpbnRl
@fqxp
fqxp / Leankit-show-tags-all-the-time.user.js
Last active March 31, 2020 20:33
Userscript: Leankit - Show Tags all the Time in the board (not only on hover) - Instructions: 1. Install »Tampermonkey« add-on 2. Click on »Raw« on this page 3. Click »Install«
// ==UserScript==
// @name Leankit: Show Tags all the Time
// @namespace http://fqxp.de/
// @version 0.1
// @description Show tags of tickets in Leankit in the ticket instead of only when hovering over the tag icon
// @author Frank Ploss <[email protected]>
// @match https://*.leankit.com/board/*
// @match https://*.leankit.com/card/*
// @grant none
// @run-at document-end
@fqxp
fqxp / bitwarden2pass
Created July 13, 2020 09:14
bitwarden2pass
#!/usr/bin/env python3
#
# Prerequisites:
# * Install bitwarden-cli (ArchLinux: bitwarden-cli package)
# and run `bw login` and `bw unlock` and set the API TOKEN thats
# printed as a result.
#
# Usage:
# 1. Simply run `bitwarden2pass`.
# 2. Voilà!
@fqxp
fqxp / tmux-panes-completion.zsh
Created September 4, 2020 10:17
Zsh completion for words from all tmux panes using FZF
_complete_tmux_pane_words() {
local -a w
if [[ -z "$TMUX_PANE" ]]; then
_message "not running inside tmux!"
return 1
fi
_tmux_capture_pane() {
tmux capture-pane -J -p $@ |