Skip to content

Instantly share code, notes, and snippets.

View fitsum's full-sized avatar
💭
npx fitsum

ፍፁም fitsum

💭
npx fitsum
View GitHub Profile
/*** The new CSS Reset - version 1.2.0 (last updated 23.7.2021) ***/
/* Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property */
*:where(:not(iframe, canvas, img, svg, video):not(svg *)) {
all: unset;
display: revert;
}
/* Preferred box-sizing value */
*,
/*
Web component code gen from Gemini Pro
Original code: https://codepen.io/cassidoo/pen/RNrqOOO
Related social media post: https://bsky.app/profile/did:plc:bhdap3w2bseikypfnjmaskzf/post/3m4pb4lz6ss24
*/
class RevealImage extends HTMLElement {
// --- Define default values ---
radius = 100;
bigRadius = 200;
@fitsum
fitsum / recorder.cjs
Created February 11, 2025 21:08 — forked from peterc/recorder.cjs
Record an HTML file to a MP4 video
// Open a supplied HTML file and record whatever's going on to an MP4.
//
// Usage: node recorder.cjs <path_to_html_file>
// Dependencies: npm install puppeteer fluent-ffmpeg
// (and yes, you need ffmpeg installed)
//
// It expects a <canvas> element to be on the page as it waits for
// that to load in first, but you can edit the code below if you
// don't want that.
//
@fitsum
fitsum / git-log-short.txt
Created December 8, 2024 21:17
minimal git log with hash, author, date, message
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
@fitsum
fitsum / leaflet-darkmode.md
Created August 21, 2024 22:04 — forked from BrendonKoz/leaflet-darkmode.md
Automatic Dark Mode for Leaflet.js
// Leaflet JS - note the *className* attribute
// [...]

L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
    className: 'map-tiles'
}).addTo(map);

// [...]
@fitsum
fitsum / ticker.js
Last active April 26, 2024 05:26
request animation frame
var now, dt,
rate = 0.5,
last = performance.now();
function frame() {
now = performance.now();
dt = (now - last) / 1000; // duration in seconds
if(dt >= rate){
console.log("bing")
last = now;
@fitsum
fitsum / dumb-console-animation.js
Last active April 26, 2024 05:25
dumb console animation
var angle = null,
step = 20,
rate = 90;
draw = () => {
if (!angle) {
angle = 0;
}
console.clear();
@fitsum
fitsum / mouse-trace.js
Created February 7, 2020 18:42
getting mousemove direction for custom cursor
//TODO: add cursor bg and rotate script. can't tell what's happening without visual
let lastCoords = [];
const handleDir = e => {
let xDiff, yDiff, currCoords = [e.x, e.y];
if ( lastCoords.length !== 0 ){
xDiff = currCoords[0] - lastCoords[0];
yDiff = currCoords[1] - lastCoords[1];
}
@fitsum
fitsum / three.html
Created December 27, 2020 21:55 — forked from nasser/three.html
a three.js boilerplate scene in a single 30 line self-contained html file
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reset-css@5.0.1/reset.min.css">
<script type="module">
import * as THREE from "https://cdn.jsdelivr.net/npm/three@0.124.0/build/three.module.js"
import { OrbitControls } from "https://cdn.jsdelivr.net/npm/three@0.124.0/examples/jsm/controls/OrbitControls.js"
var scene = new THREE.Scene()
var camera = new THREE.PerspectiveCamera(75)
camera.position.z = 4
@fitsum
fitsum / same-as-eval.js
Last active April 26, 2024 05:20
no more eval() I guess ...
(() => {return Function(`"use strict";return (${__f__})`)();}).call(null)()
// would normally do `eval(__f__)` where __f__ might be a stringified function
// name in an array