Skip to content

Instantly share code, notes, and snippets.

View nefftd's full-sized avatar

Anthony Eadicicco nefftd

View GitHub Profile
-- READ ONLY FORM
local mt = {} -- The real metatable
local mt_proxy = {} -- The object returned by getmetatable()
setmetatable(mt_proxy,{
__index = function(self,k) return mt[k] end, -- Allow the proxy to read fields. use a function so it's opaque (user cannot access real metatable)
__newindex = function() end -- But writing is a nop (otherwise we may accidentally barr access to __index)
})
mt.__metatable = mt_proxy -- Make getmetatable() return the proxy
local mt,mt_proxy = {},{}
setmetatable(mt_proxy,{ __index = mt })
mt.__metatable = mt_proxy
test = {}
setmetatable(test,mt)
-- add `__newindex = mt` to line 2 for full read/write
-- or make __newindex a special filtering function to allow writing only some metamethods
local top = math.max(f1:GetTop(),f2:GetTop())
local bottom = math.min(f1:GetBottom(),f2:GetBottom())
local left = math.min(f1:GetLeft(),f2:GetLeft())
local right = math.max(f1:GetRight(),f2:GetRight())
local w,h = UIParent:GetWidth(),UIParent:GetHeight()
f3:ClearAllPoints()
f3:SetPoint('TOPLEFT',UIParent,'TOPLEFT',h-top,left)
f3:SetPoint('BOTTOMRIGHT',UIParent,'BOTTOMRIGHT',bottom,w-right)
local mystring = "0513|0625|0929" -- and so on
local a = {}
local i = 1
for num in mystring:gmatch('[^|]+') do
a[i] = num
i = i + 1
end
table.sort(a)
local function foo()
return foo()
end
local bar; bar = function()
return bar()
end
-- With select('#') and recursion
do
local function _tsa(n,a,...)
if n > 0 then
return tostring(a),_tsa(n-1,...)
end
end
function tostringall(...)
local n = select('#',...)
@nefftd
nefftd / neffi_miniarenadebuff.txt
Last active August 29, 2015 14:06
Arena frame debuffs, with whitelist filtering, written as a series of macros for the arena tournament.
The below code is hereby released into the Public Domain.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
@nefftd
nefftd / miniaura.lua
Created September 13, 2014 21:26
Early prototype
local WHITELIST = {[8122]=1,[408]=1,[1833]=1,[6770]=1,[2094]=1,[118]=1,[82691]=1,[71757]=1,[12598]=1,[122]=1,[33395]=1,[83302]=1,[76577]=1,[12357]=1,[44572]=1,[55021]=1,
[2823]=1,[108215]=1,[108212]=1,[137573]=1, -- REMOVE FOR FINAL. ONLY FOR TESTING
}
--[=[
local buttons = {}
for i = 1,5 do
local i = i -- Store the unit ID in an upvalue
buttons['arena'..i] = setmetatable({},{__index = function(self,b)
--[[ build button i ]]
/run _SSP={[42292]=1,[59752]=1,[8122]=1,[408]=1,[1833]=1,[6770]=1,[2094]=1,[118]=1,[82691]=1,[71757]=1,[12598]=1,[122]=1,[33395]=1,[83302]=1,[76577]=1,[12357]=1,[44572]=1,[55021]=1}
/run f=CreateFrame'Frame'f:RegisterEvent'UNIT_SPELLCAST_SUCCEEDED'f:SetScript('OnEvent',function(s,e,u,_,_,_,p)if u:find'arena'and _SSP[p]then SendChatMessage(GetSpellInfo(p)..' used by: '..GetUnitName(u),'PARTY') end end)
@nefftd
nefftd / neffi_minicc.txt
Last active August 29, 2015 14:06
Minified clean-room reimplementation of OmniCC, written as a series of macros, for the arena tournament.
The below code is hereby released into the Public Domain.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.