Skip to content

Instantly share code, notes, and snippets.

@stonegao
stonegao / ssr.md
Created April 20, 2022 06:43 — forked from Widdershin/ssr.md
The absurd complexity of server-side rendering

In the olden days, HTML was prepared by the server, and JavaScript was little more than a garnish, considered by some to have a soapy taste.

After a fashion, it was decided that sometimes our HTML is best rendered by JavaScript, running in a user's browser. While some would decry this new-found intimacy, the age of interactivity had begun.

But all was not right in the world. Somewhere along the way, we had slipped. Our pages went uncrawled by Bing, time to first meaningful paint grew faster than npm, and it became clear: something must be done.

And so it was decided that the applications first forged for the browser would also run on the server. We would render our HTML using the same logic on the server and the browser, and reap the advantages of both worlds. In a confusing series of events a name for this approach was agreed upon: Server-side rendering. What could go wrong?

In dark rooms, in hushed tones, we speak of colours.

@stonegao
stonegao / markdown-text-101.md
Created April 16, 2022 09:00 — forked from matthewzring/markdown-text-101.md
A guide to Markdown on Discord.

Markdown Text 101

Want to inject some flavor into your everyday text chat? You're in luck! Discord uses Markdown, a simple plain text formatting system that'll help you make your sentences stand out. Here's how to do it! Just add a few characters before & after your desired text to change your text! I'll show you some examples...

Sweet Styles

Italics *italics* or _italics_

Underline italics __*underline italics*__

@stonegao
stonegao / getethstats.js
Created April 11, 2022 08:26 — forked from abdul/getethstats.js
Get Ethereum Stats (using Web3.js) - current block number, block heigh (transactions count), TPS (transaction per second), average gas price
const Web3 = require("web3");
const INFURA_END_POINT = "https://mainnet.infura.io/v3/<ENTER_INFURA_API_TOKEN>"
const web3 = new Web3(new Web3.providers.HttpProvider(INFURA_END_POINT));
const getEthStats = async () => {
const gasPrice = await web3.eth.getGasPrice(); //average gas price
const currentBlock = await web3.eth.getBlock("latest");
let result = null;
if (currentBlock.number !== null) { //only when block is mined not pending
const previousBlock = await web3.eth.getBlock(currentBlock.parentHash);
Twitter ID Screen name Followers Verified Last observed Display name
24929621 ParisHilton 16907951 true 2022-04-05T06:31:03Z ParisHilton.eth
24966423 TreySongz 13768497 true 2022-03-09T18:10:35Z TreySongz.eth
139539038 jccaylen 6428545 true 2022-04-02T09:20:45Z jccaylen.eth ᵍᵐ
380436513 laurDIY 5706236 true 2022-03-20T08:07:24Z lauren ✰ laurdiy.eth
150003563 mariobautista_ 5474217 true 2022-02-26T15:01:39Z MarioBautista.eth
46957344 DrakeBell 4480125 true 2022-04-06T00:27:56Z DrakeBell.ethᵍᵐ
342599843 MarioGoetze 4216847 true 2022-04-05T19:16:51Z mariogotze.eth
295218901 VitalikButerin 3635761 true 2022-04-05T20:24:20Z vitalik.eth
305192408 shitty_og 3033054 false 2022-03-20T15:24:34Z Shitty.eth
Twitter ID Screen name Followers Removal observed Before After
17461978 SHAQ 15612791 2022-02-26T22:24:52Z SHAQ.ETH SHAQ.SOL
21910850 jakeowen 2119904 2022-02-26T15:45:18Z jakeowen.eth Jake Owen
7846 ijustine 1811449 2022-03-09T14:43:37Z iJustine.eth iJustineUltra
1666038950 BoredElonMusk 1752290 2022-02-17T08:05:47Z bored.eth Bored
381051960 ethRuby 1267133 2022-03-19T08:08:11Z CryptoSolis.eth Ruby
1282418324228337665 wsbmod 832406 2022-02-24T06:52:07Z wsbmod.eth wsbmod
20882981 EclecticMethod 495235 2022-02-18T04:39:30Z eclecticm.eth Eclectic Method
811350 alexisohanian 479340 2022-02-08T06:31:55Z AlexisOhanian.eth 7️⃣7️⃣6️⃣ Alexis Ohanian 7️⃣7️⃣6️⃣
22784458 Fwiz 410813 2022-03-22T08:54:42Z Ryan Wyatt - fwiz.eth 💜 Ryan Wyatt - @ GDC
@stonegao
stonegao / octal_x86.txt
Created February 21, 2022 06:48 — forked from seanjensengrey/octal_x86.txt
x86 is an octal machine
# source:http://reocities.com/SiliconValley/heights/7052/opcode.txt
From: mark@omnifest.uwm.edu (Mark Hopkins)
Newsgroups: alt.lang.asm
Subject: A Summary of the 80486 Opcodes and Instructions
(1) The 80x86 is an Octal Machine
This is a follow-up and revision of an article posted in alt.lang.asm on
7-5-92 concerning the 80x86 instruction encoding.
The only proper way to understand 80x86 coding is to realize that ALL 80x86
@stonegao
stonegao / FlashPot.sol
Created December 27, 2021 04:33 — forked from z0r0z/FlashPot.sol
flash-lendable ETH wrapper with elastic shares
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.4;
import "https://github.com/Rari-Capital/solmate/blob/audit-fixes/src/tokens/WETH.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/interfaces/IERC3156FlashBorrower.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/interfaces/IERC3156FlashLender.sol";
contract FlashPot is WETH, IERC3156FlashLender {
using SafeTransferLib for address;
@stonegao
stonegao / songs.md
Created September 26, 2021 07:28 — forked from Suhail/songs.md

FAQ of Songs for Tunes

Songs for Tunes lets artists upload songs to sell on an open decentralized marketplace with other artists. The goal is to fund music artists to keep producing great music.

To mint, you need music.

1. How do I mint an Original Song?

You must be the owner of an original Tune NFT. You can buy one here: https://opensea.io/collection/tunesproject

After that, you can mint directly from our web app: https://songs.tunesproject.org

Overview

To understand how constructors through Solidity works (that is, how do we go from the compiled contract's bin to a live deployed contract with a different deployedBytecode), I took a deep dive into how one simple contract worked.

The contract Simple.sol:

pragma solidity ^0.5.12;

contract Simple {
@stonegao
stonegao / NewlyCreatedTokenQuery.ql
Created September 22, 2021 11:47 — forked from buddies2705/NewlyCreatedTokenQuery.ql
GraphQL API to get the newly created Ethereum Tokens
{
ethereum {
smartContractCalls(options: {desc: "block.height", limit: 10}, smartContractMethod: {is: "Contract Creation"}, smartContractType: {is: Token}) {
block {
height
timestamp {
time
}
}
smartContract {