Luabind: Transparent Lua FFI and Embedding

Introduction

luabind is a header-only library that facilitates bi-directional bindings between C++ and Lua. I began luabind as a learning exercise, to practice more advanced modern C++ features like template metaprogramming, constexpr, SFINAE, C++20 “concepts”/“requires”, CTAD, and more.

Though you can find more examples of the usage in the tests for luabind, here is one of the unittests which demonstrates some of its capabilities:

1
2
3
4
5
6
7
8
9
10
11
12
13
TEST(LuaBind, Expose) {
luabind::Lua lua;
lua["timesTwo"] = [](int x) -> int {
return x*2;
};
lua << R"(
callIntoCFunc = function(a)
return timesTwo(a)
end
)";
int x = lua["callIntoCFunc"](4);
ASSERT_EQ(x, 8);
}
Read more

Archaeological and Forensic Investigation

I have found it useful to define these two terms as it relates to investigating behavior in code: forensic investigation, and archaeological investigation.

Read more

Traefik 2.0 With Docker Compose

In this article I will discuss using Traefik in conjunction with docker-compose to set up a multi-domain server, both with and without HTTPS support.

Read more

Wireless Audio Control Interface

This project was completed in Fall of 2019 as a senior capstone design project for the EECE department at Northeastern University. Included here is the abstract and associated project materials to serve as part of my portfolio. Thanks to group members Joshua Berlin, Jess Bardio, Andrew Whitacker, Phil Del Signore, and Lousia Beckwith, as well as advisor Professor Bahram Shafai.

Read more

Decade Clock

The Decade Clock is a half-finished project I started as a pandemic past-time (and to use the CircuitStudio license I bought for myself as a graduation gift). The idea is very simple: modular boards that take in power + clock, count up some LEDs, and “spill” over to the clock on the output. The result is a neat visual effect where each column counts up 10x slower than the last. The project is perfectly impractical, but perhaps could be used as a teaching aid for middle or high school students learning about the differences between base 10 and other bases.

Read more

Understanding Lua Metatables

The Lua programming language does not have a class-based object oriented system in its definition. Lua metatables are the most common way of implementing such a system, and is analygous in usefulness to method_missing in Ruby or __getattr__ in Python.

Read more

Aliases

While working as a web dev for VirZOOM, and later doing embedded programming and scripting at Desktop Metal, I’ve accumulated some aliases in my ~/.bash_profile which speed up my workflow:

Read more

Universal Makefile

Build System Frustration

Like any developer, I like to use the right tool for the job – when it comes to coding projects, the choice of language can greatly impact the performance and workflow of the project in the future. For quick CLI’s and web projects, I like to use Python; for short single-use and domain-specific scripts, shell is nice; for native concurrency primitives and a simple language, I use Golang. Many languages that are catching the world by a storm, like Golang, Rust, Kotlin, Crystal, and Nim have built-in or otherwise generally accepted build systems that are relatively effortless to leverage in making easily buildable and installable packages. However, as a student in Electrical Engineering who frequently drops down to lower level languages like C and C++, project build systems pose a larger barrier to entry. To solve this problem, I have a relatively simple “universal” Makefile for C and C++ (and mixed), which can be easily adaptable for many projects.

Read more

Firmata

Problem

Often times, working with embedded hardware, we want to have the low level bit-flipping access of embedded programming but keep the high level programming ability of languages like Python or Ruby. Let’s say we want to control the position of a stepper motor connected through a motor driver to an Arduino, but we don’t want a “closed” control system with just the Arduino–we want to control the position from a Python script on a computer (maybe connected to a web service, etc.).

Read more
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×