Skip to content

Instantly share code, notes, and snippets.

Martin "Nexii" Pitt Martin-Pitt

View GitHub Profile
Martin-Pitt / pan-zoom-touch-and-trackpad.js
Last active Dec 20, 2019
Panning and Pinch-Zoom gesture handler for both touchscreens and trackpads; Works really well on a MacBook trackpad
View pan-zoom-touch-and-trackpad.js
// Target state
var tx = 0;
var ty = 0;
var scale = 1;
function visualiseTargetState() { = `translate(${tx}px, ${ty}px) scale(${scale})`;
View SketchSystems.spec
Event starts within 10m -> Booked
Use now -> In Use
Check in -> In Use
10m grace period -> Free
View SketchSystems.spec
Client -> Detail
Add -> New Client
Blur or close -> List
Edit a field -> Edited Details
Delete and confirm -> List
Edited Details
Martin-Pitt /
Created Jul 29, 2018
Converts an (yup, Adobe Illustrator) file into a macOS icon.icns file
mkdir icon.iconset
qlmanage -t -s 1024 -o .
mv 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
View electron-to-electron.js
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');
	/* Where the box is placed */
	position: ;
	z-index: ;
	float: ;
	place-self: ;
	justify-self: ;
	align-self: ;
	vertical-align: ;
View genesis_public_key
View preventWindowBounce.js
/// Self-Contained JavaScript to prevent window scroll overflow bounce on iOS devices
/// Checks for whitelisted native scrolling via .scrollable class or if -webkit-overflow-scrolling is an inline-style
window.PreventWindowBounce = {
handleEvent: function EventListenerInterface (ev) { if(ev.type in this) this[ev.type](ev); },
bindEvents: function () {
document.addEventListener('touchstart', PreventWindowBounce);
document.addEventListener('touchmove', PreventWindowBounce);
/// The code works by checking whether the scroll area is against
Martin-Pitt / rescaling.js
Created Sep 7, 2017
A very simple but powerful primitive that lets you make awesome UI or 2D/3D movement very quickly
View rescaling.js
function rescale(from_min, from_max, to_min, to_max, from) {
return to_min + ((to_max-to_min) * ((from_min-from) / (from_min-from_max)));
rescale.clamped = function(fMin, fMax, tMin, tMax, f) {
f = this(fMin, fMax, tMin, tMax, f);
if(tMin < tMax) { if(f < tMin) return tMin; else if(f > tMax) return tMax; }
else { if(f < tMax) return tMax; else if(f > tMin) return tMin; }
return f;
Martin-Pitt /
Last active Dec 10, 2015 — forked from clhenrick/
updating data in a d3 histogram

updating data in a d3 histogram

You can’t perform that action at this time.