Skip to content

Instantly share code, notes, and snippets.

View codebender828's full-sized avatar
⚡️
Writing history

Jonathan Bakebwa codebender828

⚡️
Writing history
View GitHub Profile
@codebender828
codebender828 / 3.1.interoperability-interface.ts
Created September 3, 2024 02:41
Binance DD Code Snippets
// Creates Instruction layout for syncing state
function createInstructionData(index: number) {
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
const data = Buffer.alloc(dataLayout.span);
dataLayout.encode({ instruction: index }, data);
return data;
}
// Creates synchronize state instruction
function createSynchronizeProgramInstruction(source: PublicKey, target: PublicKey) {
@codebender828
codebender828 / execute_airdrop.ts
Last active April 24, 2024 16:55
Airdrop Script
async function executeAirdropTransaction() {
const connectionManager = await createConnection("mainnet-beta");
// Generate Transactions
// const instructions: TransactionInstruction[] = [];
// const transactions: Transaction[] = [];
const airdropTransactionEntries = Object.values(airdropTransactionsLogs);
const lastSuccessfulIndex = airdropTransactionEntries.findLastIndex(
(value) => !value.signature
@codebender828
codebender828 / vue-jsx.tsx
Last active September 20, 2022 18:38
Panda TSX Vue
import { DOMElements } from "@chakra-ui/vue-system"
import { computed, defineComponent } from "vue"
function cx(...args: any[]) {
return args.filter(Boolean).join(" ")
}
function splitProps(props: any) {
const styleProps = {}
const elementProps = {}
@codebender828
codebender828 / signTransaction.ts
Last active May 30, 2022 10:09
Sign Solana transaction from back end and send to chain
import { Transaction, Connection, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("devnet"));
// Get the wallet object from your wallet provider
const wallet = useWallet()
export async function signTransaction(transaction) {
// 1. Get transaction form back end and construct buffer form it.
const serializedTransaction = Buffer.from(transaction, "base64");
@codebender828
codebender828 / index.html
Created March 2, 2022 09:13
Stacked avatars SCSS
<div class="flex flex-col justify-center items-center">
<div class="wrapper flex mb-3">
<a href="#" target="__blank" class="avatar bg-green-100 w-12 h-12 shadow-lg"><img src="https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1100&q=80" alt="avatar1" class="image">
</a>
<a href="#" target="__blank" class="avatar bg-green-100 w-12 h-12 shadow-lg"><img src="https://images.unsplash.com/photo-1544005313-94ddf0286df2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60" alt="avatar2" class="image">
</a>
<a href="#" target="__blank" class="avatar bg-green-100 w-12 h-12 shadow-lg"><img src="https://images.unsplash.com/photo-1527980965255-d3b416303d12?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1100&q=80" alt="avatar3" class="image">
</a>
<a href="#" target="__blank" class="avatar bg-green-100 w-12 h-12 shadow-lg"><img src="https://images.unsplash.com/photo-1540746354979-c2ecadbc01d6
@codebender828
codebender828 / question_1.sol
Last active November 15, 2021 05:40
Solidity Questions
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/*
INSTRUCTIONS FOR THIS TEST
==========================
1. Deploy Store
2. Deposit 1 ETH each from Account 1 (Alice) and Account 2 (Bob) into Store
3. Deploy `Consumer` with address of `Store`
4. Call Consumer._withdraw sending 1 ETH (using Account 3 (Eve)).
@codebender828
codebender828 / 📊 Weekly development breakdown
Last active November 29, 2021 03:01
Weekly codebending breakdown
TypeScript 13 hrs 39 mins ████████████████▓░░░ 69.0%
Solidity 2 hrs 11 mins █████░░░░░░░░░░░░░░░ 11.1%
Vue.js 2 hrs 6 mins █████░░░░░░░░░░░░░░░ 10.7%
JSON 1 hr 8 mins ████░░░░░░░░░░░░░░░░ 5.8%
@codebender828
codebender828 / .zprofile
Last active August 23, 2021 05:14
My favourite Bash Functions and Aliases
# This script will look for all the files inside the `~/.profiles.d/` directory and require them in a new terminal
# Source all files in .profile.d
# ============================
for file in ~/.profile.d/*
do
source $file
done
@codebender828
codebender828 / machine.js
Last active July 2, 2021 10:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@codebender828
codebender828 / name-me.js
Created May 28, 2020 03:28
What do you name this function? It transforms an array of objects into an object with `values` and an `allKeys` array.
// So I'm struggling to name this function so I called it `indexArrayBy`
// but it's really doing more. Here's a link to it's demo:
// Demo: https://playcode.io/612180/
/**
* Transforms an array of objects into an object containing the values
* indexed by a unique property on each object, e.g. id and
* an array containing all the keys (So you get the keys).
*
* @param {Array<Object>} array Array of objects