Skip to content

Instantly share code, notes, and snippets.

@ghostffcode
ghostffcode / BatchResolver.sol
Last active May 18, 2023 20:21
Batch Resolve ENS names to addresses
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
abstract contract Registry {
function resolver(bytes32 node) external view virtual returns (address);
}
abstract contract Resolver {
function addr(bytes32 node) external view virtual returns (address);
}
@aileftech
aileftech / hex-colors.txt
Created October 1, 2022 18:10
A Bash one-liner to produce a list of HEX color codes that read like (supposedly) valid English words
$ grep -P "^[ABCDEFabcdefOoIi]{6,6}$" /usr/share/dict/words | tr 'OoIi' '0011' | tr '[:lower:]' '[:upper:]' | awk '{print "#" $0}'
#ACAD1A
#B0BB1E
#DEBB1E
#AB1DED
#ACAC1A
#ACCEDE
#AC1D1C
#BAB1ED
#BA0BAB
@moyix
moyix / killbutmakeitlooklikeanaccident.sh
Created February 5, 2022 22:51
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
contract HasDups {
function hasDuplicates(uint[] memory values) public pure returns (bool dups) {
uint max;
for(uint i = 0; i < values.length; i++) {
if(values[i] > max) max = values[i];
}
@dcts
dcts / scrape_opensea_floor_prices.py
Created October 24, 2021 21:10
Scrape opensea floor prices with python cloudscraper package
import cloudscraper
import json
def filter_typename(dict):
return dict["__typename"] == "AssetQuantityType"
def filter_quantityInEth_exists(dict):
if "quantityInEth" in dict:
return True
else:
import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
const canvasSketch = require("canvas-sketch");
const Tweakpane = require("tweakpane");
const settings = {
dimensions: [2048, 2048],
animate: true,
};
const params = {
rows: 10,
const UniswapV2FactoryArtifact = require('@uniswap/v2-core/build/UniswapV2Factory.json');
const UniswapV2PairArtifact = require('@uniswap/v2-core/build/UniswapV2Pair.json');
const UniswapV2Router02Artifact = require('@uniswap/v2-periphery/build/UniswapV2Router02.json');
const WETH9Artifact = require('@uniswap/v2-periphery/build/WETH9.json');
async function createMockWETH() {
// deploy mock WETH
const WETH9 = await ethers.getContractFactory(
@gorgos
gorgos / MultiSwap.sol
Created August 22, 2021 11:04
Example for how to swap multiple tokens in one on Ropsten
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;
pragma abicoder v2;
import "https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/interfaces/ISwapRouter.sol";
import "https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/interfaces/IQuoter.sol";
import {IERC20, SafeERC20} from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4-solc-0.7/contracts/token/ERC20/SafeERC20.sol";
interface IUniswapRouter is ISwapRouter {
@pekkavaa
pekkavaa / extending csv.md
Last active November 13, 2022 01:07
A Straightforward Way To Extend CSV With Metadata

A Straightforward Way To Extend CSV With Metadata

Pekka Väänänen, Aug 19 2021.

This proposal is a response to It's Time to Retire the CSV by Alex Rasmussen and the discussion on lobste.rs. Don't take it too seriously.

CSV files (comma-separated values) are great but sometimes difficult to parse because everybody seems to have a slightly different idea what CSV means. The obvious solution is to transmit some metadata that tells what to expect but where do you put it? Well, how about a ZIP archive?

An archive with two files. The first file, say format.txt, has the metadata inside and the second one is the original CSV file unchanged. This is still readable by non-technical users because ZIP files are natively supported by both Windows and macOS. People can double click on them like a directory and then double click again on the CSV to open it up in Excel.