Skip to content

Instantly share code, notes, and snippets.

View myself659's full-sized avatar

沉风 myself659

  • Metaverse
View GitHub Profile
@myself659
myself659 / eventFilter.js
Created December 29, 2021 15:04 — forked from wschwab/eventFilter.js
a handmade Ethereum event filter that you should never really use
const eventFilter = (contractAddress, contractAbi, eventName, _provider) => {
const provider = _provider
// this will return an array with an object for each event
const events = contractAbi.abi.filter(obj => obj.type ? obj.type === "event" : false);
// getting the Transfer event and pulling it out of its array
const event = events.filter(event => event.name === eventName)[0];
// getting the types for the event signature
const types = event.inputs.map(input => input.type)
// knowing which types are indexed will be useful later
let indexedInputs = [];
#!/bin/bash
# We don't need return codes for "$(command)", only stdout is needed.
# Allow `[[ -n "$(command)" ]]`, `func "$(command)"`, pipes, etc.
# shellcheck disable=SC2312
set -u
abort() {
printf "%s\n" "$@"
@myself659
myself659 / gist:6465715b51c08c57019facd7405f9ead
Created November 23, 2021 02:42
React Hook for DApps | Switching Network Chains in Metamask.
/**
* useChain react-hook.
* use this to switch chain on metamask wallet.
* @module useChain
* @author subhakartikkireddy
*/
import { useState, useEffect } from "react";
/** USE CHAIN REACT HOOK */
@myself659
myself659 / examples.py
Created August 1, 2021 12:56 — forked from Adirockzz95/examples.py
manim animation examples
#!/usr/bin/env python
#
# Usage: python extract_scene.py -p [filename] [classname]
# eg: python extract_scene.py -p examples.py DrawCircle
#
import math
import numpy as np
@myself659
myself659 / composing-software.md
Created May 2, 2021 11:03 — forked from Geoff-Ford/composing-software.md
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@myself659
myself659 / master-javascript-interview.md
Created May 2, 2021 10:45 — forked from Geoff-Ford/master-javascript-interview.md
Eric Elliott's Master the JavaScript Interview Series
@myself659
myself659 / erc20-token-sample.sol
Created February 21, 2021 09:21 — forked from jcmartinezdev/erc20-token-sample.sol
Necessary code to generate an ERC20 Token
pragma solidity ^0.4.24;
// ----------------------------------------------------------------------------
// Sample token contract
//
// Symbol : LCST
// Name : LCS Token
// Total supply : 100000
// Decimals : 2
// Owner Account : 0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe

About variadics in Rust

This is an analysis of how variadic generics could be added to Rust. It's not a proposal so much as a summary of existing work, and a toolbox for creating an eventual proposal.

Introduction

Variadic generics (aka variadic templates, or variadic tuples), are an often-requested feature that would enable traits, functions and data structures to be generic over a variable number of types.

To give a quick example, a Rust function with variadic generics might look like this:

@myself659
myself659 / brownies.py
Created December 22, 2020 06:57 — forked from jiweiliew/brownies.py
Encrypt PDF and send as an email attachment via python
import hashlib
import os
import pandas as pd
import re
import time
import tkinter.filedialog as tkfd
import win32com.client as w32
from PyPDF2 import PdfFileReader, PdfFileWriter
class Session: