Skip to content

Instantly share code, notes, and snippets.

@Global()
@Module({
imports: [
TypeOrmModule.forFeature([UserRepository]),
],
providers: [CaslAbilityFactory, PermissionsGuard, AuthzService],
exports: [CaslAbilityFactory, PermissionsGuard],
})
export class AuthzModule {}
@Post()
@UseGuards(PermissionsGuard)
@CheckPermissions([PermissionAction.CREATE, "Invoice"]) // "Invoice" is the value in name column of objects table
async create(
// create invoice params
): Promise<InvoiceResponseDto> {
// create invoice logic
}
import { CustomDecorator, SetMetadata } from "@nestjs/common";
// action, object
export type RequiredPermission = [PermissionAction, PermissionObjectType]
export const PERMISSION_CHECKER_KEY = "permission_checker_params_key";
export const CheckPermissions = (...params: RequiredPermission[]): CustomDecorator<string> =>
SetMetadata(PERMISSION_CHECKER_KEY, params);
@dvcrn
dvcrn / index.ts
Last active February 22, 2025 05: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"
);
var web3 = require('@solana/web3.js');
var splToken = require('@solana/spl-token');
var metaplex = require('metaplex/metadatafull.js');
// 1. make a wallet
// 2. Airdrop
// 3. make a mint account
// 4. make a associated account
// 5. Mint to associated account
// -- Metadata
// 6. Create metadata account
@networkextension
networkextension / T2_sysctl.txt
Created August 31, 2021 02:57
T2_sysctl.txt
-bash-3.2# sysctl -a
user.cs_path: /usr/bin:/bin:/usr/sbin:/sbin
user.bc_base_max: 99
user.bc_dim_max: 2048
user.bc_scale_max: 99
user.bc_string_max: 1000
user.coll_weights_max: 2
user.expr_nest_max: 32
user.line_max: 2048
user.re_dup_max: 255
@MalteKiefer
MalteKiefer / fed.sh
Created August 20, 2021 13:35
fed.sh
#!/bin/bash
## update system
####
sudo dnf update -y
## repos
####
sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

Solana - NFT Tutorial

  • In this tutorial we will be going over how to create your own NFT Marketplace using React for the front end which will help you to create your own gallery, and using Rust for the back end to process transactions on the Solana Blockchain. More on the Solana CLI (Command Line Interface) and Developer Expierence here. Check out the Solana Blockchain source code to see what our marketplace will be built on top of!

Prerequisites

  • Disclaimer: It is useful to have some developer experience before this tutorial.
  • You should be exepcted to know Rust. It is a low-level systems programming language and can have a learning curve. Check out the SolHack Discord to join a rust study group!

Objectives

  1. How to Create your own NFT Marketplace
@benchow
benchow / mint_from_metaplex_master.sh
Last active July 7, 2022 17:37
How to use Metaplex to mint a lot of NFTs from a master edition
#!/bin/bash
########################
# Instructions
#
# Download Metaplex code
# - git clone [email protected]:metaplex-foundation/metaplex.git
#
# Edit webserver code to be able to mint NFT
# - In file .env, add your wallet address that will mint the NFTs to here => REACT_APP_STORE_OWNER_ADDRESS_ADDRESS=<Wallet Address>
@sandfox
sandfox / newline-stream-splitter.js
Created July 6, 2021 21:15
nodejs newline stream
const { Transform } = require("stream");
// Splits buffers on utf8 newline character
// If the maxLineLength is passed the current line is discarded and all further input is discarded until the next newline char is found
// TODO: emit errors on overlong lines?
class NewlineStreamSplitter extends Transform {
constructor(streamOpts, opts) {
super(streamOpts);
opts = opts || {};