Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / array-functions.js
Created March 21, 2022 10:25
Common array functions in javascript
[1, 2, 3].push(4)
// [1,2,3,4]
[1, 2, 3].pop()
// [1,2]
[1, 2, 3].shift()
// [2,3]
[1, 2, 3].unshift(0)
@spyesx
spyesx / mark6.js
Created January 6, 2022 13:40
mark6 lazy generator in javascript
const options = {
n6 : { price: 10, columns: 6 },
n7 : { price: 70, columns: 7 },
n8 : { price: 280, columns: 8 }
}
const opt = 'n7'
const rows = 10
const columns = options[opt].columns
@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 / netlify.toml
Created September 27, 2021 15:54 — forked from DavidWells/netlify.toml
All Netlify.toml & yml values
[Settings]
ID = "Your_Site_ID"
# Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts.
[build]
# This is the directory to change to before starting a build.
base = "project/"
# NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
# This is the directory that you are publishing from (relative to root of your repo)
@spyesx
spyesx / service-workers.md
Created September 21, 2021 16:12 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@spyesx
spyesx / gist:411f312f3b6a346b26113f37af6232df
Created September 17, 2021 10:07 — forked from ayamflow/gist:b602ab436ac9f05660d9c15190f4fd7b
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
body{
background:none;
font-family:arial;
max-width:1440px;
margin:0 auto;
font-size:16px;
}
h1,h2{
color:white;
@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/