Skip to content

Instantly share code, notes, and snippets.

View loucyx's full-sized avatar
🏳️‍⚧️
Channeling code witchcraft ✨

Lou Cyx loucyx

🏳️‍⚧️
Channeling code witchcraft ✨
View GitHub Profile
@loucyx
loucyx / boonmarklet.js
Last active October 7, 2025 16:07
Bookmarklet to have a tiny "AMD" require implementation in the global scope.
javascript:globalThis.require??=(p,c)=>Promise.all(p.map(i=>import(i.replace(/^(\w{3}):/,(_,m)=>`//esm.sh/${m==="npm"?"":`${m}/`}`)))).then(c);
@loucyx
loucyx / spongeBobCase.ts
Last active September 4, 2025 03:57
Sponge Bob casing util
/** Takes a string and returns it's upper case */
export const upperCase = <const Source extends string>(source: Source) =>
source.toLocaleUpperCase() as Uppercase<Source>;
/** Takes a string and returns it's lower case */
export const lowerCase = <const Source extends string>(source: Source) =>
source.toLocaleLowerCase() as Lowercase<Source>;
/** Takes a `from` and a `to` and returns a random integer. */
export const randomNumber = (from: number) => (to: number) =>
@loucyx
loucyx / cssPath.js
Last active October 8, 2025 00:42
Get specific CSS path of given element.
/**
* Get the CSS path of a given element.
*
* @param {Pick<Element, "id" | "parentElement" | "tagName">} [element] Element to get the css path to.
* @param {string} [path=""] Path so far (used in recursion).
* @returns {string} Full CSS path to the given element
*/
export const cssPath = (element, path = "") => {
const tagName = element?.tagName ?? "HTML";
const childrenOfType = element?.parentElement
@loucyx
loucyx / design-mode.js
Last active September 4, 2025 03:57
Design Mode Toggle Bookmarklet
javascript:((d,o,m)=>{d[m]=d[m]!==o?o:"off"})(document,"on","designMode")
@loucyx
loucyx / programmers-day.js
Last active September 4, 2025 03:57
Log only on programmer's day
/**
* Get current day number of the given date.
*
* @param now Target date (current date by default).
*/
const dayNumber = (now = new Date()) =>
Math.floor(
(now.getTime() - new Date(now.getFullYear(), 0, 0).getTime()) / 864e5,
);
@loucyx
loucyx / npm.1-1.svg
Last active September 4, 2025 03:57
NPM Logo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@loucyx
loucyx / npm-logo.svg
Last active September 4, 2025 03:57
NPM logo optimized (196 bytes)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.