Skip to content

Instantly share code, notes, and snippets.

View Martin-Pitt's full-sized avatar

Martin "Nexii" Pitt Martin-Pitt

View GitHub Profile
@Martin-Pitt
Martin-Pitt / interpolation.js
Created February 15, 2024 01:16
Rescale Interpolation
/*
More interesting interpolation functions to make life easier.
Rescale is a function which can interpolate a value between two different ranges.
Say you have a number which represents the position of a slider.
The slider has a start and end as well.
You want the slider to control a box between two locations.
So you could do the following:
@Martin-Pitt
Martin-Pitt / capture.mjs
Created October 29, 2023 11:59
Codepen screen recording
import { promises as fs } from 'fs';
import path from 'path';
import puppeteer from 'puppeteer';
import { PuppeteerScreenRecorder } from 'puppeteer-screen-recorder';
const viewport = {
width: 512,
height: 512,
deviceScaleFactor: 1,
// isMobile: true,
@Martin-Pitt
Martin-Pitt / render-bestagons.js
Created July 21, 2023 19:24
How to render clip-path hexagons (bestagons), this function creates the clip-path polygon function values for you, with vmax so it always acts like background cover algorithm
const RowStep = 14.39
const ColumnStep = RowStep * 5/6; // 37.5;
const HexMax = ColumnStep * 4/3;
const HexMin = ColumnStep * 2/3;
const Rows = Math.ceil(100 / RowStep);
const Columns = Math.ceil(100 / ColumnStep);
function renderBestagons(t = 1) {
let polygons = [];
let r = Rows;
module.exports = {
config: {
fontSize: 16,
fontFamily: '"Fira Code", Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
cursorColor: 'hsla(215, 100%, 90%, 1)',
cursorShape: 'BEAM',
foregroundColor: 'white',
backgroundColor: 'hsla(0, 0%, 0%, 0)',
borderColor: 'hsl(215, 20%, 20%)',
css: `
@Martin-Pitt
Martin-Pitt / pan-zoom-touch-and-trackpad.js
Last active December 22, 2023 02:16
Panning and Pinch-Zoom gesture handler for both touchscreens and trackpads; Works really well on a MacBook trackpad
// Target state
var tx = 0;
var ty = 0;
var scale = 1;
function visualiseTargetState() {
box.style.transform = `translate(${tx}px, ${ty}px) scale(${scale})`;
}
Room&
Status
Event starts within 10m -> Booked
Free
Use now -> In Use
Booked
Check in -> In Use
10m grace period -> Free
Clients
List*
Client -> Detail
Add -> New Client
Detail
Unchanged*
Blur or close -> List
Edit a field -> Edited Details
Delete and confirm -> List
Edited Details
@Martin-Pitt
Martin-Pitt / refresh-icons.sh
Created July 29, 2018 12:27
Converts an icon.ai (yup, Adobe Illustrator) file into a macOS icon.icns file
#!/bin/bash
mkdir icon.iconset
qlmanage -t -s 1024 -o . icon.ai
mv icon.ai.png icon.png
convert icon.png -gravity center -background white -extent 1024x1024 -alpha Set -colorspace sRGB -define png:format=png32 icon.png
sips -z 16 16 icon.png --out icon.iconset/icon_16x16.png
sips -z 32 32 icon.png --out icon.iconset/icon_16x16@2x.png
sips -z 32 32 icon.png --out icon.iconset/icon_32x32.png
sips -z 64 64 icon.png --out icon.iconset/icon_32x32@2x.png
const EventEmitter = require('events');
const electron = require('electron');
const address = require('address');
const Netmask = require('netmask').Netmask;
const http = require('http');
const firstOpenPort = require('first-open-port');
const got = require('got');
const Polo = require('polo');
@Martin-Pitt
Martin-Pitt / concentric-styling-order.md
Last active December 10, 2020 14:44
CSS Concentric Styling Order
{
	/* Where the box is placed */
	position: ;
	z-index: ;
	float: ;
	place-self: ;
	justify-self: ;
	align-self: ;
	vertical-align: ;