This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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" | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |