Skip to content

Instantly share code, notes, and snippets.

View 0xBigBoss's full-sized avatar
🤠

Big Boss 0xBigBoss

🤠
View GitHub Profile
@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 / 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)
SELECT
grantee,
specific_schema,
routine_name,
privilege_type
FROM
information_schema.routine_privileges
WHERE
specific_schema NOT IN ('pg_catalog', 'information_schema');
@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;
@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 / 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 / _.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

VS Code Extensions

Frontend

  • naumovs.color-highlight
  • bierner.color-info
  • pranaygp.vscode-css-peek
  • dbaeumer.vscode-eslint
  • ms-playwright.playwright
  • Orta.vscode-twoslash-queries
@0xBigBoss
0xBigBoss / Simple LLM.md
Last active October 27, 2024 02:06
A simple LLM and tokenizor for demonstrating KV Cache and inference using the transformer architecture(generating text).

Demo a Simple LLM

A simple LLM and tokenizor for demonstrating KV Cache and inference using the transformer architecture(generating text).

Need PyTorch installed.

$ python ./demo_llm.py
Demonstrating KV cache
@0xBigBoss
0xBigBoss / llama-suggest
Created November 10, 2024 19:01
Wrapper for llama-cli that generates example commands when given a user prompt.
#!/bin/bash
set -eo pipefail
user_input="$*"
if [[ -z "$user_input" ]]; then
user_input="beginner shell commands"
echo "Using default input: $user_input"
fi