Skip to content

Instantly share code, notes, and snippets.

mengyun yunyyyun

  • hangzhou
Block or report user

Report or block yunyyyun

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yunyyyun
yunyyyun / Base64.lua
Last active Aug 10, 2017
Base64 encode/decode
View Base64.lua
--base64加密
function base64_encode(data)
local base64Table='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
@yunyyyun
yunyyyun / table2string
Created May 27, 2017
把table转string,字符串结果可直接反过来load成table
View table2string
table.tostring = function(t)
if t==nil then
return "error,print table is nil!"
end
local assign={}
local function ser_table(tbl,parent)
local tmp={}
for k,v in pairs(tbl) do
local key= type(k)=="number" and "["..k.."]" or "[".. string.format("%q", k) .."]"
if type(v)=="table" then
@yunyyyun
yunyyyun / HumpNaming.lua
Created May 27, 2017
将字符串里的中文(utf-8)转为驼峰格式拼音
View HumpNaming.lua
------------------------------chinesePhoneticData.lua
local hash = {};
hash = {
[""] = "Zhong";
[""] = "Guo";
[""] = "Gu";
[""] = "Piao";
[""] = "Ming";
[""] = "Cheng";
@yunyyyun
yunyyyun / hash.lua
Last active Aug 23, 2017
一种均匀散列方法(hash)
View hash.lua
g_HashTable = 0
--创建hash表
function createHashTable()
local tb = {};
local _insert = function(k,v)
if k==0 then
k=1;
end
for i = k,k+999,1 do
if i>1000 then
You can’t perform that action at this time.