Skip to content

Instantly share code, notes, and snippets.

View phorward's full-sized avatar
🦎
Tokay!

Jan Max Meyer phorward

🦎
Tokay!
View GitHub Profile
# -*- coding: utf-8 -*-
import requests, sys, os, urllib
def getOrCreateDir(sess, host, parent, name):
folder = sess.get(host + "/vi/file/list/node",
params={
"node": parent,
"name": name.decode("utf-8")
}).json()
if folder["skellist"]:
@phorward
phorward / sort-index-yaml.py
Last active November 23, 2021 00:37
sort-index-yaml.py
from typing import Union
import yaml
import logging
def sort_yaml_file(file_name: str, dst_file_name: Union[str, None] = None):
if not dst_file_name:
dst_file_name = dst_file_name
with open(file_name, "r") as source_file:
@phorward
phorward / converter.py
Created May 15, 2020 09:49
pyodide-html5-number-system-converter.py
import math
from . import html5
def decimal_to_base(base, value):
"""
Converts decimal value into any base.
The base is defined by the number of digits in base.
"""
res = ""
@phorward
phorward / .htaccess
Created December 16, 2019 14:38
Pyodide server configuration to correctly serve application/wasm
# Apache Web Server
RewriteEngine off
Options -ExecCGI +Indexes
IndexOrderDefault Descending Date
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods GET
<FilesMatch "\.py$">
# -*- coding: utf-8 -*-
import requests, argparse, sys, csv
from collections import OrderedDict
if __name__ == "__main__":
host = "https://www.xxx.de/"
sess = requests.Session()
ret = sess.post(
@phorward
phorward / vm.c
Last active August 28, 2019 10:10
Demonstration of a simple stack virtual machine & assembler
/*
Demonstration of a simple stack virtual machine & assembler
Input:
lit 10
:loop
cpy
cpy
put
@phorward
phorward / expr.c
Last active August 28, 2019 09:50
Demonstration of a recursive descent parser
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* ~~~~~~~~~~~~~~~~~~AST~~~~~~~~~~~~~~~~~~ */
typedef enum {
NODETYPE_OPERATOR,
NODETYPE_NUMBER
@phorward
phorward / automatic-download.sh
Created July 26, 2019 12:30
App Engine Download Scripts
#!/bin/sh
PROBLEMS=""
for project in `gcloud projects list | cut -f 1 -d " "`
do
if [ "$project" == "PROJECT_ID" ]
then
continue
fi
@phorward
phorward / .bashrc
Created January 25, 2019 16:47
.bashrc with gcloud settings
####################
# Google Cloud SDK #
####################
GCLOUDSDKPATH="$HOME/bin/google-cloud-sdk"
# The next line updates PATH for the Google Cloud SDK.
if [ -f "$GCLOUDSDKPATH/path.bash.inc" ]
then
source "$GCLOUDSDKPATH/path.bash.inc"
BEGIN {
FS=";"
}
{
print "BEGIN:VCARD"
print "VERSION:2.1"
n = ""
cnt = split($1, parts, " ")