Skip to content

Instantly share code, notes, and snippets.

View moritz-t-w's full-sized avatar

Moritz Tim W. moritz-t-w

View GitHub Profile
@moritz-t-w
moritz-t-w / macos-pkl-install.sh
Created February 13, 2024 18:40
Macos PKL Install
#!/bin/bash
tag="0.25.2"
# Identify CPU architecture
architecture="$(uname -m)"
if [ "$architecture" == "arm64" ] || [ "$architecture" == "aarch64" ]; then
build="aarch64"
elif [ "$architecture" == "x86_64" ]; then
if sysctl -n sysctl.proc_translated > /dev/null 2>&1; then
# This is an ARM CPU running in translation mode
@moritz-t-w
moritz-t-w / BinaryFileCacheManager.ts
Last active January 23, 2024 10:18
Deno TypeScript Cache Manager
import { ReadWriteFileCacheManager } from "./FileCacheManager.ts";
/** Cache manager for raw binary files
*
* @property {string} filePath Path to the file whose contents are to be cached
* @property {Promise<Uint8Array>} dataPromise Asynchronous getter for data
* @property {Uint8Array} data Synchronous getter for data
* @property {Promise<void>} set Asynchronous setter for data
* @property {Uint8Array} data Synchronous setter for data
*/
@moritz-t-w
moritz-t-w / aicode.zsh
Last active February 10, 2024 09:07
ShellGPT Extras
#!/bin/zsh
## Generate code with Shell GPT's code role and watch it being written in VSCode
aicode() {
# Check if input is available from the pipe
if [ -t 0 ]; then
# If no input from pipe, pass only the prompt to the AI
sgpt --code "$@" | codium -
else
# If input is received from pipe, concatenate it with the provided prompt
@moritz-t-w
moritz-t-w / owl-install.sh
Last active September 14, 2023 15:49
OWL instalation and run scripts
git clone https://github.com/seemoo-lab/owl.git /tmp/owl
pushd /tmp/owl
git submodule update --init
git submodule update --remote --merge # see issue #77 on seemoo-lab/owl
mkdir build
cd build
cmake ..
make
sudo make install
popd
@moritz-t-w
moritz-t-w / server.py
Created August 29, 2023 14:33
Manual Webserver
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/for_me/', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
def index():
print(request.json)
response = input('Enter your full response as json:\n')
@moritz-t-w
moritz-t-w / GroupLog.ts
Created May 9, 2023 18:38
Simple (and incomplete) utility to allow for an (incomplete) analog to console.group() and console.groupEnd() in Deno's log lib
import { denoLog } from "https://deno.land/std@/log/mod.ts";
/** Singleton to keep track of the current groups */
class Groups {
private static _groups: string[] = [];
public static get groups() {
return Groups._groups;
}
@moritz-t-w
moritz-t-w / FindLowestMissingPositive.ts
Created March 23, 2023 17:11
just a neat solution we found to a challenge
/**
* Finds the lowest missing positive number in an array of numbers (quite efficiently).
*/
function findLowestMissingPositive(subject: Array<number>): number {
/**
* The iterator, which will be the lowest missing number after the loop.
*/
let x = -1; // start at -1 because we increment it before the first check
while (1) { // 1 = true
if (!subject.includes(++x)) { break; } // break if the next number isn't in the subject
@moritz-t-w
moritz-t-w / Repo Generator.ps1
Last active December 26, 2022 19:15
Creates a git / github / vscode repo with a basic structure
function New-Repo {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[string]$RepoName = "New Repo",
[Parameter(Mandatory = $false)]
[string]$License = "mit",
[Parameter(Mandatory = $false)]
@moritz-t-w
moritz-t-w / mergeTwins.js
Created November 30, 2022 15:09
Merge all repeated cells per column using jQuery
/**
* Find a cell at a given distance below the given cell.
* @param {jQuery} cell The origin cell below which to find the target.
* @param {number} steps The number of steps to take.
* @returns {jQuery} The target cell.
*/
function below(cell, steps) {
return cell.parent().nextAll().eq(steps - 1).children().eq(cell.index());
// Get the current row
// Step down the given amount of rows
@moritz-t-w
moritz-t-w / other32.options.txt
Last active July 25, 2022 08:23
Default options.txt files for Minecraft: Java Edition
version:3105
autoJump:true
autoSuggestions:true
chatColors:true
chatLinks:true
chatLinksPrompt:true
enableVsync:true
entityShadows:true
forceUnicodeFont:false
discrete_mouse_scroll:false