Skip to content

Instantly share code, notes, and snippets.

View akinnee's full-sized avatar
:shipit:
Shipping it

Alex Kinnee akinnee

:shipit:
Shipping it
View GitHub Profile
var obj = {
konamiCodeActive: false,
konamiCodeListener: function() {
if ( window.addEventListener ) {
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
window.addEventListener("keydown", function(e){
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 && !obj.konamiCodeActive) {
obj.konamiCodeActive = true;
@akinnee
akinnee / getDistance.ts
Last active May 15, 2022 00:02
typescript distance between two points
type Vector2 = {
x: number;
y: number;
};
export const getDistance = (p1: Vector2, p2: Vector2) => {
const { x: x1, y: y1 } = p1;
const { x: x2, y: y2 } = p2;
const y = x2 - x1;
const x = y2 - y1;