Skip to content

Instantly share code, notes, and snippets.

View iyobo's full-sized avatar
🦶
This is Github!

Iyobo Eki iyobo

🦶
This is Github!
View GitHub Profile
@iyobo
iyobo / PixiViewportPinch.tsx
Last active July 12, 2021 09:53
A PixiViewport plugin: Better Scroll/Zoom Behavior on trackpads with two-finger scoll and zoom.
import {Plugin, Viewport} from 'pixi-viewport';
import {DisplayObject} from 'pixi.js';
type Options = {
moveSpeed: number;
moveReverse: boolean;
zoomSpeed: number;
zoomReverse: boolean;
limitToObjectBounds?: DisplayObject;
limitToObjectBoundsBy?: number;
@iyobo
iyobo / hijackConsoleLog.js
Last active February 7, 2019 05:23
Hijacks your normal boring NodeJS console.log and gives it powers.
export const initLogger = ()=>{
['log', 'warn', 'error'].forEach((methodName) => {
const originalMethod = console[methodName];
console[methodName] = (...args) => {
let initiator = 'unknown place';
const timestamp = new Date().toISOString();
try {
throw new Error();
} catch (e) {
@iyobo
iyobo / flatten.js
Last active January 18, 2018 01:13
/**
* Takes an array or a single number and flattens it into a result array.
*
* @param input: Array|any
* @param resultArray: Array|null - optional. array into which all inputs get flattened into. Uses an empty array if none provided.
*/
const flatten = function (input, resultArray = []) {
if (!Array.isArray(resultArray))
throw new Error('ResultArray must be an array')
@iyobo
iyobo / convertToFormdata.js
Created January 14, 2018 02:17
Sadly most Ajax libraries (e.g axios) do not support automatic JS object to formData conversion. This is necessary for when you need to submit a form with a file, for example.
/**
* Created by iyobo on 2017-04-25.
*/
function appendRecursively(formData, collection, parentkey, parentIsArray) {
//console.log(...arguments)
for (let k in collection) {
const val = collection[k];
if (val === undefined) continue;