This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------------------------------------------------------ | |
-- Module: utf8_filenames | |
------------------------------------------------------------------------------------------------------------------------------ | |
-- Filename: utf8_filenames.lua | |
-- Version: 2019-07-13 | |
-- License: MIT (see at the end of this file) | |
-- This module modifies standard Lua functions so that they work with UTF-8 filenames on Windows: | |
-- io.open | |
-- io.popen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Convertor from GSM7 to ASCII | |
-- Usage: | |
-- print(GSM7_to_ASCII("F4F29C9E769F1B")) | |
function GSM7_to_ASCII(hex_string) | |
local GSM_Base = { | |
[0] = '@', '£', '$', '¥', 'è', 'é', 'ù', 'ì', 'ò', 'Ç', '\n', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env lua | |
--------------------------------------------------------------------------------------------------------------------------------------- | |
-- Display list of globals used by your Lua script | |
--------------------------------------------------------------------------------------------------------------------------------------- | |
-- Version: 2019-03-28 | |
-- License: MIT (see at the end of this file) | |
-- | |
-- Reads your Lua script from STDIN | |
-- Writes list of globals to STDOUT (if the script is syntactically correct) | |
-- Writes parsing error to STDERR (if the script is not syntactically correct) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--~ How to run the benchmark: | |
--~ $ luajit sha256_for_LuaJIT.lua;luajit -O-narrow sha256_for_LuaJIT.lua | |
local table_concat, byte, char, string_rep, sub, floor, ceil, min, max = | |
table.concat, string.byte, string.char, string.rep, string.sub, math.floor, math.ceil, math.min, math.max | |
local b = require"bit" | |
local AND = b.band | |
local OR = b.bor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env lua | |
--------------------------------------------------------------------------------------------------------------------------------------- | |
-- Converter from "source text" to "globals-backslashed source text" | |
--------------------------------------------------------------------------------------------------------------------------------------- | |
-- Reads Lua program from STDIN | |
-- Writes converted program to STDOUT (if the program is syntactically correct) | |
-- Writes parsing error to STDERR (if the program is not syntactically correct) | |
-- Usage (both Windows and Linux): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local write,D,L,select,tostring,ipairs,concat,execute,sub,gsub=io.write,{},8192,select,tostring,ipairs,table.concat,os.execute,string.sub,string.gsub | |
local T,E,I | |
T=io.read"*a" | |
T=string.match(T,"=(.-)$") or "" | |
T=gsub(T,"+"," ") | |
T=gsub(T,"%%(%x%x)",function (x) return string.char(tonumber(x,16)) end) | |
T=gsub(T,"^%s*=%s*","return ") | |
write(sub(T,1,L)) | |
write[[</TEXTAREA> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------------------------------- | |
-- This code snippet implements pseudo-random number generator | |
-- Output: 32-bit integers 0..4294967295 | |
-- Internal state (seed): 53 bits, can be read or write at any time | |
-- Good statistical properties of PRN sequence: | |
-- uniformity, | |
-- long period of 255 * 2^45 (approximately 2^53), | |
-- unpredictability |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local append, concat, floor, abs = table.insert, table.concat, math.floor, math.abs | |
local num = {'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', | |
'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'} | |
local tens = {'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'} | |
local bases = {{floor(1e18), ' quintillion'}, {floor(1e15), ' quadrillion'}, {floor(1e12), ' trillion'}, | |
{floor(1e9), ' billion'}, {1000000, ' million'}, {1000, ' thousand'}, {100, ' hundred'}} | |
local insert_word_AND = false -- 101 = "one hundred and one" / "one hundred one" | |
local function IntegerNumberInWords(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- long_unsigned_integers.lua | |
--------------------------------------------------------------------------------------------------------- | |
-- LONG ARITHMETIC (non-negative integers of arbitrary length) | |
--------------------------------------------------------------------------------------------------------- | |
-- Compatible with Lua 5.1, Lua 5.2, Lua 5.3, LuaJIT | |
-- THIS MODULE WAS NOT OPTIMIZED FOR VERY LONG NUMBERS (multiplication has quadratic time complexity) | |
-- Usage: | |
-- local L = require("long_unsigned_integers") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------------ | |
-- Module: null.lua | |
------------------------------------------------------------------------------------ | |
-- How to insert nils in an array? | |
-- Traditional approach is to appoint some Lua value as nil-replacement. | |
-- A function null(...) that swaps nils with itself may be a perfect candidate: | |
-- 1) It represents nil values inside an array |