Skip to content

Instantly share code, notes, and snippets.

View realmayus's full-sized avatar

Marius realmayus

View GitHub Profile
@realmayus
realmayus / caesar_cipher.py
Last active November 6, 2019 20:12
A simple self-written cipherer and decipherer written in python 3.x
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
mode = input("What mode? (c)ipher / (d)ecipher: ")
if mode == "c":
offset = input("Enter offset: ")
if not offset.isdigit():
print("\nOffset must be a positive Integer! Exiting...")
exit()
@realmayus
realmayus / EmailsToCSVcontacts.py
Last active February 11, 2020 21:30
Takes a list of Email addresses along with names in the format "Name Name <email@email.com>\n" and converts them to a CSV file that you can import into google contacts.
with open('contacts.csv', 'a') as newF:
newF.write('Name,"E-mail 1 - Value"\n')
newF.close()
with open('contacts.txt') as f:
for line in f:
name, email = line.split('<')
name = name[:-1]
email = email[:-3]
print("Name:" + name + ", Email: " + email + "\n")
with open('contacts.csv', 'a') as newF:
@realmayus
realmayus / unit1.pas
Created May 18, 2020 15:30
Informatik Wochenplan: Ampelschaltung
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
type
@realmayus
realmayus / setup-chime-vm.sh
Last active August 7, 2020 13:04
Whip up a VM for the chime discord bot
#!/bin/bash
cd /tmp/
curl -O https://download.java.net/java/GA/jdk13/5b8a42f3905b406298b72d750b6919f6/33/GPL/openjdk-13_linux-x64_bin.tar.gz
tar xvf openjdk-13_linux-x64_bin.tar.gz
sudo mv jdk-13 /opt/
sudo tee /etc/profile.d/jdk13.sh <<EOF
export JAVA_HOME=/opt/jdk-13
export PATH=\$PATH:\$JAVA_HOME/bin
EOF
source /etc/profile.d/jdk13.sh
@realmayus
realmayus / DataBuffer.js
Created June 15, 2020 15:36
Creates a DataBuffer object that is binary-compatible with Java's DataOutputStream, also sports a function that automatically creates a Lavaplayer-compatible base64 string. Example usage at the bottom.
class DataBuffer {
constructor() {
this.bytearr = [];
}
write(byte) {
this.bytearr.push(byte)
}
writeByteArray(byteArray) {
writeUTF8(str) {
let utf8 = []
let utflen = str.length; // optimized for ASCII
for (let i = 0; i < str.length; i++) {
let c = str.charAt(i);
if (c >= 0x80 || c === 0)
utflen += (c >= 0x800) ? 2 : 1;
}
@realmayus
realmayus / DataBuffer.js
Created June 30, 2020 10:59
A DataBuffer that's compatible with Java.
class DataBuffer {
constructor() {
this.bytearr = []
}
write(byte) {
this.bytearr.push(byte)
}
writeByteArray(byteArray) {
@realmayus
realmayus / chime.service
Last active August 7, 2020 13:18
A service file for the chime music bot.
[Unit]
Description=Chime
After=multi-user.target
[Service]
WorkingDirectory=%h/chime
ExecStart=%h/chime/venv/bin/chime
Type=idle
User=root
Group=root
Restart=always
@realmayus
realmayus / prepare_webapp_environment.sh
Created August 8, 2020 11:20
Set up web environment & install chime-web and chime-backend
GREEN='\033[0;32m'
NC='\033[0m'
echo -e "${GREEN}> Adding Ubuntu Universe to repositories & Updating package lists${NC}"
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository universe
sudo apt-get update
echo -e "${GREEN}> Installing nodejs & npm${NC}"
@realmayus
realmayus / pi_approx.py
Created August 31, 2020 17:12
Approximation of Pi using the Leibniz and the Nilkantha series, implemented in Python.
from decimal import *
getcontext().prec = 1000
# simple and beautiful but diverges slowly.
def leibniz():
prefactor = -1
pre_result = 1
current_index = 3