Skip to content

Instantly share code, notes, and snippets.

View mattiaz9's full-sized avatar

Mattia Dalzocchio mattiaz9

  • Italy
View GitHub Profile
@mattiaz9
mattiaz9 / blurhashDataURL.ts
Last active November 16, 2024 13:04
Convert blurhash to a base64 DataURL string (no canvas or node-canvas)
import { decode } from "blurhash"
export function blurHashToDataURL(hash: string | undefined): string | undefined {
if (!hash) return undefined
const pixels = decode(hash, 32, 32)
const dataURL = parsePixels(pixels, 32, 32)
return dataURL
}
@mattiaz9
mattiaz9 / amazon-paapi.d.ts
Last active September 22, 2021 07:33
Amazon PAAPI Typings
declare module "amazon-paapi" {
export type AmazonCommonParameters = {
/** Api access key */
AccessKey: string
/** Api secret key */
SecretKey: string
/** Partner ID (eg: yourtag-20) */
PartnerTag?: string
/**
* Marketplace url.
@mattiaz9
mattiaz9 / index.html
Created May 17, 2020 09:29
Fix URLs of a react app deployed on Swarm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/images/icon.png" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/images/icon-192.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script>
var path = window.location.pathname;
var bzzPattern = /\/bzz:\/([^/]+)/;
@mattiaz9
mattiaz9 / bootstrap.native.d.ts
Last active January 23, 2019 15:20
Typescript definition for bootstrap.native v-4
declare module "bootstrap.native/dist/bootstrap-native-v4" {
/** ALERT */
export class Alert {
constructor(element?: string | HTMLElement);
close(): void;
}
/** BUTTON */
export class Button {
constructor(element?: string | HTMLElement);