Skip to content

Instantly share code, notes, and snippets.

View ktmud's full-sized avatar
🥌
Peace and Love~

Jesse Yang ktmud

🥌
Peace and Love~
View GitHub Profile
@ktmud
ktmud / __init__.py
Last active January 27, 2024 16:19
An extreme simple Python http server with auto reload and file-system based router
import os
from .app import start_cli_service
env = (os.environ.get("env") or "prod").lower()
is_dev = env == "dev" or env == "local"
port, autoreload_observer = start_cli_service(autoreload=is_dev)
if autoreload_observer:
# move autoreload observer to the foreground so process won't exit
@ktmud
ktmud / test.tex
Created October 20, 2017 20:27
Allow Greek letters in verbatim
\usepackage[utf8]{inputenc}
\usepackage{alphabeta}
\begin{document}
\begin{verbatim}
α β γ min
A 2.24 7.62 1.41 γ
B 0.00 8.06 3.61 α
C 8.06 0.00 7.21 β
@ktmud
ktmud / README.md
Last active March 9, 2023 01:37
Enable Okta Login for Superset

This Gist demonstrates how to enable Okta/OpenID Connect login for Superset (and with slight modifications, other Flask-Appbuilder apps).

All you need to do is to update superset_config.py as following and make sure your Cliend ID (OKTA_KEY) and Secret (OKTA_SECRET) are put into the env.

@ktmud
ktmud / cancel_github_workflows.py
Last active January 9, 2023 19:59
Manually cancel previous GitHub Action workflow runs in queue
#!/usr/bin/env python3
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@ktmud
ktmud / FlashingDots.tsx
Created September 8, 2022 05:13
Chakra UI FlashingDots
import {
chakra,
keyframes,
CSSObject,
ChakraProps,
useToken,
} from '@chakra-ui/react';
export type FlashingDotsProps = Pick<ChakraProps, 'width' | 'height'> & {
/**
@ktmud
ktmud / parse_email.py
Created August 17, 2017 19:34
Python 3.6 Parse Email Message
import re
import email.charset
from pathlib import Path
from glob import glob
from email import message_from_binary_file, policy
RE_QUOPRI_BS = re.compile(r'\b=20=\n')
RE_QUOPRI_LE = re.compile(r'\b=\n')
RE_LONG_WORDS = re.compile(r'\b[\w\/\+\=\n]{72,}\b')
@ktmud
ktmud / pastebin.sh
Last active June 26, 2022 01:34
Pastebin Bash Script.
#!/bin/bash
# Paste at Pastebin.com using command line (browsers are slow, right?)
# coder : Anil Dewani
# date : Novemeber 7, 2010
#help function
howto()
{
echo "\
Pastebin.com Bash Script \
@ktmud
ktmud / app.py
Created May 20, 2022 21:58
aiohttp server with file system based router
import pkgutil
from aiohttp import web
ALLOWED_METHODS = ["GET", "POST"]
def load_route_handlers(path, mod):
routes = []
for method in ALLOWED_METHODS:
if hasattr(mod, method):
@ktmud
ktmud / sqlalchemy_insert_from_select.py
Last active March 29, 2022 22:15
Understand how SQLAlchemy insert().from_select(..) works
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Model(Base):
__tablename__ = "model"
id = sa.Column("id", primary_key=True)
bbb = sa.Column("bbb")
@ktmud
ktmud / gulpfile.js
Last active February 28, 2022 10:39
An example gulpfile.js with bower components and live reload support
var BatchStream = require('batch-stream2')
var gulp = require('gulp')
var coffee = require('gulp-coffee')
var uglify = require('gulp-uglify')
var cssmin = require('gulp-minify-css')
var bower = require('gulp-bower-files')
var stylus = require('gulp-stylus')
var livereload = require('gulp-livereload')
var include = require('gulp-include')
var concat = require('gulp-concat')