Skip to content

Instantly share code, notes, and snippets.

@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"
);
@kprimice
kprimice / multiplePSTContract.ts
Last active July 18, 2021 02:48
This contract includes: PST (default token), multiple NFTs handling, NFT profit sharing (royalties), multiple editions NFTs (no.), third party approval, batch transfers, multiple contract owners (two levels) and foreignInvoke
declare function ContractAssert(cond: any, e: string): asserts cond;
declare function ContractError(e: string): void;
import { SmartWeaveGlobal } from "smartweave/lib/smartweave-global";
declare const SmartWeave: SmartWeaveGlobal;
const PST = "PTY"
const UNITY = 1e12
const ERR_404TOKENID = "No token found: Invalid tokenId"
const ERR_NOTOKENID = "No tokenId specified"
const ERR_NOQTY = "No qty specified"
@rupertlssmith
rupertlssmith / ElmPackageServer.md
Last active February 28, 2024 17:38
Elm Package Server

Eco - An Alternate Elm Package Server

Eco is an alternative package management system for Elm. The name can stand for "Elm Compiler Offline".

The idea is to have a more configurable package management system for Elm, that allows for sharing private packages.

The main use case for this is intended to be within organizations, where a software developer or team can publish a private package that applications, or other private packages, in that organization can consume. This will support transitive dependency resolution in the same way that public Elm packages do.

The main repository and source of truth will be the existing package.elm-lang.org site.

@xarvh
xarvh / README.md
Last active December 18, 2019 09:44
Proposal: transpile Elm to GLSL

Proposal: transpiling Elm code to GLSL

The main problem that this proposal wants to solve is the inability to reuse code when writing shaders: if I declare a function in a shader, the only way I can reuse it in a different shader is to cut and paste the function code.

This prevents us from writing generic code that can be reused and shared in libraries.

@pinkhominid
pinkhominid / index.js
Created September 24, 2019 10:15
Upload a file with node-fetch and form-data
const fs = require('fs');
const fetch = require('node-fetch');
const FormData = require('form-data');
const filePath = `path/to/file.ext`;
const form = new FormData();
const stats = fs.statSync(filePath);
const fileSizeInBytes = stats.size;
const fileStream = fs.createReadStream(filePath);
form.append('field-name', fileStream, { knownLength: fileSizeInBytes });
@nicolasdao
nicolasdao / webpack.md
Last active July 28, 2023 19:15
Basic damn Webpack config for simple transpilation ES6 to ES5

Install

npm install -D acorn babel-loader @babel/core @babel/preset-env babel-polyfill webpack webpack-cli uglifyjs-webpack-plugin --save-dev

webpack-cli and acorn are dependencies that you, unfortunately, have to install if you want to run this god damn thing without any obscure warnings or errors.

Build

Configure Webpack

@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
@JoelQ
JoelQ / RandomToTask.elm
Last active September 30, 2021 07:16
Turn an Elm random generator into task, allowing it to be chained with other side effects.
-- 0.19
randomToTask : Generator a -> Task x a
randomToTask generator =
Time.now
|> Task.map (Tuple.first << Random.step generator << Random.initialSeed << Time.posixToMillis)
-- 0.18
@jaysonsantos
jaysonsantos / main.rs
Last active April 29, 2024 15:16
rust ring example
extern crate ring;
use ring::aead::*;
use ring::pbkdf2::*;
use ring::rand::SystemRandom;
fn main() {
// The password will be used to generate a key
let password = b"nice password";
@Avaq
Avaq / ramda-sanctuary.md
Last active March 1, 2019 00:26
Comprehensive Ramda to Sanctuary list
Ramda Sanctuary
add(a, b) add(b, a)
addIndex(f) ``
adjust(f, i, xs) ``
all(f, xs) ``
allPass(fs, x) allPass(fs, x)
always(x) K(x)
and(a, b) and(a, b)
any(f, x) ``