Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
test scribunto bug
Jackmcbarn (talk | contribs)
m Reverted edits by Jackmcbarn (talk) to last version by Le Deluge
Tags: Replaced Rollback
 
(24 intermediate revisions by 2 users not shown)
Line 1:
local locmapgetTarget = require('Module:Location mapRedirect').getTarget
local p = {}
 
local function xorByteTablespagetype(t1, t2nsText)
function p.lambertConformalConic(refLat, refLong, stdParallel1, stdParallel2)
return nsText == '' and 'articles' or (mw.ustring.lower(nsText) .. ' pages')
return function(latitude, longitude)
local n
if stdParallel1 == stdParallel2 then
n = math.sin(stdParallel1)
else
n = math.log(math.cos(stdParallel1)/math.cos(stdParallel2))/
math.log(math.tan(0.25*math.pi + 0.5*stdParallel2)/math.tan(0.25*math.pi + 0.5*stdParallel1))
end
local f = math.cos(stdParallel1)*math.tan(0.25*math.pi + 0.5*stdParallel1)^n/n
local rho = f*math.tan(0.25*math.pi + 0.5*latitude)^-n
local rho0 = f*math.tan(0.25*math.pi + 0.5*refLat)^-n
return {
x = rho*math.sin(n*(longitude - refLong)),
y = rho0 - rho*math.cos(n*(longitude - refLong))
}
end
end
 
function p.pairsmain(frame)
local currentTitle = mw.title.getCurrentTitle()
local args, args_mt = { '__pairs was not used' }, {}
local target = getTarget(currentTitle)
function args_mt.__pairs( t )
if #t2 < #t1target then
return pairs( { 'success' } )
local currentNsText, targetNsText = currentTitle.nsText, mw.title.new(target).nsText
end
if currentNsText ~= targetNsText then
return frame:expandTemplate{ title = 'Echo', args = setmetatable( args, args_mt ) }
return string.format('[[:Category:Cross-namespace redirects from %s]][[:Category:Cross-namespace redirects to %s]]', pagetype(currentNsText), pagetype(targetNsText))
end
 
function p.maptest(frame)
local locmap = require('Module:Location map')
local retval = {}
for long=-165,-30,15 do
for lat=40,80,5 do
retval[#retval + 1] = tostring(locmap.mark(frame, {'Canada', long=long, lat=lat, outside='1'}))
end
end
return '[[:Category:Pages incorrectly tagged as cross-namespace redirects]]'
return locmap.top(frame, {'Canada', width=800, float='center'}) .. table.concat(retval) .. locmap.bottom(frame, {'Canada', width=800, float='center'})
end
 
local function hexToByteTable(str)
local retval = {}
for piece in str:gmatch('[0-9A-Fa-f][0-9A-Fa-f]') do
retval[#retval + 1] = tonumber(piece, 16)
end
return retval
end
 
local bxor = require('bit32').bxor
 
local function xorByteTables(t1, t2)
if #t2 < #t1 then
t1, t2 = t2, t1
end
local retval = {}
for k,v in ipairs(t1) do
retval[k] = bxor(v, t2[k])
end
return retval
end
 
local function byteTableToString(t)
local retval = {}
for k,v in ipairs(t) do
retval[k] = string.char(v)
end
return table.concat(retval)
end
 
function p.xor(frame)
local s1, s2 = '1f e9 0d d5 33 a4 70 0c 83 03 9b a0 6d 2b', frame.args[1]
local t1, t2 = hexToByteTable(s1), hexToByteTable(s2)
return byteTableToString(xorByteTables(t1, t2))
end
 
function p.main(frame)
return mw.dumpObject(mw.ustring.match('4', '[^%s%d]'))
end