Skip to content

Instantly share code, notes, and snippets.

View timothyqiu's full-sized avatar

Haoyu Qiu timothyqiu

View GitHub Profile
@timothyqiu
timothyqiu / map-capslock-to-ctrl.reg
Created March 22, 2020 07:38
Maps CAPSLOCK to CTRL (restart is needed after using this)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
@timothyqiu
timothyqiu / math.patch
Last active March 12, 2020 06:55
Math support patch for PHP Markdown Extra 1.2.8
--- markdown.php 2013-11-30 00:09:34.000000000 +0800
+++ markdown.php 2020-03-12 14:54:15.000000000 +0800
@@ -41,6 +41,9 @@
# setting this to true will put attributes on the `pre` tag instead.
@define( 'MARKDOWN_CODE_ATTR_ON_PRE', false );
+# Optional class attribute for math.
+@define( 'MARKDOWN_MATH_CLASS', "" );
+
@timothyqiu
timothyqiu / dnspod.py
Created October 24, 2019 13:08
简易 dnspod.cn API 客户端
import urllib.parse
import requests
class DnspodException(Exception):
pass
class DnspodErrorResponse(DnspodException):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char const encode_map[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"01234567890+/";
char *base64_encode(char const *data, size_t size);
char *base64_decode(char const *code, size_t *size);
@timothyqiu
timothyqiu / roman.cc
Created March 12, 2015 05:10
将 1~3999 内的整数正确转换至罗马数字
#include <algorithm>
#include <cassert>
#include <string>
std::string toRoman(int number)
{
static struct {
int value;
char const *symbols;
} const mapping[] = {
#include <algorithm>
#include <iostream>
#include <map>
#include <unordered_map>
// MapTraits<MapType, KeyType1, KeyType2, KeyType3...>
// ---------------------------------------------------
// 连续使用 KeyType1, KeyType2, KeyType3... 对 MapType 进行取 Value 操作后的信息
template <typename MapType, typename KeyType, typename... KeyTypes>
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <windows.h> // 各种位图数据结构
class Converter
{
public:
Converter() : pixels_(NULL), width_(0), height_(0) {}