Skip to content

Instantly share code, notes, and snippets.

View loucyx's full-sized avatar
🔮
Doing some code witchcraft

Lou ✨ loucyx

🔮
Doing some code witchcraft
View GitHub Profile
@loucyx
loucyx / spongeBobCase.ts
Last active April 18, 2024 23:54
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 April 18, 2024 23:50
Get CSS path of given element.
/**
* Get the CSS path of a given element.
*
* @param {Element} [element] Element to get the css path to.
* @param {string} [path=""] Path so far (used in recursion).
*/
export const cssPath = (element, path = "") =>
((tag, nth) =>
tag
? cssPath(
@loucyx
loucyx / design-mode.js
Last active April 18, 2024 23:40
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 April 18, 2024 23:39
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 April 18, 2024 23:29
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 April 18, 2024 22:42
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.