Skip to content

Instantly share code, notes, and snippets.

View mauriciomassaia's full-sized avatar

Mauricio Massaia mauriciomassaia

View GitHub Profile
@mauriciomassaia
mauriciomassaia / vanilla-boilerplate-threejs-gsap.html
Last active August 30, 2022 11:34
Vanilla Boilerplate / threejs + gsap
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vanilla Boilerplate / threejs + gsap</title>
<style>
html,
body {
@mauriciomassaia
mauriciomassaia / node-proxy-server.js
Last active October 5, 2021 07:38
Local node proxy server for development
const http = require('http')
const https = require('https')
const PROXY_PORT = 8080
const onRequest = (clientReq, clientRes) => {
console.log(`onRequest: ${clientReq.url}`)
clientRes.setHeader('Access-Control-Allow-Origin', '*')
clientRes.setHeader('Access-Control-Request-Method', '*')
@mauriciomassaia
mauriciomassaia / SpritesheetAnimation.ts
Last active February 24, 2022 06:57
Spritesheet Animation class with Typescript and TexturePacker
import { SpritesheetData } from './interfaces'
// generate a spritesheet (png + json) using TexturePacker data file format JSON (Array)
export class SpritesheetAnimation {
canvas: HTMLCanvasElement
protected image = new Image()
protected ctx: CanvasRenderingContext2D
private playing = false
private frameIndex = 10
@mauriciomassaia
mauriciomassaia / example-render-html-template.ts
Last active May 17, 2022 00:12
Render HTML template and replace items
import { renderTemplate } from './html-utils.ts'
const tpl = `
<div class="item">
<img class="tick-icon" src="./images/icons/tick.png" />
<span>{text}</span>
</div>`
const el = renderTemplate(tpl, { text: 'Hello world' }) as HTMLDivElement
document.body.appendChild(el)
@mauriciomassaia
mauriciomassaia / Inject cacertpem into Tinify.md
Created June 5, 2024 05:13
Postinstall script to inject cacert.pem into Tinify dependency

When our team tried to use tinify into a AWS Lambda function using Typescript the file node_modules/tinify/lib/data/cacert.pem wasn't copied properly so the transpiled code could not find it and Tinify would fail.

Thanks to @shannonhochkins and his postinstall idea to inject the value of cacert.pem into Client.js.

How to setup this script

  1. Create a scripts/ folder on your project.
  2. Create a file called tinify-inject-cacertpem.js inside the scripts/ folder.