Skip to content

Instantly share code, notes, and snippets.

View walteh's full-sized avatar

Walter Scott walteh

View GitHub Profile
@walteh
walteh / assemblyStorageRef.sol
Last active February 23, 2022 00:28
simple example of how solidity calculates storage refs for structs
pragma solidity 0.8.12;
// contains refs to hardhat console.sol and DSTest.sol contract
import '../utils/forge.sol';
contract test is t {
struct Test {
uint256 a;
uint256 b;
@walteh
walteh / CheckSameSign.sol
Last active July 12, 2022 11:10
gas analysis of different methods of checking sign equality of integers in solidity v8
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.15;
import "forge-std/Script.sol";
import "forge-std/Test.sol";
function checkSameSign1(int256 a, int256 b) pure returns (bool sameSign) {
uint256 sa;
uint256 sb;
public extension Result {
// Extract the value if it's a success
var value: Success? {
switch self {
case let .success(value):
return value
case .failure:
return nil
}
}
@walteh
walteh / aliasrc.plugin.zsh
Last active April 14, 2025 13:00
zsh-plugin-aliasrc - dynamic project specific aliases for cli commands
##############################################
# aliasrc - Directory-specific command aliases
#
# This plugin enables directory-specific command aliases by looking
# for executable files in a .aliasrc directory in the current directory
# or any parent directory. When found, commands that match executable
# names in that directory will be replaced with the path to the executable.
##############################################
# Load required zsh modules
@walteh
walteh / smart-history.plugin.zsh
Created April 14, 2025 13:02
smart-history.plugin.zsh - a history plugin that makes life easy
# https://zsh.sourceforge.io/Doc/Release/Options.html
# https://postgresqlstan.github.io/cli/zsh-history-options
# https://unix.stackexchange.com/questions/273861/unlimited-history-in-zsh
setopt EXTENDED_HISTORY # include timestamp
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt HIST_BEEP # beep if attempting to access a history entry which isn’t there
setopt HIST_FIND_NO_DUPS # do not display previously found command
setopt HIST_IGNORE_DUPS # do not save duplicate of prior command
setopt HIST_NO_STORE # do not save history commands