Skip to content

Instantly share code, notes, and snippets.

View Juvar1's full-sized avatar

Juvar1

  • Turku, Finland
View GitHub Profile
@Juvar1
Juvar1 / ternary-math-test.py
Created May 24, 2023 03:14
Simulation program for ternary gates
# ternary-math-test.py
# Simulation program for ternary gates
#
# Copyright (C) 2023, Juha-Pekka Varjonen
#
#
# Internet is full of wrong and badly incorrect information about ternary operations.
# This simple program simulates NOT, NAND and NOR gates in all their states.
@Juvar1
Juvar1 / tinybasic.c
Last active July 25, 2023 03:00 — forked from pmachapman/tinybasic.c
A tiny BASIC Interpreter
/* A tiny BASIC interpreter */
// heavily modified from:
// https://gist.github.com/pmachapman/661f0fff9814231fde48
//
// Now it works with doubles instead of ints. Also fixed some bugs.
#include <string.h>
#include <stdio.h>
#include <setjmp.h>
@Juvar1
Juvar1 / pi.py
Last active August 27, 2020 12:37
Pi calculator using Bailey-Borwein-Plouffe formula
# PI calculator
#
# - Optimized for 8-bit microcontroller
# - To be translated to C-language
# - Tested up to 500 digits
#
# Original S function taken from
# http://pythonfiddle.com/bailey-borwein-plouffe-formula/
# Heavily modified afterwards
@Juvar1
Juvar1 / svf2xsvf.py
Created August 18, 2018 19:25
SVF is an file format that is used to describe JTAG chain operations. This script converts SVF ascii files to XSVF binary file format. No need to install Xilinx iMPACT software.
# converts SVF ascii files to XSVF binary file format
# usage: python svf2xsvf.py source.svf dest.xsvf
import sys
data = ["XCOMPLETE","XTDOMASK","XSIR","XSDR","XRUNTEST","","","XREPEAT",\
"XSDRSIZE","XSDRTDO","XSETSDRMASKS","XSDRINC","XSDRB","XSDRC","XSDRE",\
"XSDRTDOB","XSDRTDOC","XSDRTDOE","XSTATE","XENDIR","XENDDR",\
"XSIR2","XCOMMENT","XWAIT"]
@Juvar1
Juvar1 / run.py
Last active May 2, 2018 14:05 — forked from mumrah/run.py
Python script to decode AX.25 from KISS frames over a serial TNC without kiss module
import hexdump
import serial
import struct
def decode_addr(data, cursor):
(a1, a2, a3, a4, a5, a6, a7) = struct.unpack("<BBBBBBB", data[cursor:cursor+7])
hrr = a7 >> 5
ssid = (a7 >> 1) & 0xf
ext = a7 & 0x1