Skip to content

Instantly share code, notes, and snippets.

@spyesx
spyesx / fill_images_in_black.sh
Last active November 20, 2020 12:56
Fill all PNG, ICO, JPG and SVG in black. Useful to reset common assets such as apple-touch-* icons, favicons, android-* icons...
# https://explainshell.com/explain?cmd=for+file+in+.%2F**%2F**.%7Bpng%2Cjpg%2Cico%2Csvg%7D%3B+do+convert+%22%24file%22+-fill+black+-draw+%27color+0%2C0+reset%27+%22%24file%22%3B+printf+%27.%27%3B+done
for file in ./**/**.{png,jpg,ico,svg}; do convert "$file" -fill black -draw 'color 0,0 reset' "$file"; printf '.'; done
@spyesx
spyesx / 01_wrap.sh
Created August 17, 2018 07:16
Prepend and append text to files to wrap their content
#!/bin/sh
for file in *.vue; do
cat prepend.txt $file >> $file.$$
mv $file.$$ $file
done
for file in *.vue; do
cat $file append.txt >> $file.$$
mv $file.$$ $file
done
@spyesx
spyesx / uuidv4.js
Last active August 7, 2019 17:38
Generate UUIDv4 in JS
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
@spyesx
spyesx / find_filenames_GT_42_chars.sh
Created October 12, 2018 12:50
How to find filenames longer than 42 chars
# https://explainshell.com/explain?cmd=find+-E+.+-regex+%27.*%2F%5B%5E%2F%5D%7B43%2C%7D%27
find -E . -regex '.*/[^/]{42,}'
# Common problem faced when you need to copy files to an encrypted volume.
# You could also create a ZIP of your files and save it into the encrypted volume.
# Or, you could just create another volume into this encrypted volume.
@spyesx
spyesx / ISO_8601_Time.md
Last active January 15, 2019 13:47
ISO 8601 Time with Milliseconds and Nanoseconds

For macOS, the date utility doesn't give the right information. You need to install GNU date utility.

brew install coreutils

Homebrew will install the utility as gdate instead of date, which leaves the original date untouched and available.

gdate has an --iso-8601 option available, but it doesn't give a format that strictly follows the ISO 8601 standard, as far as I can determine. I find it better to explicitly state the format with:

@spyesx
spyesx / SynologyUsedPorts.md
Created April 16, 2019 00:29
Synology Used Ports
@spyesx
spyesx / disable_WP_updates.php
Last active October 9, 2019 11:43
Disable Wordpress updates
<?php
# Sometimes, you need to disable Wordpress updates because you prefer to update your Dockerfile or Helm chart.
# Source : https://wordpress.org/support/article/configuring-automatic-background-updates/
# function.php or a custom plugin
add_filter( 'automatic_updater_disabled', '__return_true' );
add_filter( 'auto_update_core', '__return_true' );
add_filter( 'auto_update_translation', '__return_false' );
add_filter( 'auto_core_update_send_email', '__return_false' );
@spyesx
spyesx / find_hidden_files.sh
Created October 14, 2019 12:37
Find and delete all files starting by ._ but in directories @eadir. Command needed on an encrypted volume on DSM (Synology)
find . -type f -name '._*' ! -path '*@eaDir*' -exec rm -f "{}" \;
# Find and delete all files starting by ._ but in directories @eaDir. Command needed on an encrypted volume on DSM (Synology)
# https://explainshell.com/explain?cmd=find+.+-type+f+-name+%27._*%27+%21+-path+%27*%40eaDir*%27+-exec+rm+-f+%22%7B%7D%22+%5C%3B
@spyesx
spyesx / docker-cheat-sheet.md
Last active November 2, 2024 08:44 — forked from dwilkie/docker-cheat-sheat.md
Docker Cheat Sheet

Stop all containers

$ docker stop $(docker ps -q)

Build docker image

$ cd /path/to/Dockerfile
@spyesx
spyesx / kubectl-cheat-sheet.md
Last active October 29, 2019 09:16
kubectl cheat sheet

Add a kubectl context

# copy cluster's certificate to a file
vi cluster-certificate.txt

# Set cluster
kubectl config set-cluster <CLUSTER_NAME> --server=https://37.187.1.138:6443 --certificate-authority=cluster-certificate.txt --embed-certs=true

# Set credentials