This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs; | |
fn sort_desc<T: Ord>(v: &mut Vec<T>) { | |
v.sort_by(|a, b| b.cmp(a)); | |
} | |
/// # Advent Of Code 2022 (Day 1). | |
/// | |
/// Challenge is you an input which displays "calories of elves" ([link](https://adventofcode.com/2022/day/1)): | |
/// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import pyperclip | |
import argparse | |
def check_width(args, base_width): | |
min_width = len(args.text) + base_width | |
if args.width < min_width: | |
raise ValueError( | |
f'Width of {args.width} cannot fit "{args.text}" (len: {len(args.text)} + {base_width})' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import dotenv | |
import requests | |
from collections import defaultdict | |
from decimal import Decimal as D | |
dotenv.load_dotenv() | |
# Instructions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.15; | |
import {Test} from "forge-std/Test.sol"; | |
/// @author Philippe Dumonet <https://github.com/philogy> | |
contract StringTest is Test { | |
bytes str; | |
function testBytesLikeStorage(bytes memory _inputStr) public { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @license MIT | |
# @author Philogy <https://github.com/Philogy> | |
from eth_utils.abi import function_signature_to_4byte_selector | |
from eth_utils.crypto import keccak | |
from math import ceil, log2 | |
import pyperclip | |
def find_reselector_nonce(selectors, mask): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Credit to karma (@0xkarmacoma) for the original code: twitter.com/0xkarmacoma/status/1584239664310779904 | |
Credit to kaden.eth (@0xKaden) for suggesting the use of msize: twitter.com/0xKaden/status/1584280521089376256 | |
*/ | |
#define macro reverse_word() = takes(1) returns(1) { | |
// [x0] | |
0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff | |
dup2 dup2 and // [x1r, mask1, x0] | |
0x08 shl // [x1r', mask1, x0] | |
swap2 // [x1, mask1, x1r'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0-only | |
pragma solidity 0.8.15; | |
import {Test} from "forge-std/Test.sol"; | |
import {HuffDeployer} from "foundry-huff/HuffDeployer.sol"; | |
/// @author Philippe Dumonet <[email protected]> | |
contract ReverseTest is Test { | |
address reversooor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.17; | |
// Used in the `name()` function | |
// "Yul Token" | |
bytes32 constant nameLength = 0x0000000000000000000000000000000000000000000000000000000000000009; | |
bytes32 constant nameData = 0x59756c20546f6b656e0000000000000000000000000000000000000000000000; | |
uint256 constant maxUint256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
=================================================== | |
POTENTIALLY OUT-OF-DATE (last update: 2022-10-15). | |
PLEASE REFER TO THE FOLLOWING REPO: https://github.com/Philogy/concise-erc1967-proxies | |
=================================================== | |
*/ | |
#define constant IMPL_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc | |
#define macro CONSTRUCTOR() = takes (0) returns (0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import sys | |
import pyperclip | |
def main(): | |
args = sys.argv | |
if len(args) != 2: | |
raise ValueError(f'Invalid argument count {len(args)} expected 2') | |
word = args[1] |