Skip to content

Instantly share code, notes, and snippets.

@greatwolf
greatwolf / luacom-scm.moteus-1.rockspec
Created January 31, 2020 05:16
LuaCOM rockspec modified to build with CMake.
package = "LuaCOM"
version = "scm.moteus-1"
source = {
url = "https://github.com/moteus/luacom/archive/master.zip",
dir = "luacom-master",
}
description = {
summary = "Use COM libraries from Lua",
detailed = [[
LuaCOM is an add-on library to the Lua language that allows Lua programs to use and implement objects that follow Microsoft's Component Object Model (COM) specification and use the ActiveX technology for property access and method calls. ]],
-- Monte Carlo Simulation of state machine in paper
-- Make one attempt to reach state 1000, fail at zero
function attempt (p)
local state = 2
local ups = 1
while state > 0 do
if state > 1000 then
-- attempt succeeded
@greatwolf
greatwolf / copyvstools.bat
Last active February 28, 2017 04:28
Modified batch for extracting Visual Build Tools 2017 into standalone
@echo off& setlocal& set x86=& set w32=system32
rem http://paulhoule.com/msvc14/copymsvc14.bat May 28, 2016
if "%~1"=="" echo Copies minimal files to run CL 14.0 (32 and 64 bit)
if "%~1"=="" echo First arg must be target directory& goto :eof
if exist "c:\Program Files (x86)\." set "x86= (x86)"& set w32=syswow64
rem set vs1=c:\Program Files%x86%\Microsoft Visual Studio 14.0
set vs1=c:\Program Files%x86%\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.24930
set vs2=c:\Program Files%x86%\Windows Kits\10
set vs3=c:\Program Files%x86%\Windows Kits\8.1
local seq = require 'pl.seq'
local function bench (n, func, ...)
assert (n > 0)
assert (type(func) == 'function')
local start = os.clock ()
if n % 2 == 1 then
func (...)
n = n - 1
@greatwolf
greatwolf / NQueens.lua
Last active August 29, 2015 14:24
NQueens in lua
local dump = require 'pl.pretty'.dump
local function printboard(board)
if not board then return end
local n = #board
io.stdout:write ("\n", (" -"):rep(n), "\n")
for i = 1, n do
io.stdout:write "|"
for j = 1, n do
io.stdout:write(board[j][i] and "Q" or " ", "|")
@greatwolf
greatwolf / bdd.cpp
Last active August 29, 2015 14:24
BDD test implementation
#include <iostream>
#include <vector>
using namespace std;
#define Describe(unitgroup) \
struct unitgroup; \
register_harness<unitgroup> unitgroup ## _registered; \
struct unitgroup : public testharness<unitgroup> \
@greatwolf
greatwolf / mathparser.lua
Last active August 6, 2024 09:23
Math expression parser implemented with Lua LPeg
--[[
Simple arithmetic expression parser
using LPeg's re module
--]]
require 'table.clear' -- luajit extension
local dprint = dbg and print or function() end
local dump = require 'pl.pretty'.dump
local re = require 're'
re.updatelocale()
@greatwolf
greatwolf / mkl_rt.def
Created November 5, 2013 23:19
mk_rt.def for creating bcc compatible import lib
LIBRARY MKL_RT.DLL
EXPORTS
_CAXPBY = CAXPBY
_CAXPY = CAXPY
_CAXPYI = CAXPYI
_CBBCSD = CBBCSD
_CBDSQR = CBDSQR
_CCOPY = CCOPY
_CDOTC = CDOTC