Skip to content

Instantly share code, notes, and snippets.

@kurapica
kurapica / UnitTest_Interceptor.lua
Created February 8, 2023 06:18
The Interceptor used for unit test, replace the global api in modules
require "PLoop"
require "PLoop.System.UnitTest"
-- Function defintion in _G
function UnitName()
return "player"
end
-- Define an interceptor
PLoop(function(_ENV)
@kurapica
kurapica / nginx.conf
Created September 20, 2022 05:41
A simpe mqtt broker with redis support to show the active clients
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
lua_shared_dict plbr_session_storage 10m;
require "PLoop" (function(_ENV)
-- Declare the namespace
_G.Defold = namespace "Defold"
-- Register it as global, so can be easily accessed
Environment.RegisterGlobalNamespace(Defold)
-- Define the base script class
__Sealed__()
class "Script" (function(_ENV)
Scorpio "Test" (function(_ENV)
function FillPolygon(points)
-- Calc the center point
local n = #points
if n < 3 then return end
local cx, cy = 0, 0
for i = 1, n do
Scorpio "AshToAshSkin" ""
pcall(Style.RegisterSkin, "5MSkin")
DEFAULT_COLOR = Color("|c222222ff")
LOW_HEALTH_COLOR = Color.WHITE
HEALTHBAR = (Scorpio.IsRetail or Scorpio.IsBCC or IsAddOnLoaded("LibHealComm-4.0") or pcall(_G.LibStub, "LibHealComm-4.0")) and "PredictionHealthBar" or "HealthBar"
Style.UpdateSkin("5MSkin", {
[AshToAsh.AshUnitFrame] = {
@kurapica
kurapica / async.lua
Created July 19, 2021 01:58
Full thread pool support func and iterator
local create = coroutine.create
local resume = coroutine.resume
local running = coroutine.running
local status = coroutine.status
local wrap = coroutine.wrap
local yield = coroutine.yield
local tinsert = table.insert
local tremove = table.remove
@kurapica
kurapica / example.lua
Created July 12, 2021 13:22
Controller Example
class "FileController" (function(_ENV)
inherit "Controller"
-- GET /file/download?name=test&fields=["name","age"]
__Action__("download", HttpMethod.GET)
__Form__{ -- Form验证并自动按照结构组织数据,下面的fields是字符串数组
name = String,
fields = struct { String },
}
__File__() __Iterator__() -- 申明返回为文件,并且使用迭代器的形式返回数据
@kurapica
kurapica / threadpool.lua
Created July 12, 2021 07:06
Lua simple thread pool
local create = coroutine.create
local resume = coroutine.resume
local running = coroutine.running
local status = coroutine.status
local wrap = coroutine.wrap
local yield = coroutine.yield
local tinsert = table.insert
local tremove = table.remove
local PREPARE_CONFIRM = {}
@kurapica
kurapica / SpellCooldown.lua
Last active July 10, 2021 14:29
Simple SpellCooldownPanel For WOW with mover
Scorpio "SpellCooldown" ""
class "Scorpio.Widget.SpellCooldownPanel" (function(_ENV)
inherit "ElementPanel"
import "System.Reactive"
class "Icon" { Frame }
__Indexer__() __Observable__()
@kurapica
kurapica / MinimapClassic.lua
Last active July 3, 2021 01:31
Minimap For Classic
Scorpio "MinimmapPatch" ""
MinimapZoneTextButton:SetParent(Minimap)
MinimapZoneTextButton:ClearAllPoints()
MinimapZoneTextButton:SetPoint("BOTTOMLEFT", Minimap, "TOPLEFT", 0, 4)
MinimapZoneTextButton:SetPoint("BOTTOMRIGHT", Minimap, "TOPRIGHT", 0, 4)
MinimapZoneText:ClearAllPoints()
MinimapZoneText:SetAllPoints()
MinimapZoneText.JustifyH = "CENTER"