Skip to content

Instantly share code, notes, and snippets.

View CezaryDanielNowak's full-sized avatar

Cezary Nowak CezaryDanielNowak

  • Testucan
  • Warsaw, Poland
View GitHub Profile
const generatePseudoRandom = (from, to) => parseInt(Math.random() * to) + from;
const ids = [];
let i = 0;
let lastCollision = 0;
while (i < 20) { // up to 20 collisions
const newId = generatePseudoRandom(1, 999999999);
if (ids.includes(newId)) {
console.error(`Collision detected after ${ids.length + 1 - lastCollision} IDs`);
const fs = require('fs');
const process = require('process');
const componentsPath = __dirname + '/components/';
fs.readdirSync(componentsPath).forEach((componentName) => {
console.log(componentName);
try {
// Enter component dir
let componentPath = componentsPath + componentName;
// ==UserScript==
// @name ZGN kalkulator
// @namespace ZGN
// @version 0.1
// @description try to take over the world!
// @author You
// @match */seizbil/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=zgnpragapld.pl
// @grant none
// @run-at document-end

LINUX HELPERS for HP T630 Terminal

In my case Linux Mint Xfce

Don't create SWAP drive. Create SWAP file instead and save your SSD.

# Check current swap file/partition
swapon -s

# create an big empty 10GB file (or whatever size you like)
dd if=/dev/zero of=/swapfile bs=1M count=10240
/**
* How to use:
* In the render function, include
*
* window.whyRerender && window.whyRerender(this.props, this.state);
*/
window.whyRerender = (props, state) => {
if (window.whyRerender.prevProps) {
const propsDiff = Object.keys(props).map((propName) => {
// gets device orientation.
// possible values: "landscape" | "portrait" | "" (can't detect)
const getCSSDeviceOrientation = () => {
function mediaQuery(orientation) {
return `(orientation: ${orientation})`;
}
const orientations = ['landscape', 'portrait'];
for (let orientation of orientations) {
@CezaryDanielNowak
CezaryDanielNowak / FaceDetector polyfill with jeelizFaceFilter.js
Created January 26, 2023 11:47
I'm getting an error: ERROR in ContextFF: WebGL1 and 2 are not enabled "GL_INCOMPATIBLE". But I might want to get back to this code in the future.
class _FaceDetector {
initPerformed = false;
loadPerformed = false;
constructor() {
const canvas = document.createElement('canvas');
this.canvas = canvas;
this.ctx = canvas.getContext('2d');
canvas.style.visibility = 'hidden';
@CezaryDanielNowak
CezaryDanielNowak / isBarcodeDetectorWorking
Created January 10, 2023 13:41
/** * BarcodeDetector has an "Experimental" status. It sometimes doesn't work for no reason. * * @param {string} barcodeType only qr_code and pdf417 are supported * @return {boolean} (async) If BarcodeDetector works or not */
/**
* BarcodeDetector has an "Experimental" status. It sometimes doesn't work for no reason.
*
* @param {string} barcodeType only qr_code and pdf417 are supported
* @return {boolean} (async) If BarcodeDetector works or not
*/
const isBarcodeDetectorWorking = (barcodeType) => {
return new Promise((resolve, reject) => {
if (typeof BarcodeDetector === 'undefined') return reject('UNSUPPORTED');
<?php
/*
Place this file in writable directory. Each incoming request will be saved as a file.
Sample file name:
callback_POST_08-17-2022 13.42.05.780400.txt
*/
$now = DateTime::createFromFormat('U.u', microtime(true));
$file_name = 'callback_' . $_SERVER['REQUEST_METHOD'] . '_' . $now->format("m-d-Y H.i.s.u").'.txt';
- Why subscriptions of apps purchased in App Store can be cancelled only in "Music"?
- Why navigating between maximized window and non-maximized windows is so hard?
- Why Finder can't be maximized?
- Why file paths are hidden?
- Why "open file"/"save file" dialog suck so much?
- Why transfer speed is hidden when moving file between location A and B ?