Skip to content

Instantly share code, notes, and snippets.

@frankIT
frankIT / netinst-postinst.sh
Last active November 8, 2017 21:13
debian-netinst postinstall script
#!/bin/bash
# jessie/testing
packages=(
# base desktop
xorg
xfce4
# openbox
slim
@frankIT
frankIT / CompizLastRide.sh
Last active October 15, 2016 23:43
last ride with compiz: build it on debian jessie
#!/bin/bash
# http://wiki.compiz.org/C%2B%2BCompiling
# This is basically a script version of the official documentation above
# with a few fix needed to successfully compile on debian jessie
wget https://launchpad.net/compiz/0.9.10/0.9.10.0/+download/compiz-0.9.10.0.tar.bz2
tar -xf compiz-0.9.10.0.tar.bz2
rm compiz-0.9.10.0.tar.bz2
cd compiz-0.9.10.0/
@frankIT
frankIT / ogg2mp3.bat
Created September 5, 2014 22:25
convert bulk ogg files to mp3 with ffmpeg under windows
for %%a in ("*.ogg") do ffmpeg -i "%%a" -acodec libmp3lame "mp3\%%~na.mp3"
pause
@frankIT
frankIT / resize.sh
Last active November 23, 2017 00:54
batch resize img linux
#!/bin/bash
# it will substitute all source files and needs to work with absolute paths
#for f in *.jpg; # loop folder
for f in $(find "/absolute/path/" -name '*.jpg'); do # loop folder recursively
# crop images to squared ones according to the shorter side of the source
do convert $f -gravity center -crop `identify -format "%[fx:min(w,h)]x%[fx:min(w,h)]+0+0" $f` +repage $f;
# resize the canvas of the source images to squared ones according to the larger side of the source and fill the gaps with a bg color
do convert $f -resize "600x600" -gravity center -background "#f6f6f6" -extent 600x600 $f;
# resize the image to a with of 1080 preserving the aspect ratio
@frankIT
frankIT / isViewport.js
Created October 15, 2016 22:40
Just a JS function to check if the viewport matches the guessed bootstrap grid option.
/*
* Just a JS function to check if the viewport matches the guessed bootstrap grid option.
* It uses the modern matchMedia object passing the same media query that bootstrap use, in both v3 or 4.
* Otherwise falls back using the standard window object.
* I often saw using the screen object for the same purpose,
* but it behaves strangely in extended desktop layouts with multiple monitors.
* Note that window.innerWidth instead, should not be used from within frames.
*/
function isViewport(bsSelector)
@frankIT
frankIT / videoCheck.sh
Created November 23, 2017 01:15
loop avprobe on a folder to check for potentially corrupted video
#!/bin/bash
# ...let's say you just copied tons of your gopro video from a faulty sd :)
for f in `ls *.MP4`; do
avprobe -loglevel error "$f"
#ffprobe -loglevel error "$f"
done
@frankIT
frankIT / videoEdit.sh
Last active November 27, 2017 00:51
no reencoding cli video edit using avconv/ffmpeg
#!/bin/bash
# cut chunk by giving start time and length
avconv -ss 00:02:57.00 -i GP015230.MP4 -t 23 -c copy GP015230[00.02.57.00+23].mp4
# turn video 90° clockwise
avconv -i phenomenoh.mp4 -vf "transpose=1" phenomeno_portrait.mp4
# scale/resize canvas but keep video aspect ratio filling the gaps with black
avconv -i phenomeno.mp4 -vf "scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2" phenomeno_canvas_portrait_720.mp4
@frankIT
frankIT / webp2png.sh
Last active April 30, 2022 03:46
batch convert webp to jpg
#!/bin/bash
# apt-get install webp
for f in *.webp
do dwebp $f -o "$f.png"
done;
@frankIT
frankIT / switchphpto
Last active January 22, 2024 11:05
coexistence of multiple php versions on debian stretch
#!/bin/bash
# https://deb.sury.org/
VERSION=$1
# unmount all php apache modules
for version in $(ls /etc/php); do
sudo a2dismod php$version
done
@frankIT
frankIT / chcodename.sh
Created September 22, 2019 23:13
change distro release codename to all apt config files
#!/bin/bash
for f in $(grep -Ril stretch "/etc/apt/sources.list.d/");
do sudo sed -i 's/stretch/buster/g' "$f";
done;