Skip to content

Instantly share code, notes, and snippets.

@ArneAnka
ArneAnka / gist:f245043a1fd2a29c68cb4f71b78203c7
Created April 10, 2017 20:01
Extract rar files recursively and remove the rar files afterwards
# Assuming extglob option of bash is set, which is the default, otherwise set with shopt -s extglob
# http://askubuntu.com/a/903235/562529
`find . -name '*.rar' -exec unrar e {} \; -exec rm {} \; && rm *.r+([[:digit:]])`
# Maybe better option?
find . -name '*.rar' -exec unrar e {} \; -exec rm {} \; && rm *.r*
@ArneAnka
ArneAnka / gist:bf636079faa9df86f7511b38982424ed
Created May 11, 2017 11:42
Search images of a specific dimension
# This scripts helps you when seraching images of a speceifc dimension. Lets
# say you want to remove thumbnails or something, then this is good!
# Notice the `echo`, remove that and run the script. That will REMOVE you files.
# Change `rm` to `cp` to copy the files if you want to review them before deletion.
```
#!/bin/bash
targetDir="$HOME/Pictures"
Font awesome:
In App directory, run:
```
npm install font-awesome
```
In App/resources/assets/sass/app.scss add
```
// Font awsome
$fa-font-path: "/assets/fonts";
@ArneAnka
ArneAnka / gist:56ce9657190fee72051dbf1012871726
Created December 16, 2018 13:01
How to repair broken permission
https://serverfault.com/a/35079
```
find /home/user -type d -print0 | xargs -0 chmod 0775
find /home/user -type f -print0 | xargs -0 chmod 0664
```
@ArneAnka
ArneAnka / gist:2fac16fa6c7204b0990365d1af2f5331
Created December 16, 2018 11:42
Move/copy files to folder corresponding their fileextension
find . -type f -exec bash -c 'mkdir -p sorted/"${0##*.}"; cp "$0" sorted/"${0##*.}"' {} \;
@ArneAnka
ArneAnka / gist:051571f0306c52a9aeccc4c6eee28448
Last active June 30, 2019 11:44
Find images, and copy or move them
# Two scripts that do the same thing a little different, notice `mv` and `cp`. Your choice
# What will happen is that find will recursivly serach the current folder for images, read when
# the file was created, and move/copy it to a corresponding folder.
# This is from https://apple.stackexchange.com/questions/280252/recursively-search-for-images-and-move-them-to-a-date-folder
# http://unix.stackexchange.com/a/83838
find -E . -regex '.*\.(jpg|JPG|png|PNG|jpeg|JPEG|bmp|BMP)' | while read file; do
ts=$(stat -f '%Sm' -t '%Y-%m-%d' "$file")
folder="/Users/username/Documents/Backup_images/$ts"
1. youtube-dl -a lista.txt // Download all lectures with youtube-dl from file `lista.txt`
2. for f in *.mp4; do ffmpeg -i "$f" -vn "$(basename "$f" .mp4).mp3"; done // convert all mp4 to mp3
3. for f in *.mp3; do ffmpeg -i "$f" -af "highpass=f=200, lowpass=f=3000" "$(basename "$f" .mp3)_noice.mp3"; done
4. for f in *_noice.mp3; do ffmpeg -i "$f" -af silenceremove=1:0:-50dB "$(basename "$f" .mp3)_silence.mp3"; done
5. ffmpeg-normalize *.mp3 -c:a libmp3lame -b:a 192k -ext mp3 (https://superuser.com/a/323127/643639, https://stackoverflow.com/a/58997035/4892914)
6. ????
7. PROFIT
(2. ffmpeg -i input.mp4 -f mp3 -ab 192000 -vn output.mp3)
(3. ffmpeg -i output.mp3 -af "highpass=f=200, lowpass=f=3000" output_clean.mp3) // reduce noice (https://superuser.com/questions/733061/reduce-background-noise-and-optimize-the-speech-from-an-audio-clip-using-ffmpeg)
#!/bin/bash
HOST=192.168.1.50
# Check if the script is being executed as root
if [[ $EUID -ne 0 ]]; then
echo -e "🥴 \033[0;31mThis script must be run as root \033[0m"
exit 1
fi
# Ping the storage server to determin connectivity
@ArneAnka
ArneAnka / gist:1bf5b39cfd208e7c10caf28d17f416cb
Created July 29, 2020 06:14
Move "The" to the end of a column
UPDATE games
SET title = CASE WHEN INSTR(title,' ')>0
AND LEFT(title,INSTR(title,' '))
IN ('The ')
THEN CONCAT(UPPER(SUBSTRING(title,INSTR(title,' ')+1,1))
,SUBSTRING(title,INSTR(title,' ')+2)
, ', '
, LEFT(title,INSTR(title,' ')-1))
ELSE title
END