Skip to content

Instantly share code, notes, and snippets.

View jeffprestes's full-sized avatar

Jeff Prestes jeffprestes

View GitHub Profile
@wmitsuda
wmitsuda / README.md
Last active June 17, 2022 19:20
Otterscan + Erigon + Prysm (ropsten)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
// Unlike the string type, ShortString is a value type that can be made immutable.
// It supports strings of at most 32 bytes and assumes they don't contain null bytes.
type ShortString is bytes32;
error StringTooLong(string s);
@PaulRBerg
PaulRBerg / FullMath.sol
Last active July 18, 2022 15:51
Remco Bloemen's "mulDiv" ported to Solidity v0.8 by Paul Razvan Berg. See latest: https://github.com/paulrberg/prb-math/blob/86c068e21f9ba229025a77b951bd3c4c4cf103da/contracts/PRBMath.sol#L480-L537
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
@miguelmota
miguelmota / hex_to_bigint.go
Last active May 30, 2023 20:08
Golang hex to big int
package main
import (
"fmt"
"math/big"
)
func main() {
s := "a"
i := new(big.Int)
@alexanderbez
alexanderbez / badger_wrapper.go
Last active January 22, 2023 21:03
An example wrapper around BadgerDB providing a simple embedded key/value store interface.
import (
"context"
"fmt"
"os"
"time"
"github.com/dgraph-io/badger"
)
const (
@glombard
glombard / install-apparix.sh
Created November 3, 2014 18:48
Setting up Apparix for directory bookmarks on Mac OS X
brew install -v apparix
# Installed to: /opt/foo/Cellar/apparix/11-0/bin/apparix
# Add bm/to Bash functions from man page to .bashrc or .local.bash:
man -P cat apparix | awk '/BASH-style functions/{p=1} /---/{if(p==1)p=2; else p=0; next} p>1{print}' >> ~/.local.bash
# Reload my bash config:
source ~/.local.bash
# Now create a bookmark:
@freeformz
freeformz / WhyILikeGo.md
Last active October 6, 2022 23:31
Why I Like Go

A slightly updated version of this doc is here on my website.

Why I Like Go

I visited with PagerDuty yesterday for a little Friday beer and pizza. While there I got started talking about Go. I was asked by Alex, their CEO, why I liked it. Several other people have asked me the same question recently, so I figured it was worth posting.

Goroutines

The first 1/2 of Go's concurrency story. Lightweight, concurrent function execution. You can spawn tons of these if needed and the Go runtime multiplexes them onto the configured number of CPUs/Threads as needed. They start with a super small stack that can grow (and shrink) via dynamic allocation (and freeing). They are as simple as go f(x), where f() is a function.