Skip to content

Instantly share code, notes, and snippets.

-- compat
local unpack = table.unpack or unpack
local print = print
local debug = debug
local table = table
local _ENV = setmetatable({}, {__index=function(t,k)
if (k ~= 'arg') then
error("undefined global "..k)
end
local res = {}
local Class = {}
function Class.__index(super,k,self)
self[k] = {}
return self[k]
end
setmetatable(Class,Class)
local SubClass = {}
SubClass.__index = setmetatable(SubClass,Class)
-- print((function(f) return (function(x) return f(function(...) return x(x)(...) end) end)(function(x) return f(function(...) return x(x)(...) end) end) end)(function(f) return function(n) if n==0 then return 1 else return n*f(n-1) end end end)(10))
local function fix(f)
return (function(x)
return f(function(...)
return x(x)(...)
end)
end)(function(x)
return f(function(...)
return x(x)(...)
N = 20
-- We'll use nil to indicate no queen is present.
grid = {}
for i = 0, N do
grid[i] = {}
end
function can_find_solution(x0, y0)
local x0, y0 = x0 or 0, y0 or 1 -- Set default vals (0, 1).
@katlogic
katlogic / server_hello.lua
Last active March 1, 2016 12:10 — forked from daurnimator/server_hello.lua
Prototyping lua-http server api
require('lazyserver')(8000, {
-- note that query string is not considered in the pattern
["^/(.*)"] = function(self, cap1)
self.content_type = 'text/plain'
self:write('halo halo, you requested '+self.url[1]+', pattern captured '+cap1+', args supplied '+self.param)
return 200
end)
}
-- for even more lazy:
@katlogic
katlogic / hax.c
Last active January 4, 2018 05:33
//
// CVE-2006-0741 reloaded
// CVE-2014-4699 actually
// [email protected]
//
#define _GNU_SOURCE
#include <sched.h>
#include <stdlib.h>
#include <sys/ptrace.h>
#if 0 //To compile as a stand-alone test program, type "nmake eval.c"
!ifndef COMP
COMP=1
!endif
eval.exe: eval.c; cl eval.c /Ox /G6Fy /Gs /MD /nologo /DEVALTEST /DCOMPILE=$(COMP) /link /opt:nowin98 /nologo
del eval.obj
!if 0
#endif
#if 0
diff --git a/src/Makefile b/src/Makefile
index 532da6e..351f99b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -34,9 +34,9 @@ CC= gcc
# to slow down the C part by not omitting it. Debugging, tracebacks and
# unwinding are not affected -- the assembler part has frame unwind
# information and GCC emits it where needed (x64) or with -g (see CCDEBUG).
-CCOPT= -O2 -fomit-frame-pointer
+#CCOPT= -O2 -fomit-frame-pointer
gdb ./luajit-ljx
GNU gdb (Gentoo 7.7.1 p1) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
r={}
tm={}
function setmetatable52(t,mt)
if rawget(mt,"__gc") and not rawget(t,"__gc_proxy") then
local p = newproxy(true)
rawset(t,"__gc_proxy", p)
debug.getmetatable(p).__gc=function()
rawset(t,"__gc_proxy",nil)
local nmt = debug.getmetatable(t)