Skip to content

Instantly share code, notes, and snippets.

View evnchn's full-sized avatar
🪨
唆るぜこれは

Evan Chan evnchn

🪨
唆るぜこれは
View GitHub Profile
import os
import re
pattern = r"glib\.lib\(([^)]*)\)"
libraries = []
with open("list/firmware.map", "r") as f:
for line in f:
if "glib.lib" in line:
match = re.search(pattern, line)
@evnchn
evnchn / chart-exporter.js
Created September 13, 2023 14:14
[ALPHA] mai-tools chart export proof-of-concept
// Generated with Poe. Prompt here:
// https://poe.com/s/wo0SFXk51vRy5lYWOTKP
// meant to be used with "Analyze Rating" page of https://github.com/myjian/mai-tools
// ONLY after data has been loaded!!!
// Get all elements with class "songRecordTable"
const songTables = document.querySelectorAll(".songRecordTable");
// Initialize two empty arrays for the rating cells
#ifdef DEBUG_MODE
#define cout_debug std::cout
#else
#define cout_debug if (false) std::cout
#endif
export default {
template: `
<div class="w-full flex px-4 text-xs text-[#4F3028] text-center h-[32px]" ref="observerTarget">
<template v-if="isVisible">
<div class="flex w-full">
<div v-for="(checked, index) in day_checked" :key="'header-' + index" :class="{'font-bold': index === day_checked.length - 1, 'text-center': true, 'flex-grow': true, 'basis-0': true}">
{{ day_texts[index] }}
</div>
</div>
<div class="flex w-full">
from nicegui.element import Element
class MyRowSoftload(Element, component='my_row_softload.js'):
def __init__(self, *, day_texts=[], day_checked=[]) -> None:
super().__init__()
self._props["day_texts"] = day_texts
self._props["day_checked"] = day_checked
adg// NOTE: I only go so far as to ensure this works with the nicegui-speed
// Based on NiceGUI 2.12.1
const True = true;
const False = false;
const None = undefined;
let app = undefined;
let mounted_app = undefined;
from nicegui import ui
class my_widget:
def __init__(self, name, value):
self.name = name
self.value = value
self.container = ui.row()
self.create_widget()
print("__name__ is", __name__)
DEV = True # True for development with hot reload, False for production with no hot reload
from nicegui.ui_run import run as ui_run # just importing the function to run the server
if not DEV or not __name__ == "__main__": # you can do `if True:` to bypass this to revert to the normal behavior, but that is slow...
# Explanation: 2 reasons for running this code:
# 1. not in dev mode, so there is no __mp_main__, this is already where NiceGUI will run
# 2. or, in dev mode, and this is the __mp_main__, so we want to run this code
const True = true;
const False = false;
const None = undefined;
let app = undefined;
let mounted_app = undefined;
const loaded_libraries = new Set();
const loaded_components = new Set();
# Pieced together from:
# (1) https://github.com/Vizonex/Winloop?tab=readme-ov-file#how-to-use-winloop-with-fastapi
# (2) https://www.reddit.com/r/nicegui/comments/1dlx3or/fastapi_nicegui_integration/
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
import winloop
import uvicorn
import asyncio
import datetime
from nicegui import ui