Skip to content

Instantly share code, notes, and snippets.

View ballgoesvroomvroom's full-sized avatar
🎐
stacks

whiteball ballgoesvroomvroom

🎐
stacks
View GitHub Profile
@ballgoesvroomvroom
ballgoesvroomvroom / Connect4.py
Last active June 12, 2022 05:24
Connect 4 within a single file, "4" is just a variable, can be "Connect 5" too
## Connect 4
import os
import re
import time
class Screen:
"""
Uses re module
"""
def clear():
@ballgoesvroomvroom
ballgoesvroomvroom / parser.py
Last active May 27, 2022 17:52
parser to parse entries in cc-cedict to store mapping of simplified characters to their corresponding pinyin with the correct unicode
import json
import re
LINE_SPLIT = re.compile("^.*?\s(.*?)\s\[(.*?)\].*?$") ## group 1 is the simplified, group 2 is the pinyin
TONE_MAP = {
"a": ["ā", "á", "ǎ", "à"],
"e": ["ē", "é", "ě", "è"],
"i": ["ī", "í", "ǐ", "ì"],
"o": ["ō", "ó", "ǒ", "ò"],
"u": ["ū", "ú", "ǔ", "ù"],
@ballgoesvroomvroom
ballgoesvroomvroom / .js
Last active May 23, 2022 11:17
maps exported save translations from translate.google.com (exported to google sheets) to a text file for custom parser of my own project
// uses cell range C1:D1 to the last row
// saves as "englishWord : chineseWord : source (translate.google.com)" for parser to interpret
function saveToTextfile() {
var ss = SpreadsheetApp.getActive();
var sh = ss.getActiveSheet();
var rg = sh.getRange(1, 3, sh.getLastRow(), 2);
var vs = rg.getValues();
console.log(vs)
// format data
@ballgoesvroomvroom
ballgoesvroomvroom / convert.py
Last active May 23, 2022 11:21
integers to roman numerals
ordered = [
1, 5, 10, 50, 100, 500, 1000
]
mapping = {
1: "I",
5: "V",
10: "X",
50: "L",
100: "C",
500: "D",