Skip to content

Instantly share code, notes, and snippets.

// Old code
#[account]
pub struct FooAccount {
foo_num: u128,
}
// New code
#[account]
pub struct FooAccount {
foo_num: u128,
import { Connection } from "@solana/web3.js";
import SolanaNetworkHealth from "types/enums/SolanaNetworkHealth";
import getRecentAverageTps from "utils/solana/health/getRecentAverageTps";
const SOLANA_SLOW_TPS_CUTOFF = 1_250;
const SOLANA_DOWN_TPS_CUTOFF = 500;
export default async function getSolanaNetworkHealth(
connection: Connection,
minutesLookback: number,
import { Connection } from "@solana/web3.js";
import { Maybe } from "types/UtilityTypes";
import arraySum from "utils/array/arraySum";
import sleepMs from "utils/sleepMs";
async function getRecentPerformanceSamples(
connection: Connection,
minutesLookback: number
) {
const recentPerfSamples = await connection.getRecentPerformanceSamples();
import {
Connection,
ParsedInstruction,
ParsedTransactionWithMeta,
PartiallyDecodedInstruction,
PublicKey,
} from "@solana/web3.js";
import { Maybe } from "formfn-shared/dist/types/UtilityTypes";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { ArweaveSigner, createData } from "arbundles";
import axios from "axios";
import dotenv from "dotenv";
dotenv.config();
const sendToBundler = async () => {
const jwk = JSON.parse(process.env.KEY);
const signer = new ArweaveSigner(jwk);
const item = createData("hello", signer);
await item.sign(signer);
import Arweave from "arweave";
import dotenv from "dotenv";
dotenv.config();
const arweave = Arweave.init({
host: "arweave.net",
port: 443,
protocol: "https",
timeout: 20000, // Network request timeouts in milliseconds
logging: false, // Disable network request logging
@keyframes blink {
0% {
opacity: 1;
}
49% {
opacity: 1;
}
50% {
const NAMES = ["katie", "adam", "jefra"];
function Pill(): JSX.Element {
const [name, setName] = useState(NAMES[0]);
const nameIndexRef = useRef(0);
// 1. Delete name
// 2. When name length is 0, increment nameIndex and start adding new name
// 3. When new name is finished, go back to step 1
useEffect(() => {
extends Node2D
### Export variables
export var g_copies_of_each: int = 2
# y measured from bottom of sprites, so characters all line up
export var g_min_y: int = 860
export var g_max_y: int = 860
export var g_min_spawn_wait_ms = 1000
export var g_max_spawn_wait_ms = 2000
export var g_path: String = ""
#include "lib/error_functions.h"
#include "sockets/unix_socket.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
struct sockaddr_un addr;