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 / keybase.md
Created April 16, 2019 02:27
keybase.md

Keybase proof

I hereby claim:

  • I am frostming on github.
  • I am frostming (https://keybase.io/frostming) on keybase.
  • I have a public key whose fingerprint is 1A21 DF26 CF48 7A9B 9E9B C482 7B28 4C8F CC08 5EFF

To claim this, I am signing this object:

@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 March 15, 2021 13:45
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 <mianghong@gmail.com>
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