Skip to content

Instantly share code, notes, and snippets.

View hujw77's full-sized avatar
πŸ’
Focusing

echo hujw77

πŸ’
Focusing
View GitHub Profile
@hujw77
hujw77 / generic.org
Created April 7, 2022 14:53 — forked from hrkrshnn/generic.org
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
@hujw77
hujw77 / .ethrc.sh
Created October 1, 2021 09:39 — forked from mds1/.ethrc.sh
# Ethereum helper methods
# source this in your .bashrc or .zshrc file with `. ~/.ethrc`
# --- Token addresses ---
aave=0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9
comp=0xc00e94Cb662C3520282E6f5717214004A7f26888
crv=0xD533a949740bb3306d119CC777fa900bA034cd52
dai=0x6B175474E89094C44Da98b954EedeAC495271d0F
gtc=0xDe30da39c46104798bB5aA3fe8B9e0e1F348163F
mkr=0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2
@hujw77
hujw77 / install.sh
Last active January 12, 2022 09:03
#!/bin/sh
# Based on the Nix install script
# This script installs Nix, Cachix, and evo-cli
{ # Prevent execution if this script was only partially downloaded
set -e
oops() {
@hujw77
hujw77 / MerkleVerifier.sol
Created June 24, 2021 12:34 — forked from recmo/MerkleVerifier.sol
Merkle multi-queries
contract MerkleVerifier {
function hash_leaf(uint256 value)
internal pure
returns (bytes32 hash)
{
return bytes32(value);
}
function hash_node(bytes32 left, bytes32 right)
@hujw77
hujw77 / fomo.sol
Created January 21, 2021 12:48 — forked from hayeah/fomo.sol
fomo3d contract
pragma solidity ^0.4.24;
/**
* @title -FoMo-3D v0.7.1
* β”Œβ”¬β”β”Œβ”€β”β”Œβ”€β”β”Œβ”¬β” ╦╦ ╦╔═╗╔╦╗ β”Œβ”€β”β”¬β”€β”β”Œβ”€β”β”Œβ”€β”β”Œβ”€β”β”Œβ”β”Œβ”Œβ”¬β”β”Œβ”€β”
* β”‚ β”œβ”€ β”œβ”€β”€β”‚β”‚β”‚ β•‘β•‘ β•‘β•šβ•β•— β•‘ β”œβ”€β”˜β”œβ”¬β”˜β”œβ”€ β””β”€β”β”œβ”€ β”‚β”‚β”‚ β”‚ └─┐
* β”΄ β””β”€β”˜β”΄ β”΄β”΄ β”΄ β•šβ•β•šβ•β•β•šβ•β• β•© β”΄ β”΄β””β”€β””β”€β”˜β””β”€β”˜β””β”€β”˜β”˜β””β”˜ β”΄ β””β”€β”˜
* _____ _____
* (, / /) /) /) (, / /) /)
* β”Œβ”€β” / _ (/_ // // / _ // _ __ _(/
* β”œβ”€β”€ ___/___(/_/(__(_/_(/_(/_ ___/__/_)_(/_(_(_/ (_(_(_
@hujw77
hujw77 / OracleMetadataTests.sol
Created December 13, 2020 09:35 — forked from cag/OracleMetadataTests.sol
Gas tests for oracle metadata
pragma solidity ^0.4.24;
contract SingleWordConsumer {
event LogWord(bytes32 w);
function receiveResult(bytes) external {
bytes32 w;
assembly {
w := calldataload(0x44) // 4 byte func selector +
// word of 1st arg offset +
@hujw77
hujw77 / gistColaboration.md
Created November 27, 2020 15:33 — forked from maglietti/gistColaboration.md
How to collaborate on a gist

To colaborate on a gist:

  1. Clone your gist repo locally
  2. Add your friend’s fork as a remote e.g. if your friend is named Cindy: git remote add-url cindy https://gist.github.com/cindy/df03bdacaef75a80f310
  3. Fetch your friend’s commits: git fetch cindy/master
  4. Merge your friend’s changes into your repo: git merge cindy/master
  5. Push the changes back to GitHub: git push origin/master
@hujw77
hujw77 / evolutionland-ropsten.json
Last active November 27, 2020 15:06
addresses
{
"ApostleBaseAuthorityV2": "0x7313fCf5ba7ACAe993b2746e8F62Ba730517AA3a-0x41315Dea9E44452c7FABCc5b243e9aE4eA09BB68-0xd55490c5F4EEA9e8E16Fbc76B7acB6F2095B8ebA",
"ApostleBaseV2": "0x3Fc42eadF609EfBa7552bEE29951561462f69A1C",
"ApostleClockAuction": "0x0378a5a4f05484B49B72940FFaB0132B7557E33C",
"ApostleSettingIds": "0x588c2B392a314Fd38dD25Ca0526946d6a7Def938",
"AuctionSettingIds": "0xcc70DB87712CA7d523a2b871d95290D86ed964f2",
"BankSettingIds": "0x2636cE0c5ef3dEEFe7b4f0B473eCb20eB18DE998",
"ClockAuctionAuthority": "0x7204B341ba9E74D2Bf22c87322043Bba891169",
"ClockAuctionV2": "0xd54B3Dbd400F8b58691CF3f2BA27D9788257425c",
"DRILLBASE": "0x5fB3E544f46FFc8ce1bB0e2803Fdb8C5536cFfB7",
@hujw77
hujw77 / ListMemcached.md
Created July 9, 2020 09:03 — forked from abullrd/ListMemcached.md
List Memcached Keys
@hujw77
hujw77 / nginx-tuning.md
Created May 10, 2019 03:23 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.