Skip to content

Instantly share code, notes, and snippets.

View hack3r-0m's full-sized avatar
🎯
Focusing

hack3r-0m

🎯
Focusing
View GitHub Profile
//! ```cargo
//! [dependencies]
//! bech32 = "0.9"
//! bip32 = "0.5"
//! dialoguer = "0.10"
//! hex = "0.4"
//! k256 = "0.13"
//! ripemd = "0.1"
//! thiserror = "1"
//! ```
@Philogy
Philogy / headers.py
Created October 9, 2022 02:03
Transmission11s Style Headers In Python
#!/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]
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
library Iterators {
// Function types:
// https://docs.soliditylang.org/en/latest/types.html#function-types
function map(uint256[] memory input, function (uint256) internal pure returns (uint256) f)
internal
pure
@noxx3xxon
noxx3xxon / arbitrage.py
Created August 21, 2022 22:34
CFMM Routing Arbitrage Example
import numpy as np
import cvxpy as cp
import itertools
# Problem data
global_indices = list(range(4))
# 0 = TOKEN-0
# 1 = TOKEN-1
# 2 = TOKEN-2
@0xA5DF
0xA5DF / !README.md
Last active August 19, 2022 13:37
Forge calculates gas as if it's all one tx (affecting ops that depend on warm/cold keys/addresses)

Forge calculates gas as if each test is one tx

Sample code

When runing forge test -m testGas --gas-report -vv, it shows the cost of calling x is 261:

╭──────────────────────────────────┬─────────────────┬─────┬────────┬─────┬─────────╮
│ contracts/Gas.sol:Store contract ┆                 ┆     ┆        ┆     ┆         │
╞══════════════════════════════════╪═════════════════╪═════╪════════╪═════╪═════════╡
│ Deployment Cost                  ┆ Deployment Size ┆     ┆        ┆     ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
function factorial_Yul_For(uint256 x) public pure returns(uint256){
assembly{
let result := 1
for {} iszero(iszero(x)) { x := sub(x, 1)} {
result := mul(result, x)
}
mstore(0,result)
return(0,0x20)
}
}
@Neo23x0
Neo23x0 / log4j_rce_detection.md
Last active September 11, 2024 21:41
Log4j RCE CVE-2021-44228 Exploitation Detection

log4j RCE Exploitation Detection

You can use these commands and rules to search for exploitation attempts against log4j RCE vulnerability CVE-2021-44228

Grep / Zgrep

This command searches for exploitation attempts in uncompressed files in folder /var/log and all sub folders

sudo egrep -I -i -r '\$(\{|%7B)jndi:(ldap[s]?|rmi|dns|nis|iiop|corba|nds|http):/[^\n]+' /var/log
@hrkrshnn
hrkrshnn / generic.org
Last active April 21, 2024 01:51
Some generic writeup about common gas optimizations, etc.

Upgrade to at least 0.8.4

Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!

The advantages of versions 0.8.* over <0.8.0 are:

  • Safemath by default from 0.8.0 (can be more gas efficient than some library based safemath).
  • Low level inliner from 0.8.2, leads to cheaper runtime gas. Especially relevant when the contract has small functions. For
@patrickd-
patrickd- / cheatsheet.md
Last active March 20, 2024 23:13
Solidity – Compilable Cheatsheet