Skip to content

Instantly share code, notes, and snippets.

View foreverbell's full-sized avatar
🐻
Pooh!

foreverbell foreverbell

🐻
Pooh!
View GitHub Profile
#!/usr/bin/env python
# https://github.com/will62794/tlaplus_repl
import cmd
import os
import subprocess
import tempfile
TEMPLATE = """
@foreverbell
foreverbell / fmt-all.py
Created April 5, 2018 03:59
fmt-all.py
#!/usr/bin/env python
import distutils.spawn
import os, os.path
import subprocess
class Formatter(object):
def __init__(self, suffixes, exes, args):
self.suffixes = suffixes
self.name = exes[0]
@foreverbell
foreverbell / lean.lean
Last active February 1, 2018 03:44
Lean
#check true
constant m : nat
#check m
#check nat
#check Type 0
#check Type 100
@foreverbell
foreverbell / captial-crawler.py
Created October 3, 2014 12:13
A utility to fetch all countries' captial.
#!/usr/bin/env python
# encoding: utf-8
import urllib2, re, json, random
url = 'http://www.tripmondo.com/magazine/facts-and-statistics/list-of-capitals-and-countries/'
html = urllib2.urlopen(url, timeout=5).read()
reg = re.compile('<td><a href=.*?>(.*?)</a></td>\s+<td><a href=.*?>(.*?)</a></td>\s+<td class="right">(.*?)</td>\s+<td class="right">(.*?)</td>')
with open('city.json', 'w') as f :
@foreverbell
foreverbell / git-modules-recover.py
Created August 17, 2014 05:27
Recover git submodules from .gitmodules
#!/usr/bin/env python
# encoding: utf-8
import ConfigParser
import sys
import StringIO
data = StringIO.StringIO('\n'.join(line.strip() for line in open(".gitmodules", "r")))
config = ConfigParser.SafeConfigParser()
config.readfp(data)
@foreverbell
foreverbell / latex-template-pandoc.tex
Created August 17, 2014 05:24
Latex template for pandoc
% https://github.com/tzengyuxio/pages/blob/gh-pages/pandoc/pm-template.latex
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$]{$documentclass$}
\usepackage{geometry} % 設定邊界
\geometry{
top=1in,
inner=1in,
outer=1in,
bottom=1in,
headheight=3ex,
@foreverbell
foreverbell / hack-IME.cpp
Last active October 28, 2015 07:23
在 Windows8 里重映射 <Ctrl-Space> 快捷键以实现切换输入法功能。设置开机自动启动即可。
#include <Windows.h>
#include <Winuser.h>
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine,
_In_ int nCmdShow) {
RegisterHotKey(NULL, 1, MOD_CONTROL, VK_SPACE);