Skip to content

Instantly share code, notes, and snippets.

@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.
@nazt
nazt / LINE-BOT-GAS-SAMPLE.js
Created May 24, 2020 12:22 — forked from nwatab/LINE-BOT-GAS-SAMPLE.js
Supporterz 2 and 24, October, 2018
We couldn’t find that file to show.
@nazt
nazt / fix_parallels_tools_install.md
Created May 6, 2020 15:17 — forked from xiaozhuai/fix_parallels_tools_install.md
fix parallels tools install issue

install log

cd prl_fs/SharedFolders/Guest/Linux/prl_fs && make CC=cc
make[1]: Entering directory '/usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs'
make -C /lib/modules/5.0.0-25-generic/build M=/usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs CC=cc
make[2]: Entering directory '/usr/src/linux-headers-5.0.0-25-generic'
  CC [M]  /usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.o
/usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c: In function 'prlfs_remount':
/usr/lib/parallels-tools/kmods/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c:119:21: error: 'MS_RDONLY' undeclared (first use in this function); did you mean 'IS_RDONLY'?
  if ( (!((*flags) & MS_RDONLY) && PRLFS_SB(sb)->readonly) ||