This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fetch the sponsor signature. | |
const sponsorSignature = await getSponosrSignature( | |
'0x'+originAddress.toString('hex'), | |
txBody | |
) | |
// Compose a combined signature of user + sponsor. | |
const sig = Buffer.concat([ | |
originSignature, | |
Buffer.from(sponsorSignature, 'hex') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Attempt to commit a transaction to a contract. | |
* | |
* With a hefty wallet as "sponsor" + an empty wallet as "sender". | |
* | |
*/ | |
const fetch = require("node-fetch"); | |
const cry = require('thor-devkit/dist/cry') | |
const Transaction = require('thor-devkit/dist/transaction').Transaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
foo = random.SystemRandom() | |
threshold = 8 | |
at_least = 5 | |
bingo = 0 | |
experiment_times = 100000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python3 | |
# In 100 numbers, | |
# Exactly has (n) numbers, that are <= value | |
# The possibility. | |
def f(n, value): | |
a = 1 - value/100 | |
b = value/100 | |
# Numbers that are > 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3 Script | |
# Count the "real" code lines (exclude empty lines, and comments) in a project. | |
# Languages supported: Python, JavaScript, C, C++, Java, C#, etc.... | |
# Analyse: | |
# A source code file contains code, and comments. | |
# Single line comments are easy. Just // or # | |
# Multi-line comments are begin usually with /*, and ends with */, this is | |
# accomplished with a stack, maybe. /* // */ counts as a single block of comments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.5.3 <=0.6.4; | |
contract Extension { | |
function blake2b256(bytes memory data) public view returns(bytes32); | |
function blockID(uint num) public view returns(bytes32); | |
function blockTotalScore(uint num) public view returns(uint64); | |
function blockTime(uint num) public view returns(uint); | |
function blockSigner(uint num) public view returns(address); | |
function totalSupply() public view returns(uint256); | |
function txProvedWork() public view returns(uint256); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.5.3 <=0.6.4; | |
// Crowd contract allows users | |
// to participate in a crowd funding in a limited time frame. | |
// Owner of the contract can decide: | |
// 1. Stop time of this round of crowd funding (using block.number). | |
// 2. If allow a user to deposit multiple times. | |
// 3. To which address withdraw the funds collected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from thor_requests.connect import Connect | |
from thor_requests.wallet import Wallet | |
connector = Connect("https://sync-testnet.vechain.org") | |
# wallet address: 0x7567d83b7b8d80addcb281a71d54fc7b3364ffed | |
_wallet = Wallet.fromPrivateKey(bytes.fromhex("dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65")) | |
# View the vtho this wallet has (in Wei): | |
vtho_balance = connector.get_vtho_balance(_wallet.getAddress()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CPU temperature | |
read temperature < /sys/class/thermal/thermal_zone0/temp | |
printf "CPU:\t%s °C\n" $(($temperature/1000)) | |
# Memory pressure | |
memtotal=0 | |
memfree=0 | |
while read -r name value unit; do | |
if [ "${name}" == "MemTotal:" ]; then | |
memtotal=${value} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
class MyInterface(abc.ABC): # Same as class MyInterface(metaclass=abc.ABCMeta) | |
def __init__(self, age: int): | |
print('MyInterface: init') | |
self.age = age | |
@abc.abstractmethod | |
def load_data(self, name: str): |