Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View CezaryDanielNowak's full-sized avatar

Cezary Nowak CezaryDanielNowak

  • Testucan
  • Warsaw, Poland
View GitHub Profile
/*
* Some JS objects like InputDeviceInfo or GeolocationCoordinates are impossible to clone easly.
* `Object.keys(obj)` returns `{}`
* `JSON.stringify(obj)` returns `{}`
*
* with following functions you're able to clone object properties to the simple object.
*/
function cloneGeolocationCoordinates(instance) {
return Object.keys(instance.constructor.prototype).reduce((acc, key) => {
// Extra filters for https://github.com/kig/canvasfilters.git
Filters.scaleUp = function (imageData, scale = 2) {
const sourceWidth = imageData.width;
const sourceHeight = imageData.height;
const targetWidth = parseInt(sourceWidth * scale, 10);
const targetHeight = parseInt(sourceHeight * scale, 10);
/*
* This code helps with logging image processed in the worker.
*
* Simple visual explanation for image transformation.
*/
// WORKER:
postMessage({
imageData,
});
const initialNumberOfPairs = 1;
let adultPairsNumber = 0;
let youngPairsNumber = initialNumberOfPairs;
for (let i = 1; i <= 12; ++i) {
const prevAdultPairsNumber = adultPairsNumber;
adultPairsNumber = adultPairsNumber + youngPairsNumber;
youngPairsNumber = prevAdultPairsNumber;
/**
* Transfer localStorage easly with chrome console.
* Paste this into web console of source page, then paste function's result to destination console.
**/
(function() {
let result = 'localStorage.clear();\n';
Object.keys(localStorage).forEach((key) => {
result += `localStorage["${key}"] = ${JSON.stringify(localStorage[key])};\n`
});
@CezaryDanielNowak
CezaryDanielNowak / blob-related-memory-leaks-sensor.js
Last active June 29, 2022 16:23
This code helps with finding blobs that weren't cleared with revokeObjectURL causing memory leak.
// ==UserScript==
// @name Slack: more space for channels
// @version 0.1
// @description try to take over the world!
// @author Cezary Nowak
// @match https://app.slack.com/client/*
// @icon https://www.google.com/s2/favicons?domain=slack.com
// @grant none
// ==/UserScript==
// ==UserScript==
// @name Slack: remove huddle
// @version 0.1
// @description try to take over the world!
// @author Cezary Nowak
// @match https://app.slack.com/client/*
// @icon https://www.google.com/s2/favicons?domain=slack.com
// @grant none
// ==/UserScript==
#define X_SLAVE_ADDRESS 0
#define Y_SLAVE_ADDRESS 2
#define Z_SLAVE_ADDRESS 1
#define E0_SLAVE_ADDRESS 3
====
https://github.com/MarlinFirmware/Marlin/blob/bugfix-2.0.x/Marlin/src/core/boards.h
$$('td[colspan="6"]').forEach((el) => el.parentNode.remove())