aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-08-12 09:18:27 -0300
committerEuAndreh <eu@euandre.org>2020-08-12 09:18:27 -0300
commit7901b532159fd5ab65c602e6e08048b48c14fc20 (patch)
treeeafd40a4b42a59f3c4db08921891cd68cc2dbaf6
parentscritps/assert-content.sh: Remove verbose JSON error output (diff)
downloadeuandre.org-7901b532159fd5ab65c602e6e08048b48c14fc20.tar.gz
euandre.org-7901b532159fd5ab65c602e6e08048b48c14fc20.tar.xz
Add TIL entry on filenames with timestamp, alongside with it's pt translation
-rw-r--r--_tils/2020-08-12-nome-de-arquivo-com-timestamp-simplificado.md34
-rw-r--r--_tils/2020-08-12-simple-filname-timestamp.md33
2 files changed, 67 insertions, 0 deletions
diff --git a/_tils/2020-08-12-nome-de-arquivo-com-timestamp-simplificado.md b/_tils/2020-08-12-nome-de-arquivo-com-timestamp-simplificado.md
new file mode 100644
index 0000000..4557e64
--- /dev/null
+++ b/_tils/2020-08-12-nome-de-arquivo-com-timestamp-simplificado.md
@@ -0,0 +1,34 @@
+---
+title: Nome de arquivo com timestamp simplificado
+date: 2020-08-12
+layout: til
+lang: pt
+ref: simple-filename-timestamp
+---
+Quando vou escrever um post no Jekyll ou criar um arquivo de log com a data no
+nome, eu normalmente engasgo para achar um jeito direto de fazer isso. Há um
+jeito bem simples de se fazer isso: `date -I`.
+
+```shell
+./meu-programa.sh > meu-programa.$(date -I).log
+cp template-de-post.md _posts/$(date -I)-slug-do-post.md
+```
+
+Usar essa ferramenta padrão do GNU/Linux permite que você simplesmente escreva
+`touch $(date -I).md` para criar um arquivo `2020-08-12.md`.
+
+Eu sempre tinha que parar para reler o `man date` ou buscar na internet de novo
+e de novo como fazer isso, e depois de sempre chegar no mesmo resultado ficou
+claro para mim que `date -I` quanto `date -Is` (`s` de segundos) são as
+respostas que eu estou procurando 95% do tempo:
+
+```shell
+# dentro do meu-programa.sh
+echo "Programa começou em $(date -Is)"
+# saída é:
+# Programa começou em 2020-08-12T09:15:16-03:00
+```
+
+Ambos os formatos de data são hierárquicos, com intervalos de tempo maior à
+esquerda. Isso significa que você pode facilmente ordená-los (e até usar TAB
+para completar) sem esforço ou ferramenta extra.
diff --git a/_tils/2020-08-12-simple-filname-timestamp.md b/_tils/2020-08-12-simple-filname-timestamp.md
new file mode 100644
index 0000000..7c112ff
--- /dev/null
+++ b/_tils/2020-08-12-simple-filname-timestamp.md
@@ -0,0 +1,33 @@
+---
+title: Simple filename timestamp
+date: 2020-08-12
+layout: til
+lang: en
+ref: simple-filename-timestamp
+---
+When writing Jekyll posts or creating logfiles with dates on them, I usually
+struggle with finding a direct way of accomplishing that. There's a simple
+solution: `date -I`.
+
+```shell
+./my-program.sh > my-program.$(date -I).log
+cp post-template.md _posts/$(date -I)-post-slug.md
+```
+
+Using this built-in GNU/Linux tool allows you to `touch $(date -I).md` to readly
+create a `2020-08-12.md` file.
+
+I always had to read `man date` or search the web over and over, and after doing
+this repeatedly it became clear that both `date -I` and `date -Is` (`s` here
+stands for seconds) are the thing that I'm looking for 95% of the time:
+
+```shell
+# inside my-program.sh
+echo "Program started at $(date -Is)"
+# output is:
+# Program started at 2020-08-12T09:04:58-03:00
+```
+
+Both date formats are hierarchical, having the bigger time intervals to the
+left. This means that you can easily sort them (and even tab-complete them) with
+no extra effort or tool required.