Skip to content

Instantly share code, notes, and snippets.

View nazreen's full-sized avatar

Nazreen nazreen

View GitHub Profile
@nazreen
nazreen / areObjectsSimilar.js
Created November 18, 2017 15:35
Javascript utility function to compare 2 objects.
function logDifference(arr1, arr2) {
let difference = arr1.filter(
x => arr2.indexOf(x) == -1)
.concat(arr2.filter(
x => arr1.indexOf(x) == -1)
);
if (difference.length < 1) return []; // if no difference return empty array
return difference;
@nazreen
nazreen / index.js
Created July 14, 2018 13:50
determine number of live promises by live politicians
const politicians = require('./politicians.json')
const promises = require('./promises.json') // live promises
const result = {
promisesWithLivePoliticians: {
total: 0
},
promisesWithOfflinePoliticians: {
total: 0
}
@nazreen
nazreen / 0.js
Created April 17, 2019 03:34
2019-04-16 process.on('unresolvedPromise')
// in index.js
...
async function handler(event, context) {
try {
return handlerService.call(event, context, { AWS })
} catch (e) {
if (process.env.NODE_ENV === 'local') throw e
throw JSON.stringify(e)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@nazreen
nazreen / layerzero.config.ts
Created December 5, 2024 11:01
USDEBT lz config
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { ExecutorOptionType } from '@layerzerolabs/lz-v2-utilities'
import type { OAppOmniGraphHardhat, OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'
// Note: Do not use address for EVM OmniPointHardhat contracts. Contracts are loaded using hardhat-deploy.
// If you do use an address, ensure artifacts exists.
const sepoliaContract: OmniPointHardhat = {
eid: EndpointId.SEPOLIA_V2_TESTNET,
contractName: 'MyOFTAdapter',
@nazreen
nazreen / README.md
Last active April 9, 2025 12:48
How to upgrade your Solana OFT program (previous version of Solana OFT)

This document details how to upgrade your Solana OFT program.

Notes

  • program ID == program address. The terms can be used interchangeably.
  • you will need the Squads Vault address which is the current OFT Program's Update Authority

Instructions

Prepare the updated code

@nazreen
nazreen / index.ts
Last active March 6, 2025 00:40
find deployed programs
import { Connection, PublicKey } from '@solana/web3.js';
import { promises as fs } from 'fs';
import path from 'path';
import bs58 from 'bs58';
// --- Constants & Types ---
const RPC_URL = 'https://api.devnet.solana.com';
const CACHE_DIR = path.join(__dirname, 'cache');
const INSPECTED_FILE = path.join(CACHE_DIR, 'instructionsInspected.json');
const LAST_CHECKED_FILE = path.join(CACHE_DIR, 'lastChecked.json');