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
function in_array(value, array) | |
for _, v in ipairs(array) do | |
if v == value then | |
return true | |
end | |
end | |
return false | |
end |
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
char* strdup_lower(char* str) { | |
char *b; | |
char *s; | |
char *buf; | |
errno = 0; | |
buf = strdup(str); | |
if (!buf) | |
return NULL; |
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
/* | |
a simple function to duplicate string and upper it. | |
sample: | |
... | |
char *upper = strdup_upper("HELLO world"); | |
if (!upper) { perror("ops!"); exit(1); } | |
puts(upper); | |
free(upper); |
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
-- works like c strstr() | |
-- retorn index if found pattern =) | |
function strstr(haystack, needle) | |
if (not haystack) then return nil; end | |
if (not needle) then return nil; end | |
local h, n = #haystack, #needle; | |
for i = 1, h - n + 1 do |
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
# based on 2023-05-03-raspios-bullseye-arm64-lite.img.xz | |
# | |
su [your password] | |
apt-get update && sudo apt-get upgrade | |
curl -fsSL test.docker.com -o get-docker.sh && sh get-docker.sh | |
usermod -aG docker [user_name] | |
# fix 'memory/swap' error | |
echo "cgroup_enable=memory swapaccount=1 cgroup_memory=1 cgroup_enable=cpuset" >> /boot/cmdline.txt |
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
--! lua.org | |
--! get a argument from cli in lua-5.1 | |
if not arg or #arg == 0 then | |
print('lua args.lua [nome]'); | |
os.exit(1); | |
end | |
print( _VERSION ) | |
print( string.format('ola %q', arg[1]) ) |
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
-- | |
-- based on https://www.php.net/manual/en/function.str-split.php | |
-- feel to free to validate/adjust to uses asserto/error | |
-- | |
-- Denis Dos Santos Silva | |
-- | |
local function str_split(str, length) | |
local result = {} | |
local index = 1 |
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
/* | |
php -v | |
PHP 8.0.28 (cli) (built: Feb 14 2023 18:33:29) ( NTS ) | |
Copyright (c) The PHP Group | |
Zend Engine v4.0.28, Copyright (c) Zend Technologies | |
with Zend OPcache v8.0.28, Copyright (c), by Zend Technologies | |
grep CI_VERSION system/core/CodeIgniter.php | |
define('CI_VERSION', '3.0.0'); | |
*/ |
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
-- insert or replace sqlite 3.x | |
create table config( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, key text, value text ); | |
insert into config values (1, "fg", "#ff00ff" ); | |
insert or replace into config(id, key, value) values ((select id from config where key = "bg"), "bg", "0x00ff00"); | |
SELECT * FROM config; | |
$ sqlite3 < test.sql | |
SQLite version 3.34.0 2020-12-01 16:14:00 | |
1|fg|#ff00ff |
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
#!/bin/sh | |
# | |
# download package from http://syslog4j.org/ | |
# check also https://manpages.ubuntu.com/manpages/xenial/man1/logger.1.html | |
# | |
java -cp syslog4j-0.9.46-bin.jar \ | |
org.productivity.java.syslog4j.server.SyslogServerMain \ | |
-h 127.0.0.1 \ | |
-p 9999 \ |