Skip to content

Instantly share code, notes, and snippets.

View dievardump's full-sized avatar

Simon Fremaux dievardump

View GitHub Profile
@dievardump
dievardump / docker-compose-nginx-node-postgres.yml
Last active December 20, 2023 16:25
Creating a server (VPS, EC2, anything you have access to) that can handle several VIRTUAL_HOST without the hassle of managing `sites-enabled` etc...
version: "3"
services:
postgres:
image: postgres:16
container_name: myWebsite_postgres
restart: unless-stopped
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=E8FiIVyP5DPiHLwCRMXPHGZYa # change that password
@dievardump
dievardump / reorg.js
Created June 1, 2023 08:06
Hardhat reorg
import {getUnnamedAccounts, ethers} from 'hardhat';
async function main() {
await network.provider.send('evm_setAutomine', [false]);
let snapshot = null;
async function mine() {
let blockNumber = parseInt(await network.provider.send('eth_blockNumber'), 16);
let block = await network.provider.send('eth_getBlockByNumber', [`0x${blockNumber.toString(16)}`, false]);
console.log(`${blockNumber}: ${block?.hash}`);
@dievardump
dievardump / Efficient721Airdrop.sol
Last active March 1, 2023 14:08
Function to add to OZ ERC721 to make an efficient airdrop
contract ERC721 {
// take OpenZeppelin contract and add this at the end:
uint256 private _lastTokenId;
// uncomment next line if you need totalSupply
// uint256 public totalSupply;
/// @dev be careful this function expects recipients to all be unique and not be address(0)
function _airdrop(address[] calldata recipients) internal virtual {
@dievardump
dievardump / README.md
Last active February 4, 2023 09:28
Simple Operator Filter for ERC721 & ERC721A

What

This is a quick implementation of the OpenSea OperatorFilter with a way to activate / deactivate it over time

Usage

ERC721A

@dievardump
dievardump / getERC20WalletBalance.js
Last active April 9, 2023 15:05
Get any wallet tokens for a given contract using events
function getERC20Contract(address) {
return new ethers.Contract(address, [{
anonymous: false,
inputs: [
{ indexed: true, internalType: 'address', name: 'from', type: 'address' },
{ indexed: true, internalType: 'address', name: 'to', type: 'address' },
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
],
name: 'Transfer',
type: 'event',
@dievardump
dievardump / mint.html
Created December 14, 2021 19:46
Easy interaction with a contract
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/ethers@5.4.7/dist/ethers.umd.min.js"></script>
</head>
<body>
<script>
@dievardump
dievardump / README.md
Last active January 25, 2023 14:55
Base file I used to use for my mainnet contracts to be compatible with OpenSea

Warning !!!

Recent events have shown that the auto-approval for user proxies is way too dangerous.

Security of users' NFTs should come before the convenience of auto approving collection for trading.

This is why I decided to remove the files in this gist.

Security risk

@dievardump
dievardump / Dockerfile
Created April 27, 2021 22:38
Dockerfile build for sveltekit
FROM node:14 as builder
WORKDIR /home/node/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:14 as installer
WORKDIR /home/node/app
did:3:bafyreiavdrl6ptxuqdefz7qod35zqyuzrasoosemcvskvsjoost5je3lxq
@dievardump
dievardump / SplitText.css
Last active September 29, 2020 12:09
Simple Text animation using gsap
/* for gsap transform */
.split-text__line,
.split-text__letter,
.split-text__word {
display: inline-block;
}
/* don't break "words" wrapper */
.split-text__word {
white-space: nowrap;