Skip to content

Instantly share code, notes, and snippets.

@devtooligan
devtooligan / make_str.py
Created March 18, 2025 20:36
convert .md to string (with properly escaped characters)
import sys
import re
def convert_to_ts_string(file_path):
try:
# Read the Markdown file content
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
# Escape special characters
@devtooligan
devtooligan / make_md.py
Created March 18, 2025 20:35
Convert string to .md
import sys
import re
def convert_to_markdown(input_path):
try:
with open(input_path, 'r', encoding='utf-8') as input_file:
content = input_file.read()
# Replace escaped newlines with actual newlines
content = content.replace('\\n', '\n')
@devtooligan
devtooligan / gist:6f110f6c8c35db15459bd67abc6aee48
Created October 7, 2024 23:34
Unsafe "WBTC" token used in Shezmu hack
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import { Vm } from "forge-std/Vm.sol";
import {Test, console} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function mint(address account, uint256 amount) external;
}
@devtooligan
devtooligan / README.md
Last active April 10, 2025 05:28
A bash script to create pull requests for setting up a repo the old Spearbit way

makeprs.sh

A bash script to create pull requests for setting up a repo the old Spearbit way

Requirements

  1. be sure you have gh installed if you want the script to create PR's (optional)

Mac

@devtooligan
devtooligan / UnrolledLoopTest.sol
Last active July 28, 2023 20:42
unrolled loop
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "forge-std/Test.sol";
contract UnrolledLoopTest is Test {
function _transfer1(uint256 counter) internal returns (uint256) {
// token.transfer(addressList[counter], amount);
return counter + 1;
}
@devtooligan
devtooligan / TestIsPayable.sol
Created July 1, 2023 19:54
Utility to check if a function is payable
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "forge-std/Test.sol";
contract Utility {
error BadCalldata();
error NonPayable();
error Payable();
error NoCode();
@devtooligan
devtooligan / cursedbeaconproxy.sol
Last active April 9, 2024 16:10
PoC of crit bug found in Astaria.xyz's custom BeaconProxy contract
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
contract SheHateMe {
receive() external payable {}
function getImpl(uint8 x) public returns (address) {
return address(this);
@devtooligan
devtooligan / emitRevertTest.sol
Last active June 15, 2023 22:36
Foundry test - Emit event and revert
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "forge-std/Test.sol";
contract Reverter {
event Test();
function emitAndRevert() external {
emit Test();
@devtooligan
devtooligan / pureConsole.sol
Last active January 21, 2024 14:25
console.log from pure functions h/t @z0age
// @author original POC by @z0age
library pureConsole {
/*********************
* string + uint256
********************/
function log(string memory errorMessage, uint256 value) internal pure {
#!/bin/bash
alias c='code .'
alias cdh='cd $HOME'
alias ls='ls -la'
alias sl="ls"
alias cls='clear'
alias g='git status'
alias gap='git add -p'
alias gl='git log'