Skip to content

Instantly share code, notes, and snippets.

View sambacha's full-sized avatar
:atom:

sam bacha sambacha

:atom:
View GitHub Profile
bun create @knip/config
bun add --dev --exact @biomejs/biome
npm install --save-dev --save-exact @biomejs/biome
npm init @knip/config
npm install -D knip typescript @types/node
npx knip
knip --fix
@startuml
skinparam sequenceArrowThickness 2
skinparam roundCorner 20
skinparam maxMessageSize 80
skinparam sequenceParticipant underline
skinparam backgroundColor #ffffff
title Block Proposal
autonumber
Category Scope Foreground Color Font Style Description
Visibility Modifiers storage.type.modifier.keyword.solidity #84f56293 Underline Public, memory, etc. modifiers
External Visibility storage.type.modifier.keyword.extendedscope.solidity #f56262 Underline External scope modifiers
Control Keywords keyword.control.solidity #fffffff5 Bold Keywords like emit, new, delete
Functions entity.name.function.solidity #fae674d7 Normal Function names
Transaction Variables (Inconclusive) variable.language.transaction.solidity #ffc570 Bold Underline Transaction-related variables
Transaction Variables (Security) variable.language.transaction.security.solidity #f56262 Bold Underline Secure transaction variables
Transaction Functions (Security) support.function.transaction.security.solidity #f56262 Bold Underline
@sambacha
sambacha / safe_wallet_origin_search.py
Created February 2, 2025 21:57
Find out Safe Wallet address Origin for Transaction
#!/usr/bin/env python3
import requests
import json
import os
# Replace
# <$SAFE_WALLET_ADDRESS>
# With your address
#
@sambacha
sambacha / LibResult.ts
Created January 18, 2025 12:47
TypeScript implementation of the Result monad pattern
// SPDX-License-Identifier: UPL-1.0 OR BSD-3
/**
* @file LibResult.ts
* @version 1.0.0
* @packageDocumentation
*
* A TypeScript implementation of the Result monad pattern, providing a type-safe way
* to handle operations that might fail. This pattern helps eliminate null checks
* and provides a more functional approach to error handling.

ABT

Think of an ABT as a way to represent code or expressions with variables and bindings (like let x = 5 in x + 2).

The main functions are hash and hashComponents. hash takes a single ABT as input and produces a Hash as output. This Hash is like a fingerprint of the ABT. hashComponents is designed for situations where you have multiple ABTs that might reference each other (like function definitions in a program). It takes a map of names (like function names) to their corresponding ABTs, and a function termFromHash that creates a special kind of ABT from a hash. It then outputs a list of pairs, where each pair contains a hash and the corresponding sorted list of name-ABT pairs from a "strongly connected component". A strongly connected component is a group of ABTs that are all inter-dependent.

The code works by breaking down ABTs into smaller parts and hashing them recursively. It handles different kinds of ABTs, like variables (Var'), cycles (Cycle'), abstractions (Abs''), and general terms (Tm'). For

# Colors from www.ColorBrewer.org by Cynthia A. Brewer,
# Geography, Pennsylvania State University. See BREWER for license.
# See www.colorbrewer.org for details.
#
# Color names are PALETTE-NUMCOLORS-TYPE-IDX (e.g. reds-3-seq-1)
#
# PALETTE palette name (e.g. reds)
# NUMCOLORS number of colors in the palette (e.g. 3)
# TYPE palette type (div, seq, qual)
# IDX color index within the palette (e.g. 1)
{
"name": "Uniswap Labs Extended",
"timestamp": "2024-10-01T19:32:51.793Z",
"version": {
"major": 10,
"minor": 0,
"patch": 0
},
"tags": {},
"logoURI": "ipfs://QmNa8mQkrNKp1WEEeGjFezDmDeodkWRevGFN8JCV7b4Xir",
{
"name": "Uniswap Labs Extended",
"timestamp": "2024-10-01T19:32:51.793Z",
"version": {
"major": 10,
"minor": 0,
"patch": 0
},
"tags": {},
"logoURI": "ipfs://QmNa8mQkrNKp1WEEeGjFezDmDeodkWRevGFN8JCV7b4Xir",
{
"name": "Uniswap Labs Extended",
"timestamp": "2024-10-01T19:32:51.793Z",
"version": {
"major": 10,
"minor": 0,
"patch": 0
},
"tags": {},
"logoURI": "ipfs://QmNa8mQkrNKp1WEEeGjFezDmDeodkWRevGFN8JCV7b4Xir",