Skip to content

Instantly share code, notes, and snippets.

View javve's full-sized avatar

Jonny Strömberg javve

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
}
@dvcrn
dvcrn / index.ts
Last active June 15, 2024 23:34
get metadata from metaplex
// EDIT: It's now much easier to get metadata from metaplex using the js package.
// Check the new gist here: https://gist.github.com/dvcrn/a1b0ff0a0b4b3ab02aff44bc84ac4522
// I didn't want to edit this gist because a lot of people found it helpful to see how to manually decode a account
import * as web3 from "@solana/web3.js";
import * as metadata from "./metadata"; // see metadata.ts
const tokenAddress = new web3.PublicKey(
"CxkKDaBvtHqg8aHBVY8E4YYBsCfJkJVsTAEdTo5k4SEw"
);
@mburakerman
mburakerman / package.json
Last active September 26, 2022 17:32
Webpack 4 config.js (SCSS to CSS and Babel) 👌 The Simplest Usage 👌
{
"name": "webpack-sass",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
@trusktr
trusktr / circle.js
Created November 2, 2016 21:00
Draw a circle (pixel algorithm)
//First attempt: O(r^2)
function drawCircle(cx, cy, r) {
var dim = 100
for (let i = -r; i<=r; i+=1) {
for (let j = -r; j<=r; j+=1) {
if (
Math.round(Math.sqrt(i*i + j*j)) === r