Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -euo pipefail
rm -rf ~/.local/{bin/nvim,lib/nvim,share/nvim,share/man/man1/nvim.1,share/icons/hicolor/128x128/apps/nvim.png}
xattr -c nvim-macos-arm64.tar.gz
tar xzf nvim-macos-arm64.tar.gz --strip-components 1 -C ~/.local/
rm nvim-macos-arm64.tar.gz
@frangio
frangio / gist:608671a39164eb9372c93012dfd52464
Last active December 21, 2024 19:51
EVML Assembly syntax examples
code main : 0 -> ! {
push0
push0
callf other
stop
}
code other : 2 -> 1 {
rjumpi end
pop
@frangio: is there a list of all the consistency/security checks abi coder v2
does? e.g. that offsets are within bounds
@ekpyron: We're currently lacking exhaustive documentation on it, unfortunately
- it came up a few times recently and we want to improve docs around it,
though. But as a brief informal summary: Calldata validation involves at least
(I may be missing something else myself out of my head) range-checks for
values, bounds-checks and size-checks for arrays and bounds checks against
overall calldata size. In particular, what's lacking documentation is indeed
when precisely it happens. For performance reasons, we don't necessarily
@frangio
frangio / buffered.rs
Last active December 17, 2024 18:23
Rust Buffered Iterator
use std::mem::MaybeUninit;
pub struct Buffered<I: Iterator, const N: usize> {
iter: I,
count: usize,
next: usize,
buf: [MaybeUninit<I::Item>; N],
}
impl<I: Iterator, const N: usize> Buffered<I, N> {
ef000101000402000100110400200000000003365f5f37365fd10000f93d5f5f3e5f3df3
@frangio
frangio / EIP7702Account.sol
Last active November 25, 2024 00:05
A simple ERC-4337 account for use as an EIP-7702 template. UNAUDITED
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
struct PackedUserOperation {
address sender;
uint256 nonce;
bytes initCode;
bytes callData;
bytes32 accountGasLimits;
uint256 preVerificationGas;
@frangio
frangio / Swap.t.sol
Created April 5, 2024 18:03
Testing potential gas savings for Uniswap v4 Swap events
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Test} from "forge-std/Test.sol";
contract SwapTest is Test {
event Gasused(uint);
event Swap(
bytes32 indexed id,
@frangio
frangio / Fib.lean
Last active February 28, 2024 17:20
import Std.Data.Nat.Lemmas
import Std.Tactic.Omega
import Std.Tactic.Simpa
def fib (n : Nat) :=
match n with
| 0 | 1 => n
| n' + 2 => fib (n' + 1) + fib n'
def fastfib (n : Nat) := loop n 1 0
"use strict";
const defaultOptions = {
reverse: true,
python: false
}
function merge(sequences) {
let result = [];
sequences = sequences.map(s => s.slice());
@frangio
frangio / ascii.sol
Last active October 19, 2024 06:41
Solidity function to check if a string contains only printable ASCII characters and is at most 32 characters long. Branch-free "vectorized" implementation.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
function isAsciiPrintableShortString(string memory str) pure returns (bool) {
unchecked {
uint256 b = uint256(bytes32(hex"0101010101010101010101010101010101010101010101010101010101010101"));
bytes32 chars = bytes32(bytes(str));
uint256 len = bytes(str).length;