Skip to content

Instantly share code, notes, and snippets.

View jeffzi's full-sized avatar

Jean-Francois Zinque jeffzi

  • Bordeaux
View GitHub Profile

A metatable in Lua defines various extraneous behaviors for a table when indexed, modified, interacted with, etc. They are Lua's core metaprogramming feature; most well known for being useful to emulate classes much like an OOP language.

Any table (and userdata) may be assigned a metatable. You can define a metatable for a table as such:

-- Our sample table
local tab = {}
-- Our metatable
local metatable = {
 -- This table is then what holds the metamethods or metafields
@bgromov
bgromov / PyQt5_with_SIP4_and_virtualenv.md
Last active August 17, 2021 03:12
PyQt5 with SIP 4.19.1 for Python 2.7 with virtualenv under macOS Sierra

Preparation

Install Qt5 with homebrew and link it to the system (potentially destructive operation):

$ brew install qt5
$ brew unlink qt # may fail if no Qt4 was installed previously with homebrew
$ brew link --force qt5

Additionally, it might be worth to activate the appropriate target virtualenv with:

@incrediblejr
incrediblejr / ijlat.h
Created May 25, 2016 13:36
(Simple) Lua Allocation Tracker
/* ijlat.h - v0.1a - (Simple) Lua Allocation Tracker -- public domain -- @incrediblejr, May 2016
ABOUT
A simple Lua allocation tracker.
USAGE
The memory tracker is implemented as a [stb-style header-file library][1] which means that
in *ONE* source file, put:
@Kubuxu
Kubuxu / doubleSerialize.lua
Last active July 12, 2024 18:54
Two functions allowing for Lua's number serialization.
--[[
The MIT License (MIT)
Copyright (c) 2015 Jakub (Kubuxu) Sztandera
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is