Skip to content

Instantly share code, notes, and snippets.

View jxskiss's full-sized avatar

Shawn Wang jxskiss

  • ByteDance Inc.
  • Beijing
View GitHub Profile
@Petelin
Petelin / alloc.go
Created December 5, 2018 08:01
go堆外分配分区
# from https://www.zhihu.com/people/tou-gou-bao-da
package main
import (
"fmt"
"math"
"math/rand"
"reflect"
"runtime"
"sort"
@jsmouret
jsmouret / struct.go
Last active June 20, 2024 11:15
Convert map[string]interface{} to a google.protobuf.Struct
package pb
import (
"fmt"
"reflect"
st "github.com/golang/protobuf/ptypes/struct"
)
// ToStruct converts a map[string]interface{} to a ptypes.Struct
@titpetric
titpetric / client.lua
Created March 10, 2017 10:37
LUA FFI bridge to Go shared Lib
local ffi = require("ffi")
local awesome = ffi.load("./awesome.so")
ffi.cdef([[
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef double GoFloat64;
@liftoff
liftoff / json_cleaner.py
Created October 19, 2016 13:42
Allow comments and trailing commas in JSON files using two simple Python functions to clean them up before parsing
#!/usr/bin/env python
"""
An example of how to remove comments and trailing commas from JSON before
parsing. You only need the two functions below, `remove_comments()` and
`remove_trailing_commas()` to accomplish this. This script serves as an
example of how to use them but feel free to just copy & paste them into your
own code/projects. Usage::
json_cleaner.py some_file.json
@cespare
cespare / log.go
Created October 31, 2012 06:51
Golang apache logging
type ApacheLogRecord struct {
http.ResponseWriter
ip string
time time.Time
method, uri, protocol string
status int
responseBytes int64
elapsedTime time.Duration
}