Skip to content

Instantly share code, notes, and snippets.

View qi7chen's full-sized avatar
🎯
Focusing

Johnnie qi7chen

🎯
Focusing
  • Ubisoft
  • Chengdu
View GitHub Profile
@qi7chen
qi7chen / parse_embed.py
Created June 14, 2024 03:06
parse_embed.py
# 解析嵌入类型的字段
def parse_one_embed(self, start: int) -> int:
all_range = []
gap_fields = []
end = start
last_elem_prefix = ''
for i in range(start, len(self.fields)):
field = self.fields[i]
prefix, idx = helper.parse_array_name_index(field.name)
if prefix != '' and idx == 0:
@qi7chen
qi7chen / gcdata.go
Created March 16, 2024 12:48
print golang type gcdata
func TestAABB(t *testing.T) {
t.Logf("size of map = %d", unsafe.Sizeof(map[int]int{}))
var a any = gsdb.DbUser{}
var typ = reflectutil.TypeOf(a)
var n = (int(typ.PtrBytes)/8 + 7) / 8
var sb strings.Builder
var ones = 0
for i := 0; i < n; i++ {
var ptr = unsafe.Add(unsafe.Pointer(typ.GCData), i)
var v = *(*uint8)(ptr)
@qi7chen
qi7chen / go-env-with-msys2.md
Created December 8, 2022 08:56 — forked from glycerine/go-env-with-msys2.md
Go development environment on Windows with MSYS2

Go development environment on Windows with MSYS2

Normally, it is sufficient to grab the Go MSI installer from the website in order to set up the toolchain. However, some packages that provide Go wrappers for C libraries rely on cgo tool, which in turn, needs the GCC toolchain in order to build the glue code. Also, 3rd-party dependencies are usually hosted on services like GitHub, thus Git is also needed. This mini-guide illustrates how to setup a convenient development environment on Windows using MSYS2.

import xlrd
import openpyxl
# 读取指定xls文件的某一个sheet
def read_workbook_sheet_to_rows(filename: str, sheet_name: str):
print('load workbook', filename)
if filename.endswith('.xls'):
return __xlrd_read_workbook_sheet_to_rows(filename, sheet_name)
@qi7chen
qi7chen / bigdigit.go
Created August 26, 2015 07:51
print big digit
package main
import (
"fmt"
"os"
"path/filepath"
)
var print = fmt.Println
@qi7chen
qi7chen / isNumber.c
Created May 14, 2015 09:30
Validate if a given string is numeric
// Validate if a given string is numeric.
// https://leetcode.com/problems/valid-number/
bool isNumber(const char* s)
{
if (s == NULL)
{
return false;
}
@qi7chen
qi7chen / poco_jni.cpp
Created December 10, 2014 07:44
poco http for jni
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class tutorial_myfirstapp_MainActivity */
#ifndef _Included_tutorial_myfirstapp_MainActivity
#define _Included_tutorial_myfirstapp_MainActivity
#ifdef __cplusplus
extern "C" {
#endif
/*
@qi7chen
qi7chen / coroutine_socket.lua
Last active August 29, 2015 14:10
coroutine based http download
local socket = require 'socket'
local coroutine = coroutine
local threads = {}
local function receive(connection)
connection:settimeout(0)
local s, status, partial = connection:receive(2^10)
if status == 'timeout' then
@qi7chen
qi7chen / prod_con.lua
Created November 29, 2014 09:56
lua coroutine producer/consumer
local coroutine = coroutine
local function receive(p)
local s, value = coroutine.resume(p)
return value
end
local function send(x)
coroutine.yield(x)
end
-- map(table, function)
-- e.g: map({1,2,3}, function(a) return a*2 end) -> {2,4,6}
function map(tbl, func)
local newtbl = {}
for i,v in pairs(tbl) do
newtbl[i] = func(v)
end
return newtbl
end