Skip to content

Instantly share code, notes, and snippets.

View ckytam's full-sized avatar
💭
I may be slow to respond.

ckytam ckytam

💭
I may be slow to respond.
  • China
View GitHub Profile
@ckytam
ckytam / LuaClassBinding.cpp
Created May 5, 2024 02:28 — forked from kklouzal/LuaClassBinding.cpp
Binding A C++ Class To Lua The Manual Way (shared_ptr memory management)
#include <lua.hpp> // LuaJIT header
#include <iostream> // Access to std::system("PAUSE")
#include <memory>
// A simple class to be bound in our Lua environment.
class MyClass
{
public:
MyClass()
{
@ckytam
ckytam / udpProxy.go
Created June 19, 2023 11:39 — forked from mike-zhang/udpProxy.go
Implementation of a UDP proxy in Golang
// Implementation of a UDP proxy
package main
import (
"flag"
"fmt"
"log"
"net"
"os"
@ckytam
ckytam / geektime.user.js
Created July 27, 2022 08:57 — forked from Rand01ph/geektime.user.js
让极客时间的内容可以复制
// ==UserScript==
// @name geektime copy
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 让极客时间的内容可以复制!
// @author Rand01ph
// @match https://time.geekbang.org/column/*
// @grant none
// @require http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js
// ==/UserScript==
@ckytam
ckytam / astar.lua
Created July 28, 2020 11:30 — forked from Luca-spopo/astar.lua
A* search, agnostic of the representation of a node. Node doesn't have to be a table, and the code doesn't generate garbage.
--Written by Luca aka spopo on 6/Sep/17
--Implementation based on pseudocode from wikipedia
--TODO: Use an actual heap instead of this array
local function pop(heap, F) --pop minimum F, return reference
local min = F[heap[1]]
local mini = 1
for i=2,#heap do
if F[heap[i]] < min then
@ckytam
ckytam / CMakeLists.txt
Created March 18, 2020 14:34 — forked from hpcx82/CMakeLists.txt
Build lua with cmake
cmake_minimum_required (VERSION 2.6)
project (lua) # project here actually means solution in premake
if(WIN32)
add_definitions( -D_CRT_SECURE_NO_WARNINGS )
endif()
# 1. lua static library
# how to rename library name?
add_library (lualib STATIC lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c)
@ckytam
ckytam / tokio-internals.md
Created June 28, 2019 03:53 — forked from weihanglo/tokio-internals.md
【譯】Tokio 內部機制:從頭理解 Rust 非同步 I/O 框架

本文譯自 [Tokio internals: Understanding Rust's asynchronous I/O framework from the bottom up][tokio-internals]。
Thanks [David Simmons][david-simmons] for this awesome article!

[Tokio][tokio] 是 Rust 的開發框架,用於開發非同步 I/O 程式(asynchronous I/O,一種事件驅動的作法,可實現比傳統同步 I/O 更好的延伸性、效能與資源利用)。可惜的是,Tokio 過於精密的抽象設計,招致難以學習的惡名。即使我讀完教程後,依然不認為自己充分內化這些抽象層,以便推斷實際發生的事情。

從前的非同步 I/O 相關開發經驗甚至阻礙我學習 Tokio。我習慣使用作業系統提供的 selection 工具(例如 Linux epoll)當作起點,再轉移至 dispatch、state machine 等等。倘若直接從 Tokio 抽象層出發,卻沒有清楚了解 epoll_wait() 在何處及如何發生,我會覺得難以連結每個概念。Tokio 與 future-driven 的方法就好像一個黑盒子。