Skip to content

Instantly share code, notes, and snippets.

View griloHBG's full-sized avatar
💭
I should use Git more...

Henrique griloHBG

💭
I should use Git more...
View GitHub Profile
@griloHBG
griloHBG / run.tpl
Last active February 1, 2023 22:25 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name {{printf "%q" .Name}} \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- if .Runtime}}
@griloHBG
griloHBG / signal_logger_test.c
Created May 26, 2022 20:47
A C application that logs some received signals to a file
//name: signal_logger_test.c
//how to comiple:
//${CC} signal_logger_test.c -o signal_logger_test
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
for i in $(seq 1 10);
do
msg=$(while [ $i -gt 0 ]; do echo -n "${i: -1}"; i=$((i-1)); done;);
echo $msg;
sleep .1;
done
@griloHBG
griloHBG / all_PDF_to_text.sh
Last active May 25, 2022 15:42
Convert all PDF files in a directory (and all directories within) to text
# making sure that names with spaces won't be a problem
IFS=$'\n';
# head to remove the last 2 lines (one blank and one summary) and tail to remove the first line (always a dot) of tree output
# TODO: what about *.PDF?
for i in $(tree . -f -P "*.pdf" -i | head -n -2 | tail -n +2);
# echo the relative file path
do echo -n "${i}: ";
# if it is a file (and not a directory), perform the conversion
[ -f ${i} ] && echo PDF && pdftotext "${i}" "${i}.txt";
@griloHBG
griloHBG / crosscompile_configure.sh
Last active May 31, 2021 02:19
How to run configure to crosscompile from x86_64 to arm
# CC C compiler command
# CFLAGS C compiler flags
# LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
# nonstandard directory <lib dir>
# LIBS libraries to pass to the linker, e.g. -l<library>
# CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
# you have headers in a nonstandard directory <include dir>
# CPP C preprocessor
# CXX C++ compiler command
# CXXFLAGS C++ compiler flags