Skip to content

Instantly share code, notes, and snippets.

@michaelkl
michaelkl / pgadmin3-docker.sh
Last active May 29, 2024 14:40
Running an old pgAdmin III on a modern system using Docker
docker run \
-it --rm \
-e DISPLAY=$DISPLAY \
-e LC_ALL=C \
-v ${HOME}/.pgadmin3_home:/home \
-e HHHOME=${HOME} \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v ${HOME}/.Xauthority:/root/.Xauthority \
--net host \
jancelin/docker-pgadmin3
@michaelkl
michaelkl / queue_time_logger_plugin.rb
Last active October 1, 2021 06:57
DelayedJob log job queue time
# Measures each job's time spent in a queue
#
# Register the pluging to start using it
# Delayed::Worker.plugins << Delayed::QueueTimeLoggerPlugin
#
class Delayed::QueueTimeLoggerPlugin < Delayed::Plugin
callbacks do |lifecycle|
lifecycle.before(:perform) do |worker, job|
queued_for = Time.zone.now - job.created_at
@michaelkl
michaelkl / ical.sh
Last active October 26, 2020 08:37
Interactive calendar for your console. Allows to scroll through the calendar interactively. Uses `cal` utility to print the calendar.
#!/usr/bin/env sh
# Interactive cal
#
# Allows to scroll through the calendar interactively.
# Uses `cal` utility to print the calendar.
#
# © Michael Klimenko
set_current_date() {
@michaelkl
michaelkl / rubocop.rb
Created March 19, 2020 11:47 — forked from skanev/rubocop.rb
A Rubocop wrapper that checks only added/modified code
#!/usr/bin/env ruby
# frozen_string_literal: true
# Source: https://gist.github.com/skanev/9d4bec97d5a6825eaaf6
#
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
@michaelkl
michaelkl / sshot_to_dropbox.sh
Created June 3, 2018 07:49
Thunar Dropbox upload, share and remove action
dropbox_uploader -E upload "%n" Скриншоты/ && dropbox_uploader -u -q share "Скриншоты/%n" | xclip -filter -selection clipboard; zenity --info --window-icon=/usr/share/icons/hicolor/16x16/apps/thunar-dropbox.png --title="Dropbox" --ok-label="Close" --text="%n was uploaded, URL was copied into clipboard."
@michaelkl
michaelkl / ape2flac.sh
Last active April 22, 2017 07:19
APE to FLAC split and convert
# Install flac, shntool and mac on Archlinux box
sudo yaourt -S flac shntool mac
# Single file:
shntool conv -o flac xxxxx.ape
# Split with cue info:
shntool split -f image.cue -t '%n.%t' -o flac image.ape
# or
cuebreakpoints image.cue | shnsplit -o flac image.ape
@michaelkl
michaelkl / ffmpeg_snippets.sh
Last active April 14, 2018 17:07
Transcoding video with ffmpeg
# Хороший cheat-sheet есть тут:
https://habrahabr.ru/post/333664/
## Transcode video, copy audio in single pass
# see http://trac.ffmpeg.org/wiki/Encode/H.264
ffmpeg -i input -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv
## Rotate video
# see http://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg/9570992#9570992
# For the transpose parameter you can pass:
# Что установлено:
pacman -Qqe
# Найти, каком пакету принадлежит файл:
pacman -Qo /path/to/file
# To retrieve a list of the files installed by a package:
pacman -Ql vicious
# For recursively removing orphans
@michaelkl
michaelkl / autobrightness.sh
Created November 12, 2016 12:00
screen brightness auto ajustment according to lighting (detected by webcam)
#!/bin/bash
TMPFILE=`mktemp /tmp/tmp.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.jpg`
fswebcam --jpeg 95 $TMPFILE
AVG=`convert $TMPFILE -format "%[mean]" info:`
BRIGHT=`echo $AVG | awk '{print int($1/65535*100+30)}'`
xbacklight -set $BRIGHT -time 2000
rm -rf $TMPFILE