Skip to content

Instantly share code, notes, and snippets.

View nazt's full-sized avatar

Nat nazt

  • Chiang Mai Maker Club
  • Chiang Mai
  • X @nazt
View GitHub Profile
@nazt
nazt / .gitignore
Created October 27, 2024 09:49 — forked from clydebarrow/.gitignore
ESPHome LVGL samples
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
/wifi.yaml
@nazt
nazt / .gitignore
Created October 27, 2024 09:48 — forked from clydebarrow/.gitignore
LVGL watch face in ESPHome yaml
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
/wifi.yaml
@nazt
nazt / rings.js
Created January 19, 2023 17:49 — forked from mattdesl/rings.js
canvas-sketch + canvas-sketch-util = penplot lines
const canvasSketch = require('canvas-sketch');
const { renderPaths, createPath, pathsToPolylines } = require('canvas-sketch-util/penplot');
const { clipPolylinesToBox } = require('canvas-sketch-util/geometry');
const Random = require('canvas-sketch-util/random');
const settings = {
dimensions: [ 12, 12 ],
orientation: 'landscape',
pixelsPerInch: 300,
scaleToView: true,
@nazt
nazt / BaseOpenSea.sol
Created January 23, 2022 21:43 — forked from dievardump/README.md
Base file I use for my mainnet contracts to be compatible with OpenSea
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title OpenSea contract helper that defines a few things
/// @author Simon Fremaux (@dievardump)
/// @dev This is a contract used to add OpenSea's
/// gas-less trading and contractURI support
contract BaseOpenSea {
string private _contractURI;
address private _proxyRegistry;
@nazt
nazt / address2str.sol
Created January 14, 2022 12:36 — forked from kendricktan/address2str.sol
Solidity code to convert uint to string (v0.5.x)
function toAsciiString(address x) public view returns (string memory) {
bytes memory s = new bytes(40);
for (uint i = 0; i < 20; i++) {
byte b = byte(uint8(uint(x) / (2**(8*(19 - i)))));
byte hi = byte(uint8(b) / 16);
byte lo = byte(uint8(b) - 16 * uint8(hi));
s[2*i] = char(hi);
s[2*i+1] = char(lo);
}
const ethers = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/');
// you can find pair address from Factory Contract, method getPair(token1Addr, token2Addr).
let Contract = {
PancakePair: new ethers.Contract('0xb694ec7C2a7C433E69200b1dA3EBc86907B4578B',['function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'], provider),
TwindexPair: new ethers.Contract('0xC789F6C658809eED4d1769a46fc7BCe5dbB8316E',['function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'], provider)
}
@nazt
nazt / get_commit_count.py
Created November 6, 2020 03:50 — forked from yershalom/get_commit_count.py
Easy way to calculate commits count from the github api
import requests
base_url = 'https://api.github.com'
def get_all_commits_count(owner, repo, sha):
first_commit = get_first_commit(owner, repo)
compare_url = '{}/repos/{}/{}/compare/{}...{}'.format(base_url, owner, repo, first_commit, sha)
commit_req = requests.get(compare_url)
@nazt
nazt / ssm.sh
Created June 2, 2020 17:34 — forked from yudoufu/ssm.sh
#!/bin/bash
set -e
usage() {
echo "USAGE: `basename $0` [Options]"
echo " ssm target selection using peco"
echo ""
echo "Optinal Arguments:"
echo " All arguments excluded options pass to initial queries of peco"
echo ""
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.