Skip to content

Instantly share code, notes, and snippets.

@spyesx
spyesx / youtube_watch_later.js
Last active March 27, 2024 18:58
Get URLs of your youtube watch later playlist
// Execute this in the console of on your own playlist
var videos = document.querySelectorAll('.yt-simple-endpoint.style-scope.ytd-playlist-video-renderer');
var r = [];
var json = [];
r.forEach.call(videos, function(video) {
var url = 'https://www.youtube.com' + video.getAttribute('href');
url = url.split('&list=WL&index=');
url = url[0];
@spyesx
spyesx / string-to-slug.js
Last active March 15, 2024 12:05
String to slug in JS (wordpress sanitize_title)
var string_to_slug = function (str)
{
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñçěščřžýúůďťň·/_,:;";
var to = "aaaaeeeeiiiioooouuuuncescrzyuudtn------";
for (var i=0, l=from.length ; i<l ; i++)
@spyesx
spyesx / rsync_backup.sh
Last active February 16, 2024 14:03
Rsync backup excluding node_modules
# Backup files
#https://explainshell.com/explain?cmd=rsync+-azuv+--delete+--progress+--exclude+%27node_modules%27
rsync -auvhp --delete --exclude=node_modules [source] [destination]
# Remove all node_modules folders
# https://explainshell.com/explain?cmd=find+.+-name+%22node_modules%22+-type+d+-prune+-exec+rm+-rf+%27%7B%7D%27+%2B
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
@spyesx
spyesx / docker-cheat-sheet.md
Last active February 15, 2024 10:04 — 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 / adblock-blacklist.css
Last active February 7, 2024 09:48
Class and ID to avoid because of AdBlock
.sidebar_newsletter_sign_up,
.sidebar_subscribe,
.sign-up-form-single,
.signup-form--header,
.signup-with-checkboxes,
.skinny-sign-up,
.slidedown-newsletter,
.small-newsletter,
.social-link-mail,
.social_newsletter_box,
@spyesx
spyesx / readme.md
Last active December 30, 2023 16:31
Clean up old linux kernels

Remove old linux kernels

Script way

# Dry run to check
bash remove-old-kernels.sh

# Run
bash remove-old-kernels.sh exec
@spyesx
spyesx / esm-package.md
Created November 21, 2021 10:13 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@spyesx
spyesx / images-crawler.sh
Created October 31, 2022 08:13
Download all images listed in list.txt then make it a PDF
#!/usr/bin/env bash
# Download all images listed in list.txt then make it a PDF
wget --input list.txt -O $1.jpg
convert *.jpg output.pdf
@spyesx
spyesx / curl-to-nextcloud.sh
Created September 14, 2020 07:52
Upload a file to Nextcloud with curl
# source: https://docs.nextcloud.com/server/19/user_manual/files/access_webdav.html#accessing-files-using-curl
curl -u USERNAME:PASSWORD -T /path/to/file https://my.nextcloud.tld/remote.php/dav/files/USERNAME/path/to/directory/
@spyesx
spyesx / positive_negative.js
Last active October 26, 2022 14:29
Several methods to get a random positive or negative number
// Math.random() will give you a random decimal number between 0 and 1
// Just check if the number is greater than 0.5
// And apply -1 or 1 depending on the result
Math.random() < 0.5 ? -1 : 1;
// Math.random() will give you a random decimal number between 0 and 1
// Math.rand() of a Math.random() will give you an integer 0 or 1
// Use 0 or 1 as a result of a condition to use -1 or 1
Math.round(Math.random()) ? -1 : 1;
// /!\ NOTE : Can be used for any other values like 9 or 37 ; -2 or 2...