Skip to content

Instantly share code, notes, and snippets.

@mrozo
mrozo / mseq.sh
Created February 18, 2022 17:29
Multidimessiona sequence generator in bash. Sort of exrended seq
#!/usr/bin/env bash
help="
Multidimesionnal sequence
Generate every possible sequence consisting from n integer values, each from n-th range.
Range can be defined as:
* <k> - range from 1 to <k> inclusively
* <k>..<l> - range from <k> to <l> inclusively
* <k>..<l>..<m> -range from <k> to <m> with incremetn of <l> inclusively
@mrozo
mrozo / joke.sh
Created June 30, 2021 11:39
joking cow
#!/usr/bin/env bash
URL='https://perelki.net/random'
function get_joke {
current_dir="$PWD"
cd /tmp
wget "$URL" --quiet
from_line="$(fgrep '<!-- POCZATEK -->' ./random -n | cut -d: -f1)"
to_line="$(fgrep '<!-- KONIEC -->' ./random -n | cut -d: -f1)"
joke="$(head -n $to_line ./random | tail -n $(($to_line - $from_line +1)) - | fgrep '<br />' | tr "\r" -d | sed 's/<br \/>/\n/g')"
@mrozo
mrozo / volume_control.sh
Created May 16, 2019 20:36
Synchronized volume control for awesome wm
#!/bin/bash
# the script comes from this site: customlinux.blogspot.com/2013/02/pavolumesh-control-active-sink-volume.html
# This is an updated version that works with ubuntu 18.04 and sends notifications to awesome window manager via awesome-client. Remember - I'am not an original author of the script.
# finds the active sink for pulse audio and increments the volume. useful when you have multiple audio outputs and have a key bound to vol-up and down
inc='5'
capvol='yes'
maxvol='200'
tmpfile='/tmp/pasink.tmp'
@mrozo
mrozo / tmux_welcome_screen.py
Created May 9, 2019 19:03
Welcome screen for tmux with calendar, tmux help and disk free space
#!/bin/env/python3
import calendar
import time
from subprocess import check_output
import os
DISKS = (' /home',' /', ' /home/windows', ' /media/backup')
TMUX_CHEATSHEET = """ │
Sessions │ Panes (splits)
@mrozo
mrozo / nocoin_blacklist2hosts.py
Created November 30, 2017 16:34
Convert blacklist of no coin chrome extension int a hosts file entry. https://github.com/keraf/NoCoin
import re
blacklist = open("/home/mroz/workspace/coin-hoster/blacklist.txt",'r')
domains = set()
wildcards = set()
domain_matcher = re.compile("[^/]+//(\*\.)?(?P<domain>[^/]+)")
for line in blacklist:
try:
domains.add(domain_matcher.match(line).groupdict()['domain'])
except:
pass
@mrozo
mrozo / server.py
Created April 29, 2016 09:02
Flask sqlalchemy + Flask jsontools example. This file shows how to join those two Flask extensions in order to create a restful api for accessing the database.
#
# author: mroz
# email: private@mrozo.pl
# page: github.com/mrozo
# license: BSD 2-Clause License
# Copyright (c) 2016, mroz
#
# Flask sqlalchemy + Flask jsontools example.
# This file shows how to join those two Flask extensions in order to create a restful api for accessing the database.
#