Skip to content

Instantly share code, notes, and snippets.

View frostming's full-sized avatar

Frost Ming frostming

View GitHub Profile
# Under UIVariables directory
title = "Main Window"
@frostming
frostming / __init__.py
Created March 31, 2018 03:31 — forked from nitely/__init__.py
Python Markdown parser
# -*- coding: utf-8 -*-
# Copyright (c) 2017 by Esteban Castro Borsani.
# Released under MIT license
from .elements import (
Header,
Quote,
HRule,
UListItem,
@frostming
frostming / README.md
Last active March 19, 2019 03:11
Simple CORS example with Flask

A simple example of CORS & Ajax with Flask

Requirements

$ pipenv install flask flask-cors

Start development server

@frostming
frostming / app.py
Last active September 7, 2019 01:39
Simple Flask APP with Dispatcher
import flask
from flask_login import LoginManager, UserMixin, login_user, logout_user
from flask_sqlalchemy import SQLAlchemy
from werkzeug.middleware.dispatcher import DispatcherMiddleware
settings = {
"SECRET_KEY": "hesdfdsfklj;l",
"SQLALCHEMY_DATABASE_URI": "sqlite:///db.sqlite3",
}
@frostming
frostming / api.js
Last active March 22, 2023 14:18
Flask WTF cookie based CSRF
// npm i js-cookie --save
import axios from 'axios'
import Cookies from 'js-cookie'
const api = axios.create({
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': Cookies.get('csrf_token')
})
@frostming
frostming / promise.py
Last active June 16, 2024 18:17
Python implementation of JavaScript's Promise interface
"""
Python implementation of JavaScript's Promise interface
with the power of asyncio.
See https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise
for the API specification.
Authored by: Frost Ming <[email protected]>
License: WTFPL
"""
@frostming
frostming / napkin.py
Created April 30, 2021 03:28
Cusdis Telegram Bot
from napkin import response, request
import requests
import json
TELEGRAM_BOT_TOKEN = 'xxxxxx'
TELEGRAM_CHAT_ID = 'xxxxx'
def format_message(data):
"""data example:
@frostming
frostming / iterm_image.py
Last active March 3, 2022 05:41
Render image in iTerm2
"""
Render Image in iTerm2 without pixelization
This small snippet is ported from https://github.com/sindresorhus/ansi-escapes.
It leverages iTerm2's image protocol: https://iterm2.com/documentation-images.html
so it only works on iTerm2.
Released to the public domain, feel free to copy and modify.
- Frost Ming
"""
name: Add to Journal
on:
workflow_dispatch:
inputs:
text:
description: Add a single item to Logseq journal
type: string
required: true
@frostming
frostming / fly.toml
Last active October 13, 2023 03:33
A Fly.io config file for OpenCat™ for Team that can be deployed directly
# fly.toml file generated for still-snowflake-6351 on 2023-03-30T09:53:40+08:00
kill_signal = "SIGINT"
kill_timeout = 5
primary_region = "sin"
processes = []
[build]
image = "bayedev/opencatd"