Skip to content

Instantly share code, notes, and snippets.

View arkenidar's full-sized avatar
🎯
Focusing @Elmiguys

Dario Cangialosi arkenidar

🎯
Focusing @Elmiguys
View GitHub Profile
@arkenidar
arkenidar / echo.lua
Last active October 11, 2021 12:56 — forked from whiler/echo.lua
Simple TCP Echo Server in Lua
-- sudo luarocks install luasocket
-- sudo apt install lua-socket
local socket=require("socket")
local server=assert(socket.bind("localhost",9999))
server:settimeout(0) -- for server:accept()
local ip,port=server:getsockname()
print("ncat".." "..ip.." "..port)
@arkenidar
arkenidar / how_to_build_wlua_for_windows.md
Last active July 20, 2023 15:08 — forked from Egor-Skriptunoff/how_to_build_wlua_for_windows.md
How to build windowless* #Lua for #Windows (* meaning: no visible console for standard console output, no "console window", like pythonw.exe )

What is "windowless Lua"?

Windowless Lua does not create a console window.
It runs invisible for user.

Please note that "windowless" means "doesn't have stdin, stdout and stderr".
You will not be able to see error message.
io.read(), io.write() and print() in your Lua script will not work.
But in some situations invisible Lua is just what you need very much.
For example, to avoid a GUI application (especially a game) to lose input focus when some background Lua script is started.

@arkenidar
arkenidar / ffi-sdl.lua
Created November 11, 2022 21:11 — forked from creationix/ffi-sdl.lua
Using SDL from luajit's built-in ffi module
-- load the luajit ffi module
local ffi = require "ffi"
-- Parse the C API header
-- It's generated with:
--
-- echo '#include <SDL.h>' > stub.c
-- gcc -I /usr/include/SDL -E stub.c | grep -v '^#' > ffi_SDL.h
--
ffi.cdef(io.open('ffi_SDL.h', 'r'):read('*a'))
-- Load the shared object
@arkenidar
arkenidar / sdl2_opengl.cpp
Created November 13, 2022 11:41 — forked from jordandee/sdl2_opengl.cpp
Simple SDL2/OpenGL example
// To compile with gcc: (tested on Ubuntu 14.04 64bit):
// g++ sdl2_opengl.cpp -lSDL2 -lGL
// To compile with msvc: (tested on Windows 7 64bit)
// cl sdl2_opengl.cpp /I C:\sdl2path\include /link C:\path\SDL2.lib C:\path\SDL2main.lib /SUBSYSTEM:CONSOLE /NODEFAULTLIB:libcmtd.lib opengl32.lib
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
@arkenidar
arkenidar / sdl2gles2gears.c
Last active November 15, 2022 09:46 — forked from DavidLudwig/sdl2gles2gears.c
GLGears for SDL2 + OpenGL ES 2 [[ gcc sdl2gles2gears.c $(sdl2-config --cflags --libs) -lm -lGLESv2 -ogles && ./gles # basilar compile and run (works for me) ]]
// gcc sdl2gles2gears.c $(sdl2-config --cflags --libs) -lm -lGLESv2 -ogles && ./gles # basilar compile and run (works for me)
/*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* 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,
@arkenidar
arkenidar / Makefile
Created November 17, 2022 09:34 — forked from matiasinsaurralde/Makefile
Hello World for LuaJIT FFI/C++ binding.
all: lib run
lib:
g++ -shared -fPIC -o libhello.so libhello.cpp hello.cpp
run:
luajit main.lua
clean:
rm *.so