Skip to content

Instantly share code, notes, and snippets.

View daurnimator's full-sized avatar

daurnimator

View GitHub Profile
@daurnimator
daurnimator / rock_to_PKGBUILD.lua
Last active October 8, 2022 15:51
Script to convert LuaRocks to Arch Linux PKGBUILDs
#!/usr/bin/env lua
local rockspec_name = assert(arg[1])
local function log(level, fmt, ...)
io.stderr:write(level .. "\t" .. string.format(fmt, ...) .. "\n")
end
local function append(tbl, ...)
for _, v in ipairs {...} do
from pylab import *
from numpy import *
from numpy.linalg import solve
from scipy.integrate import odeint
from scipy.stats import norm, uniform, beta
from scipy.special import jacobi
a = 0.0
@pims
pims / riakshell.go
Last active December 27, 2015 03:09
// tim$ go install
// tim$ cat logs | riakshell
package main
import (
"bufio"
"github.com/mrb/riakpbc"
"io"
"log"
@vishvananda
vishvananda / tunnel.sh
Created October 22, 2013 03:16
Script to set up an ipsec tunnel between two machines For Example: ./tunnel.sh 10.10.10.1 10.10.10.2 192.168.0.1 192.168.0.2 would set up an ipsec tunnel over 10.10.10.1 address using 192.168.0.1 as a virtual address passwordless sudo required for user on remote machine
#!/bin/bash
if [ "$4" == "" ]; then
echo "usage: $0 <local_ip> <remote_ip> <new_local_ip> <new_remote_ip>"
echo "creates an ipsec tunnel between two machines"
exit 1
fi
SRC="$1"; shift
DST="$1"; shift

Exploiting Lua 5.1 on 32-bit Windows

The following Lua program generates a Lua bytecode program called ignore-unsigned-sga.fnt, which in turn loads a DLL from within an extremely locked down Lua 5.1 sandbox in a program called RelicCOH2.exe. The remainder of this document attempts to explain how this program works by a whirlwind tour of relevent bits of the Lua 5.1 virtual machine.

if string.dump(function()end):sub(1, 12) ~= "\27Lua\81\0\1\4\4\4\8\0" then
  error("This generator requires a 32-bit version of Lua 5.1")
end

local function outer()
  local magic -- In bytecode, the stack slot corresponding to this local is changed
@tylerneylon
tylerneylon / learn.lua
Last active April 28, 2024 22:23
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@daurnimator
daurnimator / .bash_prompt.lua
Last active December 10, 2015 19:58
My bash prompt
local ret_code , n_jobs = ...
ret_code = tonumber ( ret_code )
n_jobs = tonumber ( n_jobs ) or 0
local ffi = require "ffi"
ffi.cdef [[
typedef uint32_t uid_t;
uid_t geteuid(void);
int gethostname(char *name, size_t namelen);
char *getcwd(char *buf, size_t size);
@daurnimator
daurnimator / app.lua
Created September 14, 2012 10:11
Sinatra like clone for lua
if not sinatra.incoming ( ngx.req.get_method() , ngx.var.uri ) then
return ngx.exit ( 404 )
end
@daurnimator
daurnimator / choose_type.lua
Created August 26, 2012 14:36
Lpeg pattern to parse a HTTP Accept Header
do
local function helper ( allowed , want )
return ( not want.type or allowed.type == "*" or ( allowed.type == want.type and
( not want.subtype or allowed.subtype == "*" or allowed.subtype == want.subtype ) )
) and allowed.q ~= 0
end
function choose_type ( allowed_list , wanted_list )
-- Remove items from allowed list that have no match (retains client ordering)
local res = { }
local allowed_wanted_map = { }
@daurnimator
daurnimator / ec.lua
Created November 22, 2011 03:56
A replacement for lua errors; based on coroutines.
local select = select
local error = error
local cocreate , coresume , corunning , costatus , coyield = coroutine.create , coroutine.resume , coroutine.running , coroutine.status , coroutine.yield
local getinfo = debug.getinfo
local err_signifier = { }
local ec = { }
local function xpcall_resume ( co , hand , ok , ... )