Skip to content

Instantly share code, notes, and snippets.

@kowalcj0
kowalcj0 / .bashrc
Last active July 30, 2023 10:09
Extract all subtitles from a movie using ffprobe & ffmpeg
alias subs=subs
function subs() {
movie="${1}"
filename="${1%.*}"
mappings=`ffprobe -loglevel error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 "${movie}"`
OLDIFS=$IFS
IFS=,
( while read idx lang
do
function cheat() {
# ${1} - is the language/dmbs/etc
# ${*:2} - your query
# sed 's/ /+/g' - will replace spaces with `+`
curl https://cheat.sh/${1}/`echo "${*:2}" | sed 's/ /+/g'`
}
# example usage:
# cheat python recursion
# cheat python open files
@kowalcj0
kowalcj0 / parallel_pa11y.sh
Last active June 12, 2018 17:38
run pa11y accessibility scan in parallel and save report for each URL in html file
sudo dnf install parallel
npm install pa11y pa11y-reporter-html
# the Perl expression {= s:[/\:\?\&\=]:-:g; =} will replace all special charachers '/:?&' in report filename with '-'
parallel 'pa11y --reporter=html {} > {= s:[/\:\?\&\=]:-:g; =}.html' < urls.txt
@kowalcj0
kowalcj0 / urls-checker.py
Created March 27, 2018 11:03
Modified version of fetch function with semaphore created by: Paweł Miech https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Modified version of fetch function with semaphore created by: Paweł Miech
src: https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html
"""
import argparse
import asyncio
import sys
from argparse import Namespace
from asyncio import Semaphore
@kowalcj0
kowalcj0 / get_docker_repo_tags.sh
Created February 28, 2018 10:27
list all the available image tags for a docker hub repo
wget -q https://registry.hub.docker.com/v1/repositories/circleci/python/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'
@kowalcj0
kowalcj0 / SeleniumBrowserEnumWithHelpers.py
Created December 7, 2017 12:36
handy python enum for various browsers with some helpers that allow to toggle some hidden features
from enum import Enum
from selenium.webdriver import ChromeOptions, FirefoxProfile
class Browser(Enum):
CHROME = "chrome"
FIREFOX = "firefox"
IE = "ie"
PHANTOMJS = "phantomjs"
@kowalcj0
kowalcj0 / avgresponsetime.sh
Created October 20, 2017 22:26
simple script to check avg response times from a list of hosts stored in a file (ips)
sudo sh -c 'while read -r line; do echo "$line"; ping -f -q -4 -c 50 "$line" | grep rtt | cut -d"/" -f2,5; done <ips'
@kowalcj0
kowalcj0 / sync.sh
Last active March 26, 2018 12:07
notes from installing syncthing in freebsd 10.3 jail
# 1 - create syncthing jail
# 2 - add storage
# install bash and syncthing
pkg install bash
pkg install syncthing
# add syncthing user
```
@kowalcj0
kowalcj0 / install_MKVToolNix_and_handbrake.sh
Created July 2, 2017 16:08
Run HandBrake & MKVToolNix on a headless FreeBSD jail (FreeNas)
# 1 - Create a jail called `convert` using `pluginjail-10.3` template
# 2 - list all jails
jls
JID IP Address Hostname Path
1 - convert /mnt/volume/jails/convert
# 3 - connect to our jail
jexec 1 sh
@kowalcj0
kowalcj0 / .asoundrc
Created June 30, 2017 10:29
Fiio E17 Alsa config file 24bit 94kHz ~/.asoundrc
# to get the name of the card do:
# cat /proc/asound/cards
# ...
# 2 [DACE17 ]: USB-Audio - FiiO USB DAC-E17
# FiiO FiiO USB DAC-E17 at usb-0000:00:14.0-1.4, full speed
# or
# aplay -l
# ...
# card 2: DACE17 [FiiO USB DAC-E17], device 0: USB Audio [USB Audio]
# Subdevices: 1/1