Skip to content

Instantly share code, notes, and snippets.

@artiya4u
artiya4u / get_txhash.py
Created August 10, 2022 12:02
Get Polkadot txHash by block number and height
# pip install substrate-interface
from substrateinterface import SubstrateInterface
substrate = SubstrateInterface(
url="https://rpc.polkadot.io"
)
block_number = 11542800
number = 2
@artiya4u
artiya4u / never_second_best.py
Last active March 21, 2022 07:56
เขียนโปรแกรมรับ list ของตัวเลข แล้วให้คืนค่าตัวเลขที่ซ้ำมากที่สุดเป็นอันดับที่ 2 [1, 2, 2] => 1 [1, 2, 2, 3, 3, 3] => 2 [4, 4, 4, 4, 1, 2, 2, 3, 3, 3] => 3
import random
import numpy as np
from collections import defaultdict
import matplotlib.pyplot as plt
from tensorflow import keras
list_size = 10
class_num = 9
import React from 'react';
import {
StyleSheet,
Text,
View,
FlatList,
Dimensions,
TouchableOpacity,
Image,
} from 'react-native';
@artiya4u
artiya4u / README.md
Last active November 6, 2020 15:13 — forked from mrbar42/README.md
bash scripts to create VOD HLS stream with ffmpeg almighty (tested on Linux and OS X) | Vertical video for Nvidia NVENC GPU

running:

bash create-vod-hls.sh beach.mkv

will produce:

    beach/
      |- playlist.m3u8
 |- 360p.m3u8
CREATE TEMPORARY FUNCTION decrypt(_text STRING) RETURNS STRING LANGUAGE js AS
"""
let key = CryptoJS.enc.Utf8.parse("KEY");
let options = { iv: CryptoJS.enc.Utf8.parse("IV"), mode: CryptoJS.mode.CBC };
let _decrypt = CryptoJS.AES.decrypt(_text, key, options).toString(CryptoJS.enc.Utf8);
return _decrypt;
""" OPTIONS (library="gs://crypto-lib/crypto-js.min.js");
SELECT decrypt('ENCRYPTED');
const BNK48CoinCrowdSale = artifacts.require("BNK48CoinCrowdSale");
const BNK48Coin = artifacts.require("BNK48Coin");
const Web3 = require('web3')
function ether(n) {
return new Web3.utils.BN(Web3.utils.toWei(n, 'ether'));
}
module.exports = function (deployer, network, accounts) {
pragma solidity >=0.4.21 <0.7.0;
import "@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/distribution/RefundableCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/emission/MintedCrowdsale.sol";
contract BNK48CoinCrowdSale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale
{
constructor(uint256 _openingTime, uint256 _closingTime, uint256 _rate, address payable _wallet, uint256 _cap, IERC20 _token, uint256 _goal) public
pragma solidity >=0.4.21 <0.7.0;
import "@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol";
import "@openzeppelin/contracts/ownership/Ownable.sol";
contract BNK48Coin is ERC20Mintable {
string public constant name = "BNK48 COIN"; // solium-disable-line uppercase
string public constant symbol = "BNK48"; // solium-disable-line uppercase
@artiya4u
artiya4u / localIpAddress.js
Created March 22, 2020 13:37
Get local IP address in NodeJS
let os = require('os');
module.exports.localIpAddress = () => {
let ifaces = os.networkInterfaces();
for (let dev in ifaces) {
for (let detail of ifaces[dev]) {
if (detail.family === 'IPv4') {
return detail.address;
}
}
@artiya4u
artiya4u / index.js
Last active March 8, 2020 19:03
Use async function without callback.
const {promisify} = require('util');
const fs = require('fs');
const readFileAsync = promisify(fs.readFile);
const filePath = 'index.js';
async function main() {
try {
let text = await readFileAsync(filePath, {encoding: 'utf8'});
console.log(text);