Skip to content

Instantly share code, notes, and snippets.

View jcmoyer's full-sized avatar

J.C. Moyer jcmoyer

  • United States
View GitHub Profile

Problem: You're using a msys2 / mingw gcc / gnat distribution and you're trying to debug Ada code, but you can't catch exceptions:

(gdb) catch exception
Your Ada runtime appears to be missing some debugging information.
Cannot insert Ada exception catchpoint in this configuration.

This is because the distribution installed via pacman is stripped by default.

@jcmoyer
jcmoyer / as_callfunc_x64_nasm.asm
Last active April 27, 2023 19:53
AngelScript CallX64 for nasm
;
; AngelScript CallX64 ported to nasm for use with clang on Windows
;
; Based on the original implementation by Andreas Jonsson:
;
; File: sdk/angelscript/source/as_callfunc_x64_msvc_asm.asm
;
; To use this file, compile with nasm and link it into AS or your program.
; With cmake, use something like:
;
#ifndef STASHING_REVERSE_ITERATOR_HPP
#define STASHING_REVERSE_ITERATOR_HPP
#include <iterator>
// This is an implementation of `std::reverse_iterator` that uses an auxiliary
// member to store the iterator obtained by calling `operator*`. The standard
// specifies that `reverse_iterator::operator*` has a const qualifier;
// therefore it must return a reference to a local copy of a decremented
// current iterator. If this reference points to data inside that local copy,
@jcmoyer
jcmoyer / fun2.lua
Last active August 29, 2015 14:20
(Lua 5.3) String-lambdas that close over locals with syntax inspired by OCaml/F#
-- taken from http://lua-users.org/wiki/StringTrim
local function trim(s)
return s:match "^%s*(.-)%s*$"
end
-- creates a function from a lambda string
local function fun(text)
-- divide the text into arg list and return body
local a, r = text:match("(.-)->(.*)")
@jcmoyer
jcmoyer / aspect.lua
Created June 5, 2013 19:47
pre/post method hooks in Lua for AOP
--
-- dog
--
local dog = {}
function dog.new()
return setmetatable({ name = 'dog' }, { __index = dog })
end
function dog:run()
print("* " .. self.name .. " is running *")
@jcmoyer
jcmoyer / fun.lua
Created May 23, 2013 05:45
String-lambdas with syntax inspired by OCaml/F#
-- taken from http://lua-users.org/wiki/StringTrim
function trim(s)
return s:match "^%s*(.-)%s*$"
end
-- creates a function from a lambda string
function fun(text)
-- divide the text into arg list and return body
local a, r = text:match("(.-)->(.*)")
-- implements an option type as a tagged union
local option = {}
local mt = { __index = option }
local function isoption(t)
return getmetatable(t) == mt
end
function option.some(a)
@jcmoyer
jcmoyer / currying.lua
Last active May 12, 2017 14:33
Proper function currying in Lua 5.2
-- shallowly clones an array table
function clone(t)
local r = {}
for i = 1, #t do
r[#r + 1] = t[i]
end
return r
end
-- for any function 'f', the following is true: