Skip to content

Instantly share code, notes, and snippets.

Working from home

Changkun Ou changkun

Working from home
View GitHub Profile
changkun / hotkey.go
Created Feb 27, 2021 — forked from koenbollen/hotkey.go
Commandline hotkey tool. Usage: `hotkey F12 say hello`
View hotkey.go
package main
// #cgo LDFLAGS: -framework Carbon
// #include <Carbon/Carbon.h>
// extern void Callback();
// void RunApplicationEventLoop();
// static inline OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData)
// {
// Callback();
// return 1;
View reference.cpp
#include <iostream>
#include <fstream>
#include <windows.h>
#include <string>
#include <iomanip>
#include <sstream>
int width = 2;
int height = 2;
int32_t bitmap2x2[4] = { 0xffff0000, 0xff00ff00, 0xff0000ff, 0x00000000 };
changkun /
Created Feb 15, 2021 — forked from unbracketed/
Moving commits between branches

Example: Moving up to a few commits to another branch

Branch A has commits (X,Y) that also need to be in Branch B. The cherry-pick operations should be done in the same chronological order that the commits appear in Branch A.

cherry-pick does support a range of commits, but if you have merge commits in that range, it gets really complicated

git checkout branch-B
git cherry-pick X
git cherry-pick Y
changkun /
Last active Dec 24, 2020
为 Hexo 博客文章分配全局唯一 ID
import yaml
import glob
import time
POST_DIR = 'source/_posts/'
def loader():
posts = glob.glob(POST_DIR + '*.md')
settings = []
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:


start new with session name:


Compile Go for Apple Silicon (M1)

Follow these short instructions on how to compile Go for Apple Silicon (M1). From here on out, we may simply refer to it as the "ARM device".

This entire process should only take about 5-10 minutes, but please read through everything carefully, in order to avoid any potential issues along the way.

Note that at the time of writing this, Go was not yet officially available for Apple's ARM.

Additionally it should be noted that this guide expects you to only be working on the ARM device, and not to have Go installed (yet).

changkun / app.yaml
Created Nov 23, 2020 — forked from akhenakh/app.yaml
Example of graceful shutdown with grpc healthserver * httpserver
View app.yaml
command: ["/root/grpc_health_probe", "-addr=:6666"]
initialDelaySeconds: 1
command: ["/root/grpc_health_probe", "-addr=:6666"]
initialDelaySeconds: 2
imagePullPolicy: IfNotPresent
changkun / foundation.go
Created Nov 20, 2020 — forked from 13k/foundation.go
Accessing Foundation Framework from Go with cgo
View foundation.go
// How to build: "CC=clang go build"
package main
import (
View A hack for showing LaTeX formulas in GitHub


A lot of GitHub projects need to have pretty math formulas in READMEs, wikis or other markdown pages. The desired approach would be to just write inline LaTeX-style formulas like this:

$e^{i \pi} = -1$

Unfortunately, GitHub does not support inline formulas. The issue is tracked here.


changkun /
Created Apr 13, 2020 — forked from aclements/
$getg() function for gdb
import gdb
_Gdead = 6
class SliceValue:
"""Wrapper for slice values."""
def __init__(self, val):
self.val = val