Skip to content

Instantly share code, notes, and snippets.

View datatypevoid's full-sized avatar

Null Void datatypevoid

View GitHub Profile
@datatypevoid
datatypevoid / safe_reference.lua
Created January 23, 2017 21:51 — forked from eliasdaler/safe_reference.lua
Safe reference implementation. Lua part. See https://eliasdaler.github.io/game-object-references for details
Handles = {}
local memoizedFuncs = {}
-- metatable which does magic
local mt = {}
mt.__index = function(handle, key)
if not handle.isValid then
print(debug.traceback())
error("Error: handle is not valid!", 2)
end
template <typename ...> class ActionEvent;
template <typename CT>
class ActionEvent <CT> {
public:
class Sink {
typedef void* InstancePtr;
@datatypevoid
datatypevoid / d_copy.lua
Created March 23, 2017 15:09 — forked from MihailJP/d_copy.lua
Shallow- and deep-copy of table in Lua
function clone (t) -- deep-copy a table
if type(t) ~= "table" then return t end
local meta = getmetatable(t)
local target = {}
for k, v in pairs(t) do
if type(v) == "table" then
target[k] = clone(v)
else
target[k] = v
end
@datatypevoid
datatypevoid / deepcopy.lua
Created March 23, 2017 15:09 — forked from Deco/deepcopy.lua
Lua Non-recursive Deep-copy
--[[ deepcopy.lua
Deep-copy function for Lua - v0.2
==============================
- Does not overflow the stack.
- Maintains cyclic-references
- Copies metatables
- Maintains common upvalues between copied functions (for Lua 5.2 only)
TODO
@datatypevoid
datatypevoid / valgrind.sh
Last active June 27, 2017 18:05
bash script for compiling c++ project and running valgrind on it (https://startupnextdoor.com/how-to-run-valgrind-in-clion-for-c-and-c-programs/)
#!/usr/bin/env bash
if [ $1 = "C" ]
then
/usr/bin/clang -ggdb main.c -std=c99 -Wall -Werror -o program && /usr/local/bin/valgrind ./program
elif [ $1 = "Cpp" ]
then
/usr/bin/clang++ -std=c++11 -stdlib=libc++ main.cc -Wall -Werror -o program && /usr/local/bin/valgrind ./program
fi

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
# - Find libbson
# Find the native libbson includes and library.
# Once done this will define
#
# LIBBSON_INCLUDE_DIRS - where to find bson.h, etc.
# LIBBSON_LIBRARIES - List of libraries when using libbson.
# LIBBSON_FOUND - True if libbson found.
#
# LIBBSON_VERSION_STRING - The version of libbson found (x.y.z)
# LIBBSON_VERSION_MAJOR - The major version
# - Check for the presence of RapidJSON
#
# The following variables are set when RAPIDJSON is found:
# RAPIDJSON_FOUND Set to true, if all components of RapidJSON
# have been found.
# RAPIDJSON_INCLUDE_DIRS Include path for the header files of RAPIDJSON
# RAPIDJSON_LIBRARIES Link these to use RAPIDJSON
# RAPIDJSON_LFLAGS Linker flags (optional)
if (NOT RAPIDJSON_FOUND)
# - Check for the presence of cpp_redis
#
# The following variables are set when cpp_redis is found:
# CPPREDIS_FOUND Set to true, if all components of cpp_redis
# have been found.
# CPPREDIS_INCLUDE_DIRS Include path for the header files of cpp_redis
# CPPREDIS_LIBRARIES Link these to use cpp_redis
# CPPREDIS_LFLAGS Linker flags(optional)
# Define the list of search paths for headers and libraries