Skip to content

Instantly share code, notes, and snippets.

View MitchiLaser's full-sized avatar

Michael Hohenstein MitchiLaser

View GitHub Profile
@MitchiLaser
MitchiLaser / mint_download.sh
Created October 25, 2024 11:55
Linux Mint download latest release
#!/bin/bash
# This scripts fetches the latest Linux Mint ISO file with Cinnamon desktop for 64bit systems
# and stores the iso file in a temporary file. The script also checks the sha256 checksum of the
# downloaded file and returns the path to the file if the checksum is correct. Otherwise the
# script returns an error code.
#
# To get the newest version of Linux Mint, the script fetches the content of the download page of a local mirrot
# and extracts the version numbers from the links to get the highest version number.
@MitchiLaser
MitchiLaser / fib.tcl
Created September 6, 2024 08:38
TCL upvar abuse
#!/usr/bin/tclsh
# TCL has its unique `upvar` method to map a variable from
# a superiour scope to a local variable.
# This makes it possible to access the values of previous
# iterations in recursive functions
proc fib {stop {step 0}} {
if {$step < 2} {
set result [expr $step == 0 ? 0 : 1] ;# first two values

VHDL Cheat-Sheet

Basic Structure

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
@MitchiLaser
MitchiLaser / main.cpp
Created March 6, 2024 10:06
Recursive lambda calculating Fibonacci number in C++
#include <iostream>
#include <cstdlib>
int main( int argc, char* argv[]) {
typedef unsigned long long int num_type;
std::cout << [](auto lambda, num_type number) -> num_type { return lambda(lambda, number); } ([](auto lambda, num_type number) -> num_type { return number <= 2 ? num_type(1) : lambda(lambda, number-1) + lambda(lambda, number-2); }, std::atoi(argv[1])) << std::endl;
return EXIT_SUCCESS;
}
@MitchiLaser
MitchiLaser / python_recursive_lambdas.ipynb
Last active February 28, 2024 08:16
How to write recursive lambdas in Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MitchiLaser
MitchiLaser / fourier.py
Created November 9, 2023 11:04
Visualisation of the fourier transform of a square wave
#!/usr/bin/env python3
"""
Create a Matplotlib window which shows the fourier transform of a square wave signal.
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider
import math
@MitchiLaser
MitchiLaser / Makefile
Created October 10, 2023 13:02
lp and lpr wrapper to disable -U command line argument
CC=g++
main:
$(CC) -D LP main.cpp -o lp
$(CC) -D LPR main.cpp -o lpr
clean:
rm lp_wrapper
rm lpr_wrapper
@MitchiLaser
MitchiLaser / vm.sh
Created October 10, 2023 12:51
QEMU VM Startup script
#!/bin/bash
# This is a script which uses QEMU to start a VM or set up the VM with a pre-defined installer
# when the virtual hard-drive cannot be found. It was made to quickly recreate a new VM in case
# the old one was deleted (maybe because someone messed arround with it)
# All the arguments QEMU needs to start the VM with the right parameters
# are also stored in this script and can be modified.
# The default OS installer is currently a Link to the OpenSUSE net installer
@MitchiLaser
MitchiLaser / morse.ino
Created October 10, 2023 11:50
Arduino Morse code
/*
* Arduino Morse message
*
* (c) Michael Hohenstein
* MIT License
*
* This code takes the string <Text> and translates it into morse code.
* When an LED is attached at Pin <LedPin> , the LED blinks to emit the
* message in Morse code.
*/