Skip to content

Instantly share code, notes, and snippets.

View bertrandg's full-sized avatar
:octocat:
 

bertrandg bertrandg

:octocat:
 
  • Lyon, FRANCE
View GitHub Profile
@tonytonyjan
tonytonyjan / copyExif.js
Last active June 26, 2024 14:41
copy EXIF from one JPEG blob to another and return a new JPEG blob.
// Copyright (c) 2019 Weihang Jian <tonytonyjan@gmail.com>
export default async (src, dest) => {
const exif = await retrieveExif(src);
return new Blob([dest.slice(0, 2), exif, dest.slice(2)], {
type: "image/jpeg"
});
};
export const SOS = 0xffda,
@drewdaemon
drewdaemon / ThumbnailGenerator.js
Last active May 13, 2022 12:58
Front end JS for generating image thumbnails from base64-encoded images.
function ThumbnailGenerator() {
this.resizeCanvas = document.createElement('canvas');
this.generate = function (imgSrc, thumbDims, compression) {
[this.resizeCanvas.width, this.resizeCanvas.height] = [thumbDims.x, thumbDims.y];
const ctx = this.resizeCanvas.getContext("2d");
const tmp = new Image();
const ret = new Promise(resolve => {
@manekinekko
manekinekko / binary-plist-parser.service.ts
Last active October 21, 2022 09:40
Apple's Binary Property List (bplist) parser in #JavaScript for the browser.
// const Buffer = require('buffer/').Buffer;
import { Injectable } from '@angular/core';
// Ported to browser from https://githuBuffer.com/joeferner/node-bplist-parser/blob/master/bplistParser.js
// Inspired by http://code.google.com/p/plist/source/browse/trunk/src/com/dd/plist/BinaryPropertyListParser.java
const bigInt = require('big-integer');
const Buffer = require('bops');
export const maxObjectSize = 100 * 1000 * 1000; // 100Meg
export const maxObjectCount = 32768;
@chrisveness
chrisveness / crypto-aes-gcm.js
Last active May 30, 2024 17:09
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
@revolunet
revolunet / create-wav-from-buffer.js
Last active January 29, 2022 14:01
web audio + wav buffering
/*
Goal : instantly play any wav source without download the file and without <audio/>
Idea is to use the fetch streaming API and pass raw data to web audio
My use case is playng a wav file
following http://stackoverflow.com/questions/38589614/webaudio-streaming-with-fetch-domexception-unable-to-decode-audio-data/38593356#38593356
@ghaiklor
ghaiklor / node-event-loop-demo.js
Created March 25, 2016 18:44
This example shows how you can block event loop in NodeJS
'use strict';
// The purpose of this example is to show
// how you can block the event loop with JavaScript.
// There is 3 routes
// / respond with Hello, World text
// /block uses JavaScript while for 5 seconds
// /non-block uses setTimeout for 5 seconds
// Do the following
@btroncone
btroncone / rxjs_operators_by_example.md
Last active June 15, 2024 07:17
RxJS 5 Operators By Example
@btroncone
btroncone / ngrxintro.md
Last active June 26, 2024 08:27
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@deiu
deiu / webcryptoapi.html
Last active June 27, 2024 07:44
Web Crypto API example: RSA keygen & export & import & sign & verify & encrypt & decrypt
<!-- MIT License -->
<html>
<head>
<script>
function generateKey(alg, scope) {
return new Promise(function(resolve) {
var genkey = crypto.subtle.generateKey(alg, true, scope)
genkey.then(function (pair) {
resolve(pair)
})
@paulirish
paulirish / readme.md
Last active April 2, 2024 20:18
resolving the proper location and line number through a console.log wrapper

console.log wrap resolving for your wrapped console logs

I've heard this before:

What I really get frustrated by is that I cannot wrap console.* and preserve line numbers

We enabled this in Chrome DevTools via blackboxing a bit ago.

If you blackbox the script file the contains the console log wrapper, the script location shown in the console will be corrected to the original source file and line number. Click, and the full source is looking longingly into your eyes.