Skip to content

Instantly share code, notes, and snippets.

@gryf
gryf / libxft-bgra.patch
Created June 11, 2021 14:39
bgra patch for gentoo x11-libs/libXft
diff -ur libXft-2.3.3/src/xftcolor.c libXft-2.3.3-patched/src/xftcolor.c
--- libXft-2.3.3/src/xftcolor.c 2019-03-16 19:12:27.000000000 +0100
+++ libXft-2.3.3-patched/src/xftcolor.c 2021-04-23 16:53:14.825232294 +0200
@@ -90,9 +90,9 @@
green_len = masklen (visual->green_mask);
blue_shift = maskbase (visual->blue_mask);
blue_len = masklen (visual->blue_mask);
- result->pixel = (((color->red >> (16 - red_len)) << red_shift) |
- ((color->green >> (16 - green_len)) << green_shift) |
- ((color->blue >> (16 - blue_len)) << blue_shift));
import os
import subprocess
import weechat
info = ('notify',
'gryf',
'0.1',
'GPL3',
@gryf
gryf / tmux.md
Last active June 17, 2020 15:06 — forked from russelldb/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@gryf
gryf / copydeps.sh
Created February 25, 2020 05:26
Copy dependencies (libs) for certain binaries
DEPS=(/bin/foo /sbin/bar /usr/bin/baz)
# copy libs of foo/bar/baz to lib in current directory
for bin in ${DEPS[*]}; do
cp $bin ./bin/
ldd $bin >/dev/null || continue
for lib in $(ldd $bin | sed -nre 's,.* (/.*lib.*/.*.so.*) .*,\\1,p' \\
-e 's,.*(/lib.*/ld.*.so.*) .*,\\1,p')
do
mkdir -p .${lib%/*} && cp {,.}$lib
@gryf
gryf / freedesktop_wmaker_menu.py
Last active February 24, 2020 18:15
example of dynamic window maker menu for freedesktop *desktop files.
#!/usr/bin/env python
import argparse
import configparser
from collections import defaultdict
import os
class WMMenu:
APP_DESK_PATH = '/usr/share/applications'
@gryf
gryf / suspend.sh
Created August 31, 2019 05:28
do actions before and after suspending
#!/bin/bash
xlock &
sudo /usr/sbin/pm-suspend
# get back keyboard and other settings after resume
#sudo /usr/local/bin/usb_power.sh
~/bin/setxinput.sh
@gryf
gryf / nbp-rates.py
Last active March 20, 2020 11:22 — forked from dulek/nbp-rates.py
Gets you average NBP rate for given date and currency.
#!/usr/bin/env python
"""
Get exchange rate from NBP service for USD (default) and provided day (or now)
"""
import argparse
from datetime import datetime
import requests
@gryf
gryf / is-thursday.py
Last active October 12, 2016 08:22 — forked from dulek/is-thursday.py
#!/usr/bin/env python
import argparse
from datetime import datetime
from pytz import common_timezones, timezone
parser = argparse.ArgumentParser(description="Tells you if it's Thursday "
"anywhere in the world.")
parser.add_argument('--all', action='store_true', default=False,
help='Print all timezones with Thursday.')
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <version> <revision>"
echo "for example for Java 1.8.0.92 it would be:"
echo "$0 8 92"
exit 1
fi
VERSION="$1u$2"
@gryf
gryf / bash_prompt.sh
Last active April 20, 2018 07:59 — forked from bradsokol/bash_prompt.sh
Set color bash prompt according to active virtualenv, Git, Mercurial or Subversion branch and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the active nodejs virtualenv[1]
# * the branch/status of the current Git, Mercurial or Subversion repository
# * the return value of the previous command
# * one line prompt