Skip to content

Instantly share code, notes, and snippets.

View Egor-Skriptunoff's full-sized avatar

Egor-Skriptunoff

View GitHub Profile
@Egor-Skriptunoff
Egor-Skriptunoff / blake3_for_luajit.lua
Last active March 15, 2022 07:36
BLAKE3 for LuaJIT
--------------------------------------------------------------------------------------------------------------------------
-- BLAKE3 for LuaJIT
--------------------------------------------------------------------------------------------------------------------------
-- Compatible with:
-- LuaJIT 2.x (FFI must be enabled, both little-endian and big-endian systems are supported)
-- This module contains functions:
-- blake3 (message, key, digest_size_in_bytes)
-- blake3_derive_key (key_material, context_string, derived_key_size_in_bytes)
-- hex_to_bin (hex_string)
-- bin_to_hex (binary_string)
@Egor-Skriptunoff
Egor-Skriptunoff / marble_scroll.lua
Created November 1, 2021 11:57
Scroll for Logitech Trackman Marble trackball
--------------------------------------
-- Scroll for Logitech Trackman Marble
--------------------------------------
-- This script is based on the project "MarbleScroll for Logitech Trackman Marble" by Primož.
-- https://www.fewprojects.com/marblescroll-for-logitech-trackman-marble/
-- The original code was rewritten to LuaJIT FFI and slightly modified by Egor Skriptunoff.
-- Logitech Trackman Marble trackball has only 4 buttons: LMB, RMB, Back, Forward.
-- It lacks scroll wheel and middle button.
-- This script adds the following possibilities:
@Egor-Skriptunoff
Egor-Skriptunoff / win-125x.lua
Created May 22, 2021 22:44
String converter between Windows ANSI and UTF-8 encodings
---------------------------------------------------------------------
-- Converter between win-125x and UTF-8 strings
---------------------------------------------------------------------
-- Written in pure Lua, compatible with Lua 5.1-5.4
-- Usage example:
-- require("win-125x")
-- str_win = utf8_to_win(str_utf8)
-- str_utf8 = win_to_utf8(str_win)
---------------------------------------------------------------------
@Egor-Skriptunoff
Egor-Skriptunoff / how_to_install_lua_and_luajit_on_windows.md
Last active October 5, 2024 00:01
How to install Lua and LuaJIT on Windows

How to install Lua and LuaJIT on 64-bit Windows

  1. Download the latest Lua and LuaJIT sources

    • Create temporary folder for Lua sources.
      I assume you would use C:\Temp\ folder.

    • Visit Lua FTP webpage and download the latest Lua source archive, currently it is lua-5.4.3.tar.gz

  • Use suitable software (7-Zip, WinRar, WinZip or TotalCommander) to unpack the archive.
@Egor-Skriptunoff
Egor-Skriptunoff / how_to_build_wlua_for_windows.md
Created May 22, 2021 22:16
How to build windowless Lua for Windows

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.

@Egor-Skriptunoff
Egor-Skriptunoff / how_to_build_wluajit_for_windows.md
Last active February 2, 2024 14:36
How to build windowless LuaJIT for Windows

What is "windowless LuaJIT"?

Windowless LuaJIT 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 LuaJIT 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.

@Egor-Skriptunoff
Egor-Skriptunoff / how_to_build_luajit_for_windows.md
Last active July 26, 2022 22:11
How to build LuaJIT for Windows

How to build 64-bit LuaJIT 2.1 binaries for Windows

  1. Download the latest LuaJIT sources

    • Create temporary folder for LuaJIT sources.
      I assume you would use C:\Temp\ folder.

    • Download and install Portable "Git for Windows"

@Egor-Skriptunoff
Egor-Skriptunoff / wcwidth.lua
Created October 11, 2020 22:03
Function wcwidth implemented in pure Lua
local wcwidth -- function wcwidth(codepoint) returns 0, 1 or 2 for codepoints from the range 0..0x10FFFF
do -- implementation from the C library "utf8proc" was rewritten in Lua, compressed and minified
local d = [[r6rur7!&B!!(!"my!"arCssststssrNx|}ssrDr+r&sr{zsxttsvr7sssr4r1rq}rP{{sr.vs{suswrAu!!/rGrLusr(sy|tr
3urNssytttu{s|tr0sturNsswvttuusr4tus}urNsszsusur*tr,xsurNssytttuyu|tr4srQwuusv{sr>wrOysusvyt}tr3urNssysusvyt}tr2vrMt
sysusv{s|tr3ur\svxssszr(trSsty~zrxst{}xr`tr1sssssvtrGr*stw}sr:{srzr*r-vvusutyuvr#~ss|vrxrv!%=u!)zur3ur3tr4trVr6{srCv
!!.tr8s!!.~v~!"5wrO|sr3tsrFr'rUwrEr'r<{~ur4r#rNr$rFr*!!Pusr+vsxstu!!~rPsw!%Kwr.yrGws|rvr7!%itr#t!!vvusts!%Itr+trH~rA
sr)sr#sztr'twtzswsr+sytssvstsysvtr2sr9sssvussrSur.sr$s!)#trIsvs!$7u!!Esrvr6!!8r0sro~!"0r0~vr@vr'trlttr{wrAsrtsrj~rEs
r>z!jZrV#C1u!,;urM!$Fvs|r6trft!"jsusvsr-wvsritrHr(r0r(r#sr<zr/r#~r3uvrEr$r:srYr$~sztrCurHssuttwtssr?wwt!"Fzstr("8frr
!5`!c|!#jt!!"rZs!'er&|xr&r9sr)sv!!Kssrv!!7yr(u!%As!"<s!!Mw!1^ustwvr>uvs!!]t!%}v!$!t!!Q}!!gurKr%
@Egor-Skriptunoff
Egor-Skriptunoff / LGS_OutputDebugMessage_Receiver.lua
Last active April 25, 2020 21:17
LuaJIT script to receive a message sent with OutputDebugMessage() from LGS/GHUB
-- This LuaJIT script receives first OutputDebugMessage() from LGS/GHUB, prints the message to stdout and exits
-- Waiting is limited to 2 seconds
local timeout_msec = 2000 -- set 2^32-1 for infinite waiting
local ffi = require"ffi"
local psapi = ffi.load"psapi"
ffi.cdef[[
uint32_t EnumProcesses(uint32_t *, uint32_t, uint32_t *);
@Egor-Skriptunoff
Egor-Skriptunoff / LGS_script_template.lua
Last active December 17, 2023 11:31
Template script file for Logitech Gaming Software
---------------------------------------------------------------------------------------------
-- LGS_script_template.lua
---------------------------------------------------------------------------------------------
-- Version: 2019-04-19
-- Author: Egor Skriptunoff
--
--
-- This is a template for "Logitech Gaming Software" script file.
-- Four useful features are implemented here:
--