Skip to content

Instantly share code, notes, and snippets.

@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/
@spyesx
spyesx / 1.get-volume-names.md
Last active August 25, 2020 12:27
Mount all docker volumes in an Alpine container for inspection. I use this on macOS since docker volumes are not directly accessible.

Get all volumes' names

$ docker volume ls | awk '{print $2}' | grep -v 'VOLUME'
> 0d8ffd800baf623b030e727829f6a31dd05a0ed73877021f018a849be0ce6433
> 0dc6353456b723b4885f556fb49938b497bdea4bf792bca12d7b5c6ef12dcf16
> 2a579e3e73596349308a4ece576f00c6822f1a04481965f6b8ed366b771dd5ea
@spyesx
spyesx / semantic-commit-messages.md
Last active August 29, 2020 16:29 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@spyesx
spyesx / detox_rename_filenames.sh
Created February 4, 2020 04:22
Clean up and lowercase filenames
# https://explainshell.com/explain?cmd=detox+-s+iso8859_1+-r+-v+.%2F*
detox -s iso8859_1 -r -v ./*
# Lowecase filenames
# linux
rename 'y/A-Z/a-z/' *
# macOS needs to be forced
@spyesx
spyesx / optimize_pdf_size.sh
Created January 24, 2020 04:20
Optimize PDF size by changing it's density
# https://explainshell.com/explain?cmd=convert+-density+200x200+-quality+60+-compress+jpeg+input.pdf+output.pdf
convert -density 200x200 -quality 60 -compress jpeg input.pdf output.pdf
apiVersion: v1
data:
auth: <SECRET>
kind: Secret
metadata:
name: staging-basic-auth
type: Opaque
@spyesx
spyesx / 5G-vote.js
Last active November 27, 2019 16:10
5G Vote
var cleanStorage = function(){
console.log('%c Start clean localStorage', 'color: green')
var myStorage = window.localStorage;
var ids = Object.keys(myStorage).filter( (key) => {
return key.slice(0,3) === '5G_'
})
ids.forEach( (id) => {
console.log('clean: '+id)
window.localStorage.removeItem(id);
})