Skip to content

Instantly share code, notes, and snippets.

View 0xBigBoss's full-sized avatar
🤠

Big Boss 0xBigBoss

🤠
View GitHub Profile
@0xBigBoss
0xBigBoss / _.py
Created October 8, 2024 22:22
Attention and Differential Attention functions.
def Attention(X, W_q, W_k, W_v):
Q = X @ W_q
K = X @ W_k
V = X @ W_v
# Q, K, V: [b, n, d]
s = 1 / sqrt(d)
A = Q @ K.transpose(−1,−2) ∗ s
return softmax(A) @ V
@0xBigBoss
0xBigBoss / flatten-source-files.sh
Created August 24, 2024 14:07
Analyze the current directory c++ source files and copy them based on their layout into a new folder. Great for uploading as contexts for projects that do not have a great API for managing files.
#!/bin/bash
# create a prefix based on the parent git repo directory name
prefix=$(basename "$(git rev-parse --show-toplevel)")
# Create a directory to store the flattened files
outdir="/tmp/flattened"
mkdir -p "$outdir"
# Find c++ files, rename them, and copy to flattened directory
@0xBigBoss
0xBigBoss / send-app-activity-feed.md
Last active May 25, 2024 03:17
Designing Send App Activity Feed - Unified Activity Table

Unified Activity Table

A more generic table that can be used to capture all events, onchain and offchain, for the user. For example, there may be a user referral tracked inside the database that should show up in the activity table. The table should be generic enough to be used for any event that is emitted by the send account contract or to represent any other event that a user may want to track and see in their activity feed.

The view will be adapted so that it can be added to the activity table.

create table activity (
    id serial primary key,
    event_name text not null, -- the name of the event usually the integration or source table name
@0xBigBoss
0xBigBoss / get-historical-token-price.ts
Created March 26, 2024 02:39
Returns historical prices of POKT in the past n days and the average for that period
 import axios from 'axios';
import { poll } from 'ethers/lib/utils';
import moment from 'moment';
import Logger from '@loaders/logger';
import sleep from '@helpers/utils/sleep';
import { getRandomArbitrary } from '@helpers/utils/get-random-arbitrary';
const pricesPerDayUsd: { [day: string]: number } = {};
let historicalPricesLoaded = false;
SELECT
grantee,
specific_schema,
routine_name,
privilege_type
FROM
information_schema.routine_privileges
WHERE
specific_schema NOT IN ('pg_catalog', 'information_schema');
@0xBigBoss
0xBigBoss / erc-4337-deposit-to-entrypoint.ts
Created December 29, 2023 20:29
ERC-4337 Account abstraction sponsor a transactions by setting the deposit on the Entry Point
// sponsor the creation by setting the deposit on the Entry Point
const { request: depositRequest } = await baseMainnetClient.simulateContract({
address: entrypoint.address,
functionName: 'depositTo',
abi: iEntryPointABI,
args: [senderAddress],
account: dummyAccount,
value: parseEther('0.5'),
})
const depositHash = await walletClient.writeContract(depositRequest)
@0xBigBoss
0xBigBoss / webauthn-signature-verifier.ts
Created December 29, 2023 15:27
Verify a digital signature using ECDSA and Web Crypto API
export async function verifySignature({
authenticatorData,
clientDataJSON,
r,
s,
x,
y,
}: {
authenticatorData: string
clientDataJSON: string
@0xBigBoss
0xBigBoss / gh-org-contribs
Last active October 25, 2023 18:07
ZX script to fetch all contributors to an organization public repos.
#!/usr/bin/env zx
// -*- mode: js -*-
const orgName = process.argv[3];
if (!orgName) {
console.log(`Usage: gh-org-contribs ${chalk.bold("<org-name>")}`);
process.exit(1);
}
@0xBigBoss
0xBigBoss / docker_context_analyze.sh
Created October 13, 2023 03:30
Analyze a docker context and what files would be included in your docker image. Creates a directory at /tmp/docker-context.
printf 'FROM scratch\nCOPY . /' | DOCKER_BUILDKIT=1 docker build -f - -o /tmp/docker-context .
@0xBigBoss
0xBigBoss / upgrade.zx.md
Last active July 29, 2023 22:25
Pocket Network v1 Upgrade Feature e2e

Upgrade Feature e2e

You need to have zx installed before executing this file.

npm install -g zx
zx upgrade.zx.md

Ensure ACL Owner is imported