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
#!/usr/bin/env pybricks-micropython | |
""" | |
Example LEGO® MINDSTORMS® EV3 Robot Educator Driving Base Program | |
----------------------------------------------------------------- | |
This program requires LEGO® EV3 MicroPython v2.0. | |
Download: https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3 | |
Building instructions can be found at: |
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 fastapi import FastAPI, BackgroundTasks, Request | |
import uvicorn | |
import requests | |
import asyncio | |
import logging | |
import sys | |
from models import * | |
from blockchain.db import DB | |
from blockchain.blockchain import Blockchain |
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 .blocks import Block, Tx, Input, Output | |
from .verifiers import TxVerifier, BlockOutOfChain, BlockVerifier, BlockVerificationFailed | |
import logging | |
logger = logging.getLogger('Blockchain') | |
class Blockchain: | |
__slots__ = 'max_nonce', 'chain', 'unconfirmed_transactions', 'db', 'wallet', 'on_new_block', 'on_prev_block', 'current_block_transactions', 'fork_blocks' |
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 rsa | |
import binascii | |
from .wallet import Address | |
class TxVerifier: | |
def __init__(self, db): | |
self.db = db | |
def verify(self, inputs, outputs): |
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 time | |
from hashlib import sha256 | |
from merkletools import MerkleTools | |
from .wallet import Address | |
class Input: | |
__slots__ = 'prev_tx_hash', 'output_index', 'signature', '_hash', 'address', 'index', 'amount' |
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 rsa | |
import binascii | |
class Address: | |
def __init__(self, addr): | |
if isinstance(addr, rsa.PublicKey): | |
self.addr = addr | |
else: | |
if isinstance(addr,str): |
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 sklearn.datasets import make_blobs | |
from collections import defaultdict | |
# Generate sample data | |
n_samples = 4000 | |
n_components = 4 | |
X, y_true = make_blobs(n_samples=n_samples, | |
centers=n_components, | |
cluster_std=0.99, |
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 matplotlib.pyplot as plt | |
import numpy as np | |
from sklearn import datasets, linear_model | |
from sklearn.metrics import mean_squared_error, r2_score | |
# Load the diabetes dataset | |
diabetes_X, diabetes_y = datasets.load_diabetes(return_X_y=True) | |
# Use only one feature | |
diabetes_X = diabetes_X |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
class Conv2d(nn.Module): | |
def __init__(self, inch, outch, kernel, padding=0, stride=1): | |
super(Conv2d, self).__init__() | |
# setting our kernels with random normal |
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
var a = document.querySelectorAll('.msg-selectable-entity');for (var i=0;i<=a.length;i++){a[i].click();}; | |