View bin2hex.c
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
#include <sys/resource.h> | |
double get_time() | |
{ | |
struct timeval t; | |
struct timezone tzp; | |
gettimeofday(&t, &tzp); |
View gist:ef376955b606c386ef47b8ef2e2a869e
This file contains 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 |
View strdup_lower.c
This file contains 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; |
View strdup_upper.c
This file contains 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); |
View strstr.lua
This file contains 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 |
View install.sh
This file contains 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 |
View gist:ba20927f0e4eb9717efb8250bda82e12
This file contains 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]) ) |
View str_split.lua
This file contains 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 |
View rl_helper.php
This file contains 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'); | |
*/ |
View test.sql
This file contains 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 |
NewerOlder