Skip to content

Instantly share code, notes, and snippets.

View nazt's full-sized avatar

Nat Weerawan nazt

View GitHub Profile
@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 / dw-pt.ino
Created December 4, 2020 01:21
dw-pt.ino
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 12
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
@nazt
nazt / test-nbiot.ino
Created November 29, 2020 08:58
test-nbiot.ino
#define RXD2 26
#define TXD2 27
void setup() {
Serial.begin(115200);
//Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
pinMode(17, OUTPUT);
digitalWrite(17, LOW);
@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 / influxdb.conf
Last active July 22, 2020 06:54
influxdb.conf
### Welcome to the InfluxDB configuration file.
# The values in this file override the default values used by the system if
# a config option is not specified. The commented out lines are the configuration
# field and the default value used. Uncommenting a line and changing the value
# will change the value used at runtime when the process is restarted.
# Once every 24 hours InfluxDB will report usage data to usage.influxdata.com
# The data includes a random ID, os, arch, version, the number of series and other
# usage data. No data from user databases is ever transmitted.
@nazt
nazt / x.sh
Created July 17, 2020 19:07
x.sh
echo "$1"
if test $# -gt 0; then
export ID=$1
else
echo "no output dir specified"
exit 1
fi
pip install git+https://github.com/NAzT/ma1.git