Skip to content

Instantly share code, notes, and snippets.

@zuf
zuf / bash_history_auto_backup.sh
Created June 26, 2023 16:15
Simple bash history auto backup
# copy to your .bashrc to keey bash history backups at ~/bak/bash/history/
# backup bash history when start new bash session and there no bak files for last 5 minutes
LAST_HIST_BAKS=$(find $HOME/bak/bash/history/ -type f -mmin -5)
if [ -z "$LAST_HIST_BAKS" ]; then
mkdir -p $HOME/bak/bash/history/
zstd < $HOME/.bash_history > $HOME/bak/bash/history/bash_history.$(date +%Y-%m-%d_%H-%M-%S.%N).zst
# remove old (older then 30 days) bak files
find ~/bak/bash/history/ -type f -mtime '+30' | xargs --no-run-if-empty rm
@zuf
zuf / russian_cities.json
Last active August 7, 2018 21:17
Список городов России (для автодополнения в формах)
["Адыгейск (Адыгея)","Майкоп (Адыгея)","Горно-Алтайск (Алтай)","Алейск (Алтайский край)","Барнаул (Алтайский край)","Белокуриха (Алтайский край)","Бийск (Алтайский край)","Горняк (Алтайский край)","Заринск (Алтайский край)","Змеиногорск (Алтайский край)","Камень-на-Оби (Алтайский край)","Новоалтайск (Алтайский край)","Рубцовск (Алтайский край)","Славгород (Алтайский край)","Яровое (Алтайский край)","Белогорск (Амурская область)","Благовещенск (Амурская область)","Завитинск (Амурская область)","Зея (Амурская область)","Райчихинск (Амурская область)","Свободный (Амурская область)","Сковородино (Амурская область)","Тында (Амурская область)","Циолковский (Амурская область)","Шимановск (Амурская область)","Архангельск (Архангельская область)","Вельск (Архангельская область)","Каргополь (Архангельская область)","Коряжма (Архангельская область)","Котлас (Архангельская область)","Мезень (Архангельская область)","Мирный (Архангельская область)","Новодвинск (Архангельская область)","Няндома (Архангельская область)","Он
@zuf
zuf / go58.go
Created January 19, 2017 22:06
CLI tool which generates random strings (passwords) encoded with base58
package main
import "fmt"
import "flag"
import "crypto/rand"
import "math/big"
import "github.com/tv42/base58"
func secure_random(n int) []byte{
b := make([]byte, n)
@zuf
zuf / after-contourgps-mount.sh
Created July 6, 2015 15:48
Shell script for automated sync mounted to usb action camera to my archive. GUI progress shown through zenity (matedialog) tool. This script was written for usage with udev rules.
#!/usr/bin/bash
# This script uses too much unneeded dependencies (like python for adding some integers). Sorry for that.
# You can clean it for your cases (replace python with bc for example).
# TODO: test rsync version shoud has --info=progress2 option (v3.0.10 or more)
#USER="`whoami`"
CONTOUR_MOUNTPOINT="/run/media/$USER/CONTOUR GPS/DCIM"
CONTOUR_ARCHIVE='/path/to/archive'
@zuf
zuf / extract_contour_gps.sh
Created May 20, 2015 10:16
This script extracts GPS data (in GPX format) from ContourGPS camera videos.
#!/usr/bin/env sh
# This script extracts GPS data (in GPX format) from ContourGPS camera videos.
# You need to have ffmpeg, gpsbabel and gnu parallel to run this script.
#
# Please note that *.gpx files in given directory may be overwriten!
#
# Usage: extract_contour_gps.sh <directory_with_movies>
#
@zuf
zuf / compose_star_trails.rb
Created October 4, 2013 12:52
Helps to create start trails from series of photos. It uses ImageMagick.
#!/usr/bin/env ruby
require 'rubygems'
require 'tmpdir'
@compose_method = 'LightenIntensity'
@processes_count = 4
@intermediate_image_format = "tga"
class Numeric
@zuf
zuf / PKGBUILD
Created October 6, 2012 15:45
PKGBUILD for gnuradio 3.6.2
# Contibutor: kontakt.zuf@gmail.com
# Maintainer: Moritz Fischer <moritz.fischer@student.kit.edu>
pkgname=gnuradio
pkgver=3.6.2
pkgrel=1
pkgdesc="free software development toolkit that provides the signal processing runtime and processing blocks to implement software radios using readily-available, low-cost external RF hardware and commodity processors"
arch=('i686' 'x86_64')
license=('GPL')
depends=('fftw' 'python2-numpy' 'boost-libs' 'cppunit' 'swig' 'gsl' 'blas' 'guile' 'libuhd')
makedepends=('boost')
@zuf
zuf / kdenlive-transition-fixer.rb
Created July 30, 2012 10:38
kdenlive dissolve transition fixer. Prints fixed project xml contents. (See kdenlive bug: http://www.kdenlive.org/mantis/view.php?id=2668)
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
if ARGV.size != 1
$stderr.puts "kdenlive dissolve transition fixer. Prints fixed project xml contents. (See kdenlive bug: http://www.kdenlive.org/mantis/view.php?id=2668)"
$stderr.puts "Usage: #{File.basename $PROGRAM_NAME} <project.kdenlive>"
@zuf
zuf / Gemfile.lock
Created March 27, 2012 14:25
Gemfile for Russian gem issue #34
GIT
remote: https://github.com/tgbyte/twitter-bootstrap-rails.git
revision: ef49b93cb585413b0e2d14e44e50063a0fd58b5c
specs:
twitter-bootstrap-rails (2.0.2.2)
actionpack (>= 3.1)
less-rails (~> 2.1.5)
railties (>= 3.1)
GEM
@zuf
zuf / optimize_images.rb
Created February 3, 2012 09:04
Small ruby script that try to optimize JPEG and PNG images with external tools like jpgcrush or optipng
#!/usr/bin/env ruby
require 'rubygems'
@optimize_image_bin = 'optimize_image_bin' # from google pagespeed sdk
@pngout = 'pngout'
@pngcrush = 'pngcrush'
@optipng = 'optipng'
@advpng = 'advpng'