Skip to content

Instantly share code, notes, and snippets.

View ravener's full-sized avatar
❤️
owo

Ravener ravener

❤️
owo
View GitHub Profile
@ravener
ravener / vowels.py
Last active June 18, 2024 15:49
Count the number of vowels in a word
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import unittest
vowels: list[str] = ["a", "e", "i", "o", "u"]
def count_vowels(word: str) -> int:
"""
Counts the vowels in a given word.
@ravener
ravener / rot13.py
Created June 9, 2024 08:51
ROT13 in Python and Rust
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import sys
def generate_table() -> dict[str, str]:
"""
Generates a look up table for mapping characters to their ROT13 character.
"""
input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
@ravener
ravener / bf.py
Created May 12, 2024 11:17
Brainfuck Interpreter in Python
#!/usr/bin/python3
# -*- coding: utf8 -*-
import sys
from argparse import ArgumentParser
from pathlib import Path
def compute_jump_table(instructions: str) -> dict[int, int]:
"""
@ravener
ravener / det.py
Last active October 8, 2022 18:23
Calculate determinant of an n × n matrix in Python
# Get the submatrix of A
# Removing the ii-th row and jj-th column
def sub(A, ii, jj):
matrix = []
for i in range(len(A)):
if i == ii:
continue
@ravener
ravener / changelog.sh
Created June 24, 2022 07:58
Generate CHANGELOG.md from git tags
#!/usr/bin/bash
# A bash script to generate a markdown changelog from git tags
# Run this inside a git repository to generate CHANGELOG.md file
if [ ! -d ".git" ]; then
echo "Error: Not a git repository"
exit 1
fi
@ravener
ravener / vm.js
Created June 29, 2018 18:03
Virtual Machine in JavaScript
/*
MIT License
Copyright (c) 2018 Free TNT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is