Skip to content

Instantly share code, notes, and snippets.

View zed-wong's full-sized avatar
🕌

Zed Wong zed-wong

🕌
View GitHub Profile
@zed-wong
zed-wong / ff.go
Created August 8, 2021 00:26
golang ffmpeg exec
package main
import(
"fmt"
"log"
"os/exec"
"strings"
)
func main(){
@zed-wong
zed-wong / Leafer_twilio_outbound.xml
Last active April 27, 2022 12:28
Leafer alert from twilio
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Play loop="2">https://drive.google.com/uc?id=110Z0bLzKmYWASkCkpKb7g60x5TscOPtC</Play>
</Response>
@zed-wong
zed-wong / git-remove-from-history.sh
Created June 12, 2022 06:23
Remove file from git history
git filter-branch --index-filter \
'git rm -rf --cached --ignore-unmatch path_to_file' HEAD
@zed-wong
zed-wong / authorize.js
Last active July 27, 2022 02:15
Mixin SPA OAuth helper
// https://github.com/fox-one/uikit/blob/main/packages/uikit/src/utils/authorize.ts
// https://github.com/fox-one/uikit/blob/main/packages/uikit/src/services/mixin/oauth.js
import ReconnectingWebSocket from "reconnecting-websocket";
import { gzip } from "pako/lib/deflate";
import { ungzip } from "pako/lib/inflate";
import { v4 as uuidv4 } from "uuid";
import sha256 from "crypto-js/sha256"
import EncBase64 from "crypto-js/enc-base64";
@zed-wong
zed-wong / get-nfts-from-mvm.js
Last active August 12, 2022 13:03
The procedure of getting NFT(ERC721) information from MVM with ethers.js
import axios from 'axios';
import { ethers } from 'ethers';
//import ERC721ABI from '../assets/erc721.json';
export async function getNFTsFromExplorer(userAddr, provider){
if (!userAddr) throw new Error('UserAddr is required');
if (!provider) throw new Error('Provider is required');
const fetchTokens = await getTokensFromExplorer(userAddr);
const filteredTokens = filterTokens(fetchTokens);
@zed-wong
zed-wong / CurveCryptoSwap.vy
Created October 8, 2022 09:24
CurveCryptoSwap.vy
# @version 0.3.1
# (c) Curve.Fi, 2021
# Pool for USDT/BTC/ETH or similar
interface ERC20: # Custom ERC20 which works for USDT, WETH and WBTC
def transfer(_to: address, _amount: uint256): nonpayable
def transferFrom(_from: address, _to: address, _amount: uint256): nonpayable
def balanceOf(_user: address) -> uint256: view
interface CurveToken:
@zed-wong
zed-wong / CurveContract.vy
Created October 22, 2022 01:21
curve-contract
# @version 0.2.4
# (c) Curve.Fi, 2020
# Pool for DAI/USDC/USDT
from vyper.interfaces import ERC20
interface CurveToken:
def totalSupply() -> uint256: view
def mint(_to: address, _value: uint256) -> bool: nonpayable
def burnFrom(_to: address, _value: uint256) -> bool: nonpayable
@zed-wong
zed-wong / disable-ubuntu-sensor.md
Created November 22, 2022 08:49
Disable surface ubuntu sensor (disable screen rotation and touchscreen)
@zed-wong
zed-wong / utils.ts
Last active December 11, 2022 13:32
Ts utils functions
// $1.23
export const formatUSMoney = (x: string | number) => {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(Number(x))
}
// $123.23M
export const formatCompactUSD = (x: number) => {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumSignificantDigits: 2, notation: "compact" , compactDisplay: "short" }).format(x)
}
@zed-wong
zed-wong / UpdateMixinOneLine.sh
Created April 12, 2023 02:27
Update Mixin Messenger with one line (Ubuntu)
alias updateMixin="proxychains curl -L -o mixin_desktop.deb $(curl -s https://api.github.com/repos/MixinNetwork/flutter-app/releases/latest | grep "browser_download_url.*mixin_desktop_linux_amd64.deb" | cut -d : -f 2,3 | tr -d \") && sudo dpkg -i mixin_desktop.deb && rm mixin_desktop.deb"