Skip to content

Instantly share code, notes, and snippets.

View sambacha's full-sized avatar
:atom:

sam bacha sambacha

:atom:
View GitHub Profile
@sambacha
sambacha / main.go
Created February 24, 2025 04:34 — forked from mdehoog/main.go
Dump the transcation size + estimated compressed size from a geth database, and analyze using numpy
package main
import (
"bytes"
"compress/zlib"
"context"
"encoding/binary"
"fmt"
"log"
"math/big"
// Find the latest version of this script here:
// https://gist.github.com/rsms/a8ad736ba3d448100577de2b88e826de
//
const EM = 2048
interface FontInfo {
familyName :string
styleName :string
unitsPerEm :int
ascender :int
@sambacha
sambacha / decode-dyn-uti.swift
Created August 14, 2023 12:10 — forked from jtbandes/decode-dyn-uti.swift
Dynamic UTI decoding
/// Decodes a dynamically-generated Uniform Type Identifier for inspection purposes. (**NOT FOR PRODUCTION USE!**)
/// Many, many thanks to http://alastairs-place.net/blog/2012/06/06/utis-are-better-than-you-think-and-heres-why/
///
/// <https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-BCGCDHIJ>
func decodeDynUTI(_ uti: String) -> String?
{
let vec = Array("abcdefghkmnpqrstuvwxyz0123456789")
let encoded = Array(uti).suffix(from: 5)
var result: [UInt8] = []
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.6.8;
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*

Trying Ezno checking today

This a short overview of some of the things you can do with Ezno today. If you find any problems, file an issue.

The following examples show some errors that have been caught using type checking, partial/const evaluation and effects.

To get started we will install oxidation-compiler which has bindings for Ezno's checker. (you can also get the binary from the releases page).

npm install -g oxidation-compiler@latest
@sambacha
sambacha / go-function-error-reporting.md
Created October 8, 2022 10:45 — forked from posener/go-function-error-reporting.md
Function Failure reporting: Error or OK

Function Failure Reporting: Error or OK

Go's "multiple return values" feature, can be used for several purposes. Among them for failure reporting to the function caller. Go has two conventions for failure reporting, but currently, no clear convention for which to use when. I've encountered different programmers that prefer different choices in different cases. In this article, we will discuss the two, and try to make the process of choosing our next function signature more conscious.

The Basics

@sambacha
sambacha / FeeEstimationHighLevel.md
Created July 29, 2022 05:47 — forked from morcos/FeeEstimationHighLevel.md
Bitcoin Core Fee Estimation Algorithm

High level description Bitcoin Core's fee estimation algorithm

The algorithm takes as input a target which represents a number of blocks within which you would like your transaction to be included in the blockchain. It returns a fee rate that you should use on your transaction in order to achieve this.

The algorithm is conceptually very simple and does not attempt to have any predictive power over future conditions. It only looks at some recent history of transactions and returns the lowest fee rate such that in that recent history a very high fraction of transactions with that fee rate were confirmed in the block chain in less than the target number of blocks.

Transactions can occur with a nearly continuous range of fee rates and so in order to avoid tracking every historical transaction independently, they are grouped into fee rate "buckets". A fee rate bucket represents a range of fee rates within which the algorithm treats all transactions as having approximately the same fee rate and the answer th

@sambacha
sambacha / create-service.sh
Created July 14, 2022 23:23 — forked from ahmedsadman/create-service.sh
Bash script to create systemd service
#!/usr/bin/bash
##
## Creates Service file based on JSON data
##
# Sample JSON file:
# {
# "service_name": "test_service",
# "description": "Netcore dev server",
@sambacha
sambacha / HeapSort.sol
Created July 11, 2022 13:14 — forked from fiveoutofnine/HeapSort.sol
Solidity implementation of max-heapsort
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract HeapSort {
function sort(uint256[] calldata _input) external pure returns (uint256[] memory) {
_buildMaxHeap(_input);
uint256 length = _input.length;
unchecked {
for (uint256 i = length - 1; i > 0; --i) {
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
library RadixSort {
uint256 internal constant ALPHABET_SIZE_LOG_2 = 7;
uint256 internal constant ALPHABET_SIZE = 1 << ALPHABET_SIZE_LOG_2;
uint256 internal constant MASK = ALPHABET_SIZE - 1;
function sort(uint256[] memory _list) internal pure {
uint256 iterations;