Skip to content

Instantly share code, notes, and snippets.

@szabo92
szabo92 / reduce_size
Last active September 14, 2018 14:29
Reduce size of image
mogrify -path ./resized -filter Triangle -define filter:support=2 -thumbnail WIDTH -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip *
@szabo92
szabo92 / scroll.js
Created September 10, 2018 18:57
Load more data on scroll
window.onscroll = function() {
if (window.scrollY + 1 > document.body.clientHeight - window.innerHeight) {
// load more data
}
}
sudo sysctl vm.swappiness=0
@szabo92
szabo92 / scrypt
Last active June 1, 2018 01:33
scrypt-kdf
scrypt-kdf password site 32768 20 20 28
# To avoid plain text password input, use the one liner:
while read site && read -s pass; do scrypt-kdf $pass $site `python -c "print(2**15)"` 20 20 28; break; done; pass=""
@szabo92
szabo92 / z3fold
Created May 2, 2018 23:35
enable z3fold option for zswap.zpool
sudo su
echo z3fold >> /etc/initramfs-tools/modules
update-initramfs -u
@szabo92
szabo92 / sudo
Created May 2, 2018 21:41
Execute command in PATH as sudo
sudo env "PATH=$PATH" command
@szabo92
szabo92 / su
Created March 15, 2018 23:21
su
# when `su` raises authentication error is probably because root password is not set
# you can login with your sudo enabled account and password
sudo su
# or you can set a password for root
sudo passwd root
# after that, you can do `su` and login with the password set before
@szabo92
szabo92 / rclone
Created March 13, 2018 08:34
RClone sync with Dropbox
rclone sync ~/Dropbox/ dropbox: --exclude ".*"
# --exclude ".*" is necessary to avoid errors
@szabo92
szabo92 / utf-8
Created March 7, 2018 02:49
Repair file names
sudo convmv -f iso-8859-1 -t utf-8 -r .
@szabo92
szabo92 / tar
Created March 4, 2018 10:26
tar
# x: This option tells tar to extract the files.
# v: The “v” stands for “verbose.” This option will list all of the files one by one in the archive.
# z: The z option is very important and tells the tar command to uncompress the file (gzip) or j (bZip2).
# f: This options tells tar that you are going to give it a file name to work with.
tar xvzf file.tar.gz
tar xvjf file.tar.bz2
# Extract to other directory