Skip to content

Instantly share code, notes, and snippets.

View changkun's full-sized avatar
🏠
https://changkun.de

Changkun Ou changkun

🏠
https://changkun.de
View GitHub Profile
@changkun
changkun / app.yaml
Created November 23, 2020 09:30 — forked from akhenakh/app.yaml
Example of graceful shutdown with grpc healthserver * httpserver
readinessProbe:
exec:
command: ["/root/grpc_health_probe", "-addr=:6666"]
initialDelaySeconds: 1
livenessProbe:
exec:
command: ["/root/grpc_health_probe", "-addr=:6666"]
initialDelaySeconds: 2
imagePullPolicy: IfNotPresent
@changkun
changkun / foundation.go
Created November 20, 2020 05:31 — forked from 13k/foundation.go
Accessing Foundation Framework from Go with cgo
// How to build: "CC=clang go build"
package main
import (
"fmt"
"net/url"
"strconv"
"unsafe"
)

Problem

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.

Investigation

@changkun
changkun / getg.py
Created April 13, 2020 16:50 — forked from aclements/getg.py
$getg() function for gdb
import gdb
_Gdead = 6
class SliceValue:
"""Wrapper for slice values."""
def __init__(self, val):
self.val = val
@changkun
changkun / index.html
Created April 6, 2020 16:53
iframe dark
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<style>
body {
margin: 0;
}
container/list
golang.org/fake/a
golang.org/fake/b
* golang.org/fake/c
* golang.org/fake/e
* golang.org/fake/subdir/d
* golang.org/fake/subdir/d [golang.org/fake/subdir/d.test]
* golang.org/fake/subdir/d.test
* golang.org/fake/subdir/d_test [golang.org/fake/subdir/d.test]
math/bits
@changkun
changkun / caller.go
Created February 24, 2020 09:33
get caller
func getFrame(skipFrames int) runtime.Frame {
// We need the frame at index skipFrames+2, since we never want runtime.Callers and getFrame
targetFrameIndex := skipFrames + 2
// Set size to targetFrameIndex+2 to ensure we have room for one more caller than we need
programCounters := make([]uintptr, targetFrameIndex+2)
n := runtime.Callers(0, programCounters)
frame := runtime.Frame{Function: "unknown"}
if n > 0 {
fold -w 72 -s text.txt > text.txt
@changkun
changkun / x.go
Created January 19, 2020 16:53
go runtime print
var msg1 = []byte("message to be printed\n")
var msg2 = []byte("another message to be printed\n")
//go:nosplit
func printmsg() {
write(2, unsafe.Pointer(&msg1[0]), int32(len(msg1)))
}
//go:nosplit
func printmsg2() {
@changkun
changkun / all.md
Last active August 2, 2022 04:17
Go History

The Go History

This document includes all interesting issues, discussions, proposals, and CLs in the Go development history, which intents to offer a comprehensive reference of Go history.

Authors

Core Founders