Skip to content

Instantly share code, notes, and snippets.

@marekyggdrasil
marekyggdrasil / run_rtsp_raw.py
Created May 28, 2020 12:42
An example of a raw livestream pipeline generated from numpy array, based on https://github.com/jackersson/gstreamer-python/commit/98424f8c21bd84805313d8890d789e739d115ffa and to put it in context, I made this example for this issue https://github.com/jackersson/gst-python-tutorials/issues/4
#!/usr/bin/env python
# -*- coding:utf-8 vi:ts=4:noexpandtab
# Simple RTSP server. Run as-is or with a command-line to replace the default pipeline
import time
import sys
import abc
import numpy as np
import typing as typ
from fractions import Fraction
@marekyggdrasil
marekyggdrasil / diophantine.py
Last active April 17, 2023 00:32
Code repository for tutorial on constraint programming available on https://mareknarozniak.com/2020/06/22/constraint-programming/
from constraint import Problem
problem = Problem()
problem.addVariable('x', range(1, 10))
problem.addVariable('y', range(1, 10))
problem.addVariable('z', range(1, 10))
def constraintCheck(x, y, z):
@marekyggdrasil
marekyggdrasil / phi1.cnf
Last active July 13, 2020 15:06
CNF files for online tutorial covering the concept of SAT and boolean satisfiability in general, tutorial available under https://mareknarozniak.com/2020/07/13/satisfiability/
p cnf 3 3
1 -2 3 0
1 2 -3 0
-1 -2 3 0
@marekyggdrasil
marekyggdrasil / ecc.py
Last active November 16, 2021 12:39
Tutorial covering the concept of Elliptic Curve Cryptography and Diffie-Hellman Key Exchange, tutorial available under https://mareknarozniak.com/2020/11/30/ecdh/
import numpy as np
# ECC addition in R
def eccContAddition(Px, Py, Qx, Qy, a, b):
if np.isclose([Px], [Qx])[0]:
m = (3.*Px**2.+a)/(2.*Py)
else:
m = (Py-Qy)/(Px-Qx)
Rx = m**2 - Px - Qx
@marekyggdrasil
marekyggdrasil / index.js
Last active December 10, 2020 08:29
node.js example on how to connect to the grin-wallet owner API based on: it is a modified official example from here: https://github.com/mimblewimble/grin-wallet/tree/1ced8990b9e21fa17c788d93a151ec1164ebbce5/doc/samples/v3_api_node
/* Sample Code for connecting to the V3 Secure API via Node
*
* With thanks to xiaojay of Niffler Wallet:
* https://github.com/grinfans/Niffler/blob/gw3/src/shared/walletv3.js
*
*/
const http = require('http');
const crypto = require('crypto');
@marekyggdrasil
marekyggdrasil / plotting.py
Last active January 11, 2024 17:28
Tutorial covering the concept of geometric phase for a qubit, tutorial available under https://mareknarozniak.com/2021/01/09/qubit-berry-phase/
import matplotlib.pyplot as plt
def plotQubit(angles, refrel, refimag, resrel, resimag, title, x_axis, filename, url=''):
fig, ax = plt.subplots(1, 1, constrained_layout=True)
ax.set_title(title)
x_axis += '\n' + url
ax.set_xlabel(x_axis)
ax.set_ylabel('phase')
@marekyggdrasil
marekyggdrasil / distrib.png
Last active January 27, 2021 13:21
A source code for a probability plots for a trustless Mimblewimble transaction aggregator based on scalable BFT https://mareknarozniak.com/2021/01/27/aggrematon/
distrib.png
@marekyggdrasil
marekyggdrasil / ecdsa_knowledge.png
Last active September 12, 2021 14:53
Tutorial covering the Eliptic Curve Digital Signature Algorithm (ECDSA) available under https://mareknarozniak.com/2021/03/16/ecdsa/
ecdsa_knowledge.png
@marekyggdrasil
marekyggdrasil / aes.py
Last active April 24, 2021 10:36
Examples for tutorial on symmetric ciphers available under https://mareknarozniak.com/2021/04/22/symmetric/
from Crypto.Cipher import AES
from getpass import getpass
ciphertext = None
with open('ciphertext3.txt', 'r') as file:
ciphertext = bytes.fromhex(file.read())
password = getpass('Password: ')
key = bytes(password, 'ascii')
key = key + b'\x00'*(16-len(key))