Skip to content

Instantly share code, notes, and snippets.

View Breta01's full-sized avatar
🤹
All over the place

Bretislav Hajek Breta01

🤹
All over the place
View GitHub Profile
@Breta01
Breta01 / FELT Load Model.py
Last active April 19, 2023 04:12
Sample of loading model using FELT Labs
from feltlabs.model import load_model
# Load scikit-learn model
model = load_model("final-model-House Prices.json")
# Data shape must be: (number_of_samples, number_of_features)
data = [
[1980, 2, 2, 2, 0, 0],
[1700, 3, 2, 3, 1, 1],
[2100, 3, 2, 3, 1, 0],
@Breta01
Breta01 / House Prices - part 2.csv
Created August 17, 2022 02:30
Actual data used for FELT demonstration
1980 2 2 2 0 0 115900
1700 3 2 3 1 1 107500
2100 3 2 3 1 0 151100
1860 2 2 3 0 1 91100
2150 2 3 4 0 1 117400
2100 3 2 3 0 1 130800
1650 3 2 3 0 1 81300
1720 2 2 2 1 0 125700
2190 3 2 3 1 0 140900
2240 4 3 3 0 2 152300
@Breta01
Breta01 / House Prices - part 1.csv
Created August 17, 2022 02:26
Actual data used for FELT demonstration
1790 2 2 2 0 0 114300
2030 4 2 3 0 0 114200
1740 3 2 1 0 0 114800
1980 3 2 3 0 0 94700
2130 3 3 3 0 0 119800
1780 3 2 2 0 1 114600
1830 3 3 3 1 2 151600
2160 4 2 2 0 2 150700
2110 4 2 3 0 0 119200
1730 3 3 3 0 0 104000
@Breta01
Breta01 / House Prices Example.csv
Last active April 15, 2023 08:40
Example of House Prices dataset
SqFt Bedrooms Bathrooms Offers Brick Neighborhood Price
1790 2 2 2 0 0 114300
2030 4 2 3 0 0 114200
1740 3 2 1 0 0 114800
1980 3 2 3 0 0 94700
2130 3 3 3 0 0 119800
1780 3 2 2 0 1 114600
1830 3 3 3 1 2 151600
2160 4 2 2 0 2 150700
2110 4 2 3 0 0 119200
@Breta01
Breta01 / empty
Created July 20, 2022 06:54
Empty file
// Empty alg file
1 2 3
2 3 4
2 3 4
2 3 4
2 3 4
2 3 4
@Breta01
Breta01 / File server with smart contracts deployment.py
Last active April 23, 2022 05:31
File server with smart contracts deployment
import http.server
from pathlib import Path
# Get root directory
ROOT = Path(__file__).parent.parent
# Class for serving build directory
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
@Breta01
Breta01 / Github action deploy.yaml
Created April 23, 2022 03:55
Example of action for deploying smart contracts.
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "**.sol"
name: Deploy to testnet
@Breta01
Breta01 / Python implementation of Encryption - Decryption.py
Created March 11, 2022 15:26
Python implementation of Encryption and Decryption functions matching with MetaMask
"""Module for encryption and decryption compatible with MetaMask."""
from base64 import a85decode, a85encode
# PyNaCl==1.5.0
from nacl.public import Box, PrivateKey, PublicKey
def _hex_to_bytes(hex: str) -> bytes:
return bytes.fromhex(hex[2:] if hex[:2] == "0x" else hex)
@Breta01
Breta01 / Decryption function.ts
Last active March 11, 2022 15:04
Decrypting data with MetaMas
const ascii85 = require('ascii85');
async function decryptData(account: string, data: Buffer): Promise<Buffer> {
// Reconstructing the original object outputed by encryption
const structuredData = {
version: 'x25519-xsalsa20-poly1305',
ephemPublicKey: data.slice(0, 32).toString('base64'),
nonce: data.slice(32, 56).toString('base64'),
ciphertext: data.slice(56).toString('base64'),
};