Skip to content

Instantly share code, notes, and snippets.

View Lucent's full-sized avatar

Michael Dayah Lucent

View GitHub Profile
@tynes
tynes / name-claim.md
Last active March 28, 2023 16:54
Domain Name Claiming for Handshake

Handshake Domain Name Claims

The Handshake Network has reserved the Alexa Top 100k domains on chain to make sure that important brands are able to own their name in the system. These names can be claimed using a DNSSEC proof of ownership. This means that the owner of the domain name must place a TXT record at their domain name that includes a controlled address.

For technical instructions, see:

@victornpb
victornpb / deleteDiscordMessages.js
Last active April 16, 2024 09:32
Delete all your messages from DM or Channel in Discord
/*
This file is now hosted here:
https://github.com/victornpb/undiscord
*/
@jakub-g
jakub-g / async-defer-module.md
Last active May 6, 2024 16:18
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@amoshydra
amoshydra / CollatePages.js
Created November 23, 2018 02:48
A script to consolidate pdf consisting of a set of even and a set of odd pages into a single correct paginated PDF file
// Complements: Planet PDF (http://www.planetpdf.com/)
// Source: https://forums.adobe.com/thread/286654?start=40&tstart=0
// Modified by
// - Christian Sass for Acrobat XI compatibility
// - Bernd Alheit for newer Acrobat compatibility
// - amoshydra for comsolidating solution
// Add a menu item to reverse all pages in the active document
app.addToolButton({ cName: "Reverse", cLabel: "Reverse", cExec: "PPReversePages();", cEnable: "event.rc = (event.target != null);"});
app.addToolButton({ cName: "Collate", cLabel: "Collate", cExec: "trustedCollatePages();", cEnable: "event.rc = (event.target != null);"});
@klingtnet
klingtnet / how-to-upgrade-nvmw-ssd-firmware-on-linux.md
Last active September 16, 2023 23:37
How to upgrade [Lenovo] NVMe SSD firmware on Linux

The instructions were tested on a Lenovo X1 Carbon 5th Gen (X1C5) on Arch Linux but should be applicable to other Lenovo models and Linux distributions.

BACKUP YOUR DATA! I created a bootable Ubuntu Image like this:

$ sudo sh -c 'curl --location --silent --fail "http://releases.ubuntu.com/18.04/ubuntu-18.04.1-desktop-amd64.iso" | pv > /dev/<your-usb-drive>'
# note that pv is only there to show progress, it is perfectly fine to redirect curl to the usb drive directly.

then I booted from this drive by pressing F12 on reboot and dumped my NVMe disk to an external hard drive like this:

@inodaf
inodaf / create-observable.js
Last active June 24, 2020 20:05
👀 Object Observable using ES6 Proxies.
function createObservable(observable, { onGet, onSet }) {
const interceptor = {
get(target, key, receiver) {
onGet(key)
return target[key]
},
set(target, prop, value) {
onSet(prop, value)
return true
}
@samthor
samthor / safari-nomodule.js
Last active February 14, 2024 02:54
Safari 10.1 `nomodule` support
// UPDATE: In 2023, you should probably stop using this! The narrow version of Safari that
// does not support `nomodule` is probably not being used anywhere. The code below is left
// for posterity.
/**
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
* load <script nomodule> anyway. This snippet solve this problem, but only for script
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
*
* Again: this will **not** prevent inline script, e.g.:
@KiaraGrouwstra
KiaraGrouwstra / proxy-async.js
Last active January 3, 2021 15:36
using ES6 Proxy to let Promises/Observables pretend like they're regular values
// using ES6 Proxy to let Promises/Observables pretend like they're regular values.
// get the mapping function used for async objects
let getMapper = (target) => target instanceof Promise ? 'then' :
target instanceof Observable ? 'switchMap' : null;
// ^ fails if the Observable is in a local namespace e.g. Rx.Observable
// bind a value to its object if it's a function
let bindFn = (val, obj) => typeof val == 'function' ? val.bind(obj) : val;
@Rich-Harris
Rich-Harris / service-workers.md
Last active May 6, 2024 22:10
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.