Skip to content

Instantly share code, notes, and snippets.

View spvkgn's full-sized avatar

spvkgn

  • Russia
View GitHub Profile
@spvkgn
spvkgn / compton.service
Created May 2, 2018 09:35
systemd user units
[Unit]
Description=Compton X11 compositor
After=graphical.target
[Service]
Type=forking
Restart=always
RestartSec=10
ExecStart=/usr/bin/compton -b
ExecReload=/bin/kill -SIGUSR1 $MAINPID
@spvkgn
spvkgn / ffmpeg_tips.txt
Last active May 6, 2022 07:27
FFmpeg tips
# Convert HLS .m3u8 playlist to MP4
ffmpeg -i playlist.m3u8 -acodec copy -vcodec copy output.mp4
# for stream with AAC audio also needs to add the bitstream filter https://ffmpeg.org/ffmpeg-bitstream-filters.html#aac_005fadtstoasc
ffmpeg -i playlist.m3u8 -acodec copy -bsf:a aac_adtstoasc -vcodec copy output.mp4
# lossless cut from URL. -ss input seeking point, -t duration
ffmpeg -ss 00:00:00 -i <URL> -t 00:00:00 -acodec copy -vcodec copy output.mp4
# get URL with youtube-dl. -to output seeing point
ffmpeg -ss 00:00:00 -i `youtube-dl -g <URL>` -t 00:00:00 -acodec copy -bsf:a aac_adtstoasc -vcodec copy -copyts -avoid_negative_ts 1 output.mp4
@spvkgn
spvkgn / suspend-modules
Last active April 6, 2018 11:18 — forked from mauron85/suspend-modules
Ubuntu 16.04 systemd unload modules on sleep
#!/bin/bash
# Put into /lib/systemd/system-sleep/suspend-modules
# chmod a+x /lib/systemd/system-sleep/suspend-modules
# Create /etc/suspend-modules.conf
# with one module per line
# credits to:
# https://bbs.archlinux.org/viewtopic.php?pid=1540125#p1540125
dget -ux http://ru.archive.ubuntu.com/ubuntu/pool/main/x/xorg-server/xorg-server_1.19.5-0ubuntu2.dsc
wget https://bugs.freedesktop.org/attachment.cgi?id=129861 -O xkb-switch-on-release.patch
cd cd xorg-server-1.19.3
quilt import ../xkb-switch-on-release.patch
dch -l ppa~artful -D artful 'Add xkb-switch-on-release.patch'
debuild -S -sd -d
@spvkgn
spvkgn / gist:0e64d620bf5ef41f81cda115ffcff108
Last active July 2, 2017 04:39
add gcc 4.9 alternative
#!/bin/sh
sudo apt install -y gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
@spvkgn
spvkgn / bitrate.sh
Created June 25, 2017 05:41
Show bitrate of audio files in current dir with mediainfo
#!/bin/sh
FILETYPES="*.mp3 *.m4a *.mpc *.ogg *.flac *.ape *.wav"
MEDIAINFO_PARAMS=--inform="Audio;%BitRate/String% %BitRate_Mode% %Format%\n"
if [ ! -z "$1" ]
then mediainfo "$MEDIAINFO_PARAMS" "$@" | sed '${/^$/d}'
else mediainfo "$MEDIAINFO_PARAMS" $FILETYPES | sed '${/^$/d}'
fi
@spvkgn
spvkgn / gist:a5412912ecb731af544a49b0f85acf2c
Last active June 24, 2017 08:44
Add random keyfile to existing LUKS device
sudo dd if=/dev/urandom of=/root/keyfile bs=1024 count=4
sudo chmod 0400 /root/keyfile
sudo cryptsetup luksAddKey /dev/sdX /root/keyfile
@spvkgn
spvkgn / create-tar.gz.sh
Created June 20, 2017 14:49
Create tarball from git repo
#!/bin/sh
[ ! -z "$1" ] || exit
NAME=$1 ; cd $NAME
DATESTAMP=$(date +"%Y%m%d")
VERSION=$(git describe master --tags --match='v*' | sed 's/^v//' | cut -d- -f1)
COMMIT=$(git rev-parse --short=5 HEAD)
git archive master --format=tar.gz --prefix=$NAME-$VERSION~git$DATESTAMP.$COMMIT/ -o ../$NAME-$VERSION~git$DATESTAMP.$COMMIT.tar.gz
@spvkgn
spvkgn / autossh.service
Last active July 3, 2017 05:12
AutoSSH tunnel systemd unit
[Unit]
Description=AutoSSH service for a reverse tunnel from some.example.com to localhost
After=network.target
After=networking.service
[Service]
Environment=AUTOSSH_FIRST_POLL=30
Environment=AUTOSSH_GATETIME=0
Environment=AUTOSSH_POLL=60
Environment=USERNAME=user