Skip to content

Instantly share code, notes, and snippets.

View aunyks's full-sized avatar
Increasing potential

Gerald Nash aunyks

Increasing potential
View GitHub Profile
@aunyks
aunyks / latex-gen.py
Last active May 10, 2022 00:59
A Python program for generating LaTeX expressions.
import matplotlib.pyplot as plt
import sympy
limxtoinf = sympy.Symbol('\lim_{x\\to\infty}')
# THE LATEX EXPRESSION TO BE PRINTED
expr = sympy.latex(limxtoinf)
# OR
#expr = '\lim_{x\\to\infty}'
@aunyks
aunyks / graph.py
Created February 5, 2017 18:54
A Python program for graphing functions, plotting, points, etc.
import matplotlib.pyplot as plt
import numpy as np
## Create functions and set domain length
x = np.arange(0.0, 2.0, 0.01)
y = x**2
dy = 2*x - 1
## Plot functions and a point where they intersect
plt.plot(x, y)
@aunyks
aunyks / large-file-hash.py
Last active August 23, 2023 06:59
Hash a large file in Python
import hashlib as hash
# Specify how many bytes of the file you want to open at a time
BLOCKSIZE = 65536
sha = hash.sha256()
with open('kali.iso', 'rb') as kali_file:
file_buffer = kali_file.read(BLOCKSIZE)
while len(file_buffer) > 0:
sha.update(file_buffer)
@aunyks
aunyks / snakecoin-block.py
Last active March 8, 2024 18:49
The block structure for SnakeCoin.
import hashlib as hasher
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
self.hash = self.hash_block()
import datetime as date
def create_genesis_block():
# Manually construct a block with
# index zero and arbitrary previous hash
return Block(0, date.datetime.now(), "Genesis Block", "0")
def next_block(last_block):
this_index = last_block.index + 1
this_timestamp = date.datetime.now()
this_data = "Hey! I'm block " + str(this_index)
this_hash = last_block.hash
return Block(this_index, this_timestamp, this_data, this_hash)
# Create the blockchain and add the genesis block
blockchain = [create_genesis_block()]
previous_block = blockchain[0]
# How many blocks should we add to the chain
# after the genesis block
num_of_blocks_to_add = 20
# Add blocks to the chain
for i in range(0, num_of_blocks_to_add):
import hashlib as hasher
import datetime as date
# Define what a Snakecoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
{
"from": "71238uqirbfh894-random-public-key-a-alkjdflakjfewn204ij",
"to": "93j4ivnqiopvh43-random-public-key-b-qjrgvnoeirbnferinfo",
"amount": 3
}
from flask import Flask
from flask import request
node = Flask(__name__)
# Store the transactions that
# this node has in a list
this_nodes_transactions = []
@node.route('/txion', methods=['POST'])
def transaction():