Skip to content

Instantly share code, notes, and snippets.

View marcio199226's full-sized avatar
🎯
Focusing

oskar marcio199226

🎯
Focusing
View GitHub Profile
@send2moran
send2moran / debounceMutationObserver.js
Created April 26, 2020 16:03
debounce MutationObserver
const debounce = (func, delay) => {
let debounceTimer;
return function() {
const context = this;
const args = arguments;
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => func.apply(context, args), delay);
};
};
let summery = { addded: [], removed: [] };
@angeal185
angeal185 / chacha20-poly1305.js
Created May 6, 2019 13:05
nodejs chacha20-poly1305 encrypt decrypt example
const crypto = require('crypto');
let key = crypto.randomBytes(32),
text = 'test';
function encChaPoly(key, data, cb){
try {
let iv = crypto.randomBytes(12),
cipher = crypto.createCipheriv('chacha20-poly1305', key, iv, {
authTagLength: 16
@sechel
sechel / @ BroadcastChannel Polyfill.md
Created September 13, 2018 15:47
BroadcastChannel Polyfill

BroadcastChannel Polyfill

BroadcastChannel is a new communication API proposed in the HTML Standard but not yet widely implemented. It allows messages to be sent to all other BroadcastChannel instances sharing the same channel name within the same browsing context and origin.

var bc = new BroadcastChannel('name');

bc.postMessage(payload);
@pianosnake
pianosnake / bounding-box-from-lat-lng-zoom-img-size.js
Last active July 17, 2024 14:19
Get a bounding box from latitude, longitude, zoom level and image size. Useful for getting the bounding box of a static map generated with only those variables.
const EARTH_CIR_METERS = 40075016.686;
const degreesPerMeter = 360 / EARTH_CIR_METERS;
function toRadians(degrees) {
return degrees * Math.PI / 180;
};
function latLngToBounds(lat, lng, zoom, width, height){
const metersPerPixelEW = EARTH_CIR_METERS / Math.pow(2, zoom + 8);
const metersPerPixelNS = EARTH_CIR_METERS / Math.pow(2, zoom + 8) * Math.cos(toRadians(lat));

The default format of keys was changed in OpenSSL 1.0. From OpenSSL 1.0 change log:

Make PKCS#8 the default write format for private keys, replacing the traditional format. This form is standardised, more secure and doesn't include an implicit MD5 dependency. [Steve Henson]

Good explanations of the difference between the two formats: https://tls.mbed.org/kb/cryptography/asn1-key-structures-in-der-and-pem

Converting RSA private key:

@nesimtunc
nesimtunc / ImageController.js
Last active May 8, 2024 07:23
Minio Server - NodeJS - File Upload & Photo Showing Example
const formidable = require('formidable');
const fs = require('fs');
var Minio = require('minio');
let minioClient = new Minio.Client({
endPoint: config.MINIO.ENDPOINT,
port: config.MINIO.PORT,
accessKey: config.MINIO.ACCESS_KEY,