From b171347f739b2ada7960ad50bcba47e898d890d2 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Fri, 4 Jun 2021 23:50:58 -0600 Subject: reflect changes on updated pyssg using jinja templates --- blog/dst/a/asi_nomas_esta_quedando.html | 117 +++++++++++ blog/dst/a/el_blog_ya_tiene_timestamps.html | 37 ++-- blog/dst/a/first_blog_post.html | 37 ++-- blog/dst/a/git_server_with_cgit.html | 37 ++-- blog/dst/a/linux_video_notes.html | 35 ++-- blog/dst/a/mail_server_with_postfix.html | 37 ++-- blog/dst/a/new_blogging_system.html | 37 ++-- blog/dst/a/shell_scripting.html | 310 --------------------------- blog/dst/a/shell_scripting_video_notes.html | 313 ++++++++++++++++++++++++++++ blog/dst/a/sql_video_notes.html | 35 ++-- blog/dst/a/website_with_nginx.html | 37 ++-- 11 files changed, 594 insertions(+), 438 deletions(-) create mode 100644 blog/dst/a/asi_nomas_esta_quedando.html delete mode 100644 blog/dst/a/shell_scripting.html create mode 100644 blog/dst/a/shell_scripting_video_notes.html (limited to 'blog/dst/a') diff --git a/blog/dst/a/asi_nomas_esta_quedando.html b/blog/dst/a/asi_nomas_esta_quedando.html new file mode 100644 index 0000000..ca7c670 --- /dev/null +++ b/blog/dst/a/asi_nomas_esta_quedando.html @@ -0,0 +1,117 @@ + + + + + + + Así nomás está quedando el página -- Luévano's Blog + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + +
+
+ +
+

Así nomás está quedando el página

+ +

Estuve acomodando un poco más el sItIo, al fin agregué la “sección” de contact y de donate por si hay algún loco que quiere tirar varo.

+

También me puse a acomodar un servidor de XMPP el cual, en pocas palabras, es un protocolo de mensajería instantánea (y más) descentralizado, por lo cual cada quien puede hacer una cuenta en el servidor que quiera y conectarse con cuentas creadas en otro servidor… exacto, como con los correos electrónicos. Y esto está perro porque si tú tienes tu propio server, así como con uno de correo electrónico, puedes controlar qué características tiene, quiénes pueden hacer cuenta, si hay end-to-end encryption (o mínimo end-to-server), entre un montón de otras cosas.

+

Ahorita este server es SUMISO (compliant en español, jeje) para jalar con la app conversations y con la red social movim, pero realmente funcionaría con casi cualquier cliente de XMPP, amenos que ese cliente implemente algo que no tiene mi server. Y también acomodé un server de Matrix que es muy similar pero es bajo otro protocolo y se siente más como un discord/slack (al menos en el element), muy chingón también.

+

Si bien aún quedan cosas por hacer sobre estos dos servers que me acomodé (además de hacerles unas entradas para documentar cómo lo hice), quiero moverme a otra cosa que sería acomodar una sección de dibujos, lo cual en teoría es bien sencillo, pero como quiero poder automatizar la publicación de estos, quiero modificar un poco el pyssg para que jale chido para este pex.

+

Ya por último también quiero moverle un poco al CSS, porque lo dejé en un estado muy culerón y quiero meterle/ajustar unas cosas para que quede más limpio y medianamente bonito… dentro de lo que cabe porque evidentemente me vale verga si se ve como una página del 2000.

+ +
+ +
+ + + + \ No newline at end of file diff --git a/blog/dst/a/el_blog_ya_tiene_timestamps.html b/blog/dst/a/el_blog_ya_tiene_timestamps.html index 0859ee9..b4d6882 100644 --- a/blog/dst/a/el_blog_ya_tiene_timestamps.html +++ b/blog/dst/a/el_blog_ya_tiene_timestamps.html @@ -1,10 +1,10 @@ - + - Así es raza, el blog ya tiene timestamps -- Luévano's Blog + Así es raza, el blog ya tiene timestamps -- Luévano's Blog @@ -64,22 +64,27 @@
-

Así es raza, el blog ya tiene timestamps

-

Pues eso, esta entrada es sólo para tirar update sobre mi primer post. Ya modifiqué el ssg lo suficiente como para que maneje los timestamps, y ya estoy más familiarizado con este script entonces ya lo podré extender más, pero por ahora las entradas ya tienen su fecha de creación (y modificación en dado caso) al final y en el índice ya están organizados por fecha, que por ahora está algo simple pero está sencillo de extender.

+

Así es raza, el blog ya tiene timestamps

+ +

Pues eso, esta entrada es sólo para tirar update sobre mi primer post. Ya modifiqué el ssg lo suficiente como para que maneje los timestamps, y ya estoy más familiarizado con este script entonces ya lo podré extender más, pero por ahora las entradas ya tienen su fecha de creación (y modificación en dado caso) al final y en el índice ya están organizados por fecha, que por ahora está algo simple pero está sencillo de extender.

Ya lo único que queda es cambiar un poco el formato del blog (y de la página en general), porque en un momento de desesperación puse todo el texto en justificado y pues no se ve chido siempre, entonces queda corregir eso. Y aunque me tomó más tiempo del que quisiera, así nomás quedó, diría un cierto personaje.

El ssg modificado está en mis dotfiles (o directamente aquí).

Por último, también quité las extensiones .html de las URLs, porque se veía bien pitero, pero igual los links con .html al final redirigen a su link sin .html, así que no hay rollo alguno.

-
- + +
+
- + \ No newline at end of file diff --git a/blog/dst/a/first_blog_post.html b/blog/dst/a/first_blog_post.html index 3e03528..2e35fc3 100644 --- a/blog/dst/a/first_blog_post.html +++ b/blog/dst/a/first_blog_post.html @@ -1,10 +1,10 @@ - + - This is the first blog post, just for testing purposes -- Luévano's Blog + This is the first blog post, just for testing purposes -- Luévano's Blog @@ -64,21 +64,26 @@
-

This is the first blog post, just for testing purposes

-

I’m making this post just to figure out how ssg5 and lowdown are supposed to work (and eventually also rssg).

+

This is the first blog post, just for testing purposes

+ +

I’m making this post just to figure out how ssg5 and lowdown are supposed to work (and eventually also rssg).

At the moment, I’m not satisfied because there’s no automatic date insertion into the 1) html file, 2) the blog post itself and 3) the listing system in the blog homepage (and there’s also the problem with the ordering of the entries…). And all of this just because I didn’t want to use Luke’s solution (don’t really like that much how he handles the scripts… but they just work).

Hopefully, for tomorrow all of this will be sorted out and I’ll have a working blog system.

-
- + +
+
- + \ No newline at end of file diff --git a/blog/dst/a/git_server_with_cgit.html b/blog/dst/a/git_server_with_cgit.html index 6080592..81dde47 100644 --- a/blog/dst/a/git_server_with_cgit.html +++ b/blog/dst/a/git_server_with_cgit.html @@ -1,10 +1,10 @@ - + - Create a git server and setup cgit web app (on Nginx) -- Luévano's Blog + Create a git server and setup cgit web app (on Nginx) -- Luévano's Blog @@ -64,8 +64,9 @@
-

Create a git server and setup cgit web app (on Nginx)

-

My git server is all I need to setup to actually kill my other server (I’ve been moving from servers on these last 2-3 blog entries), that’s why I’m already doing this entry. I’m basically following git’s guide on setting up a server plus some specific stuff for (btw i use) Arch Linux (Arch Linux Wiki: Git server and Step by step guide on setting up git server in arch linux (pushable)).

+

Create a git server and setup cgit web app (on Nginx)

+ +

My git server is all I need to setup to actually kill my other server (I’ve been moving from servers on these last 2-3 blog entries), that’s why I’m already doing this entry. I’m basically following git’s guide on setting up a server plus some specific stuff for (btw i use) Arch Linux (Arch Linux Wiki: Git server and Step by step guide on setting up git server in arch linux (pushable)).

Note that this is mostly for personal use, so there’s no user/authentication control other than that of SSH. Also, most if not all commands here are run as root.

Prerequisites

I might get tired of saying this (it’s just copy paste, basically)… but similar as before (check my website and mail entries):

@@ -172,17 +173,21 @@ repo.desc=These are my personal dotfiles.

Otherwise you could let cgit to automatically detect your repositories (you have to be careful if you want to keep “private” repos) using the option scan-path and setup .git/description for each repository. I will add more to my actual configuration, but for now it is useful as it is. For more, you can check cgitrc(5).

Finally, if you want further support for highlighting, other compressed snapshots or support for markdown, checkout the optional dependencies for cgit and also the Arch Wiki goes in detail on how to setup highlighting with two different packages.

-
- + +
+
- + \ No newline at end of file diff --git a/blog/dst/a/linux_video_notes.html b/blog/dst/a/linux_video_notes.html index 7a6ef5d..c95cc00 100644 --- a/blog/dst/a/linux_video_notes.html +++ b/blog/dst/a/linux_video_notes.html @@ -1,10 +1,10 @@ - + - Linux tutorial video notes -- Luévano's Blog + Linux tutorial video notes -- Luévano's Blog @@ -64,8 +64,9 @@
-

Linux tutorial video notes

-

I was requested to make a summary of a video about basic Linux stuff (like the SQL tutorial video notes); this time, I did most of the notes depending on the topic since I’m familiar with most of the stuff presented in the video. The video in question is: The Complete Linux Course: Beginner to Power User!. Also, some notes were taken from Arch Linux Wiki since it’s got pretty decent documentation, and, of course, general googling.

+

Linux tutorial video notes

+ +

I was requested to make a summary of a video about basic Linux stuff (like the SQL tutorial video notes); this time, I did most of the notes depending on the topic since I’m familiar with most of the stuff presented in the video. The video in question is: The Complete Linux Course: Beginner to Power User!. Also, some notes were taken from Arch Linux Wiki since it’s got pretty decent documentation, and, of course, general googling.

(Basic) commands

A list of basic commands and small explanation (note that options are started with either - or --, depending on the program, but most of the time - is used for letter options and -- for word options, -l vs --list for example):

-
- + +
+
- + \ No newline at end of file diff --git a/blog/dst/a/mail_server_with_postfix.html b/blog/dst/a/mail_server_with_postfix.html index 3b983e6..190c4a5 100644 --- a/blog/dst/a/mail_server_with_postfix.html +++ b/blog/dst/a/mail_server_with_postfix.html @@ -1,10 +1,10 @@ - + - Create a mail server with Postfix, Dovecot, SpamAssassin and OpenDKIM -- Luévano's Blog + Create a mail server with Postfix, Dovecot, SpamAssassin and OpenDKIM -- Luévano's Blog @@ -64,8 +64,9 @@
-

Create a mail server with Postfix, Dovecot, SpamAssassin and OpenDKIM

-

The entry is going to be long because it’s a tedious process. This is also based on Luke Smith’s script, but adapted to Arch Linux (his script works on debian-based distributions). This entry is mostly so I can record all the notes required while I’m in the process of installing/configuring the mail server on a new VPS of mine; also I’m going to be writing a script that does everything in one go (for Arch Linux), that will be hosted here.

+

Create a mail server with Postfix, Dovecot, SpamAssassin and OpenDKIM

+ +

The entry is going to be long because it’s a tedious process. This is also based on Luke Smith’s script, but adapted to Arch Linux (his script works on debian-based distributions). This entry is mostly so I can record all the notes required while I’m in the process of installing/configuring the mail server on a new VPS of mine; also I’m going to be writing a script that does everything in one go (for Arch Linux), that will be hosted here.

This configuration works for local users (users that appear in /etc/passwd), and does not use any type of SQL. And note that most if not all commands executed here are run with root privileges.

More in depth configuration is detailed in the Arch Wiki for each package used here.

Prerequisites

@@ -427,17 +428,21 @@ systemctl enable spamassassin.service

DKIM Test successful

(Yes, I blurred a lot in the picture just to be sure, either way what’s important is the list on the bottom part of the image)

Finally, that’s actually it for this entry, if you have any problem whatsoever you have my info down below.

-
- + +
+
- + \ No newline at end of file diff --git a/blog/dst/a/new_blogging_system.html b/blog/dst/a/new_blogging_system.html index e3fae20..5ad639e 100644 --- a/blog/dst/a/new_blogging_system.html +++ b/blog/dst/a/new_blogging_system.html @@ -1,10 +1,10 @@ - + - I'm using a new blogging system -- Luévano's Blog + I'm using a new blogging system -- Luévano's Blog @@ -64,24 +64,29 @@
-

I'm using a new blogging system

-

So, I was tired of working with ssg (and then sbg which was a modified version of ssg that I “wrote”), for one general reason: not being able to extend it as I would like; and not just dumb little stuff, I wanted to be able to have more control, to add tags (which another tool that I found does: blogit), and even more in a future.

+

I'm using a new blogging system

+ +

So, I was tired of working with ssg (and then sbg which was a modified version of ssg that I “wrote”), for one general reason: not being able to extend it as I would like; and not just dumb little stuff, I wanted to be able to have more control, to add tags (which another tool that I found does: blogit), and even more in a future.

The solution? Write a new program “from scratch” in pYtHoN. Yes it is bloated, yes it is in its early stages, but it works just as I want it to work, and I’m pretty happy so far with the results and have with even more ideas in mind to “optimize” and generally clean my wOrKfLoW to post new blog entries. I even thought of using it for posting into a “feed” like gallery for drawings or pictures in general.

I called it pyssg, because it sounds nice and it wasn’t taken in the PyPi. It is just a terminal program that reads either a configuration file or the options passed as flags when calling the program.

It still uses Markdown files because I find them very easy to work with. And instead of just having a “header” and a “footer” applied to each parsed entry, you will have templates (generated with the program) for each piece that I thought made sense (idea taken from blogit): the common header and footer, the common header and footer for each entry and, header, footer and list elements for articles and tags. When parsing the Markdown file these templates are applied and stitched together to make a single HTML file. Also generates an RSS feed and the sitemap.xml file, which is nice.

It might sound convoluted, but it works pretty well, with of course room to improve; I’m open to suggestions, issue reporting or direct contributions here. BTW, it only works on Linux for now (and don’t think on making it work on windows, but feel free to do PR for the compatibility).

That’s it for now, the new RSS feed is available here: https://blog.luevano.xyz/rss.xml.

-
- + +
+
- + \ No newline at end of file diff --git a/blog/dst/a/shell_scripting.html b/blog/dst/a/shell_scripting.html deleted file mode 100644 index a9253d3..0000000 --- a/blog/dst/a/shell_scripting.html +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - - Shell scripting tutorial video notes -- Luévano's Blog - - - - - - - - - - - - - - - - - - - -
- - -
- - - -
-
- -
-

Shell scripting tutorial video notes

-

Another summary, this time about shell scripting in general. And just like with the Linux notes, I also did most of the notes myself or with resources outside the video. The videos in question are: The Bad Tutorials (YT): Shell Scripting Tutorials and Automation with SCripting (YT): Complete Shell Scripting Tutorials. Also, some notes were taken from tutorialspoint: UNIX / LINUX Tutorial and general googling.

-

Basic concepts

-

A shell it’s an interface between the user and the kernel. While the kernel it’s the layer that interacts between the shell and the hardware. And you access the shell either via a terminal, or executing a shell script. Note that if you’re using a GUI environment, you need a terminal emulator to actually use a terminal (most Linux distros come with everything needed, so no need to worry).

-

When using a terminal a blank screen with some text and a cursor that shows you where to type will appear and depending on the shell being used (sh, dash, ksh, bash, zsh, fish, etc.) the prompt will be different. The most common one being of the form user@host:~$, which tells that the user is using host machine and the current working directory is ~ (can be /any/path/ too), and lastly, the $ shows the current privileges of the shell/user using the shell (a $ for normal user and # for root access).

-

To clear the screen use command clear or simply do Ctrl + l (most terminals let you do this) and to cancel or create a new prompt do Ctrl + c, this also cancels any running program that’s using the terminal (typing q when a program is running also stops the process, sometimes).

-

Also there are POSIX (portable operating system interface) compliant shells like sh, dash, ksh, etc., that have a standard syntax and are portable to any Unix system. Non POSIX compliant shells (or not necessary fully POSIX compliant) are bash, zsh, fish, etc., that provide a more modern syntax but lack speed on executing scripts.

-

Common commands/programs

-

A list of common commands or programs with a short description (for more, do man command or command -h or command --help):

- -

And some special “commands” or “operators” (for more: gnu: 3.6 Redirections):

- -

Shell scripting

-

A shell script is nothing more but a file that contains commands in it; they’re executed in the same order they are present in the file. A shell script file is usually terminated with a .sh extension, independently of the shell being used, but it’s not 100% necessary as in Unix systems, an extension mean nothing, other than distinction (visually) between files. Then one can just have an extension-less file as a script. The script must have execution permissions (chmod +x file), unless shell script is executed in the terminal, where shell could be sh, bash, etc. Comments are created by prepending # to whatever the text should be a comment.

-

It’s common practice to have the first line as a she-bang (#!), which is just a comment telling the interpreter which shell to execute the script with (usable when having the script in your PATH so you only call the name of the script like any other command/program). A she-bang has the syntax #!/path/to/shell some_other_options, the most common she-bangs being: #!/bin/sh, #!/bin/bash, #!/usr/bin/python, etc.

-

Also, some people argue that you shouldn’t use absolute paths, since not all Unix operating systems have the same directory structure, or not all programs are going to be installed in the same folder. So a portable she-bang can be made by prepending /usr/bin/env and the specify the program to run, for example: #!/usr/bin/env bash.

-

Like always… the basic “Hello, world!” script:

-
#!/bin/sh
-echo "Hello, world!"
-
-

Three ways of executing this script (assuming the file name is hw):

-
    -
  1. Type in terminal sh hw.
  2. -
  3. Type in terminal ./hw. Requires the file to have execute permissions.
  4. -
  5. Type in terminal hw. Requires the file to have execute permissions. Requires the file to be in your PATH.
  6. -
-

Variables

-

Variables are case sensitive, meaning that my_var and MY_VAR are different and a variable name can only contain letters and numbers (a-z, A-Z and 0-9) or the underscore character _. Can’t contain a space. Variables are called by prepending $ to the variable name.

-

Like in most programming languages, there are some reserved words like if, select, then, until, while, etc., that can’t be used as variables or as values of variables. For more: D.2 Index of Shell Reserved Words.

-

There is no need to specify a variable type. Anything surrounded by " will be treated as text. You can use booleans, numbers, text and arrays (the implementation of arrays depends on the shell being used). Make a variable readonly by calling readonly variable_name. Basic syntax:

- -

There are special variables (for more. tutorialspoint: Unix / Linux - Special Variables):

- -

When calling a script, you can pass optional (or required) positional arguments like: command arg1 arg2 arg3 argn.

-

Note that a variable can also take the output of another command, one common way to do this is using $(command) or `command`, for example: var="$(echo 'this is a command being executed inside the definition of a variable')" which, since the echo command is being run, var="this is a command being executed inside the definition of a variable", which doesn’t seem like much, but there could be any command inside $() or `command`. Note that this is not special to defining variables, could also be used as arguments of another command.

-

Internal Field Separator (IFS)

-

This is used by the shell to determine how to do word splitting (how to recognize word boundaries). The default value for IFS consists of whitespace characters (space, tab and newline). This value can ve overridden by setting the variable IFS to something like, for example, :.

-

Conditionals

-

Exit status

-

Any command being run has an exit status, either 0 or 1, if the command has been executed successfully or otherwise (an error), respectively.

-

if statement

-

Pretty similar to other programming languages, evaluates an expression to a true or false and executes code as specified. if statements can be nested, and follow normal rules of logical operations. Basic syntax is:

-
#!/bin/sh
-if expression
-then
-do_something
-elif another_expression
-then
-do_another_thing
-else
-do_something_else
-fi
-
-

The expression is usually wrapped around [] or [[]], the first being POSIX compliant and the second bash-specific (and other shells).

-

Also, some operators to compare things use == for “equals” and > for “greater than”, for example; while in a POSIX compliant shell, = for “equals” and -gt for “greater than” has to be used. For more operators: tutorialspoint: Unix / Linux - Shell Basic Operators (this also covers logical operators and file test operators).

-

Case statement

-

A common good alternative to multilevel if statements, enables you to match several values against one variable. Basic syntax is:

-
case $var in
-    pattern1)
-        do_something1
-        ;;
-    pattern2)
-        subpattern1)
-            do_subsomething1
-            ;;
-        subpattern2)
-            do_subsomething2
-            ;;
-        *)
-    pattern3|pattern4|...|patternN)
-        do_something3
-        ;;
-    patternM)
-        do_somethingM
-        ;;
-    *)
-        do_something_default
-        ;;
-esac
-
-

Where the * pattern is not necessary but serves the same purpose as a “default” case.

-

Loops

-

Loops enable execution of a set of commands repeatedly. Loops, naturally, can be nested. expression here (in the basic syntax examples) work the same as mentioned in the “if statement” section. For more: tutorialspoint: Unix / Linux - Shell Loop Types.

-

Loop control

-

Similar than other programming languages, there are loop controls to interrupt or continue a loop:

-
* `break` statement.
-* `continue` statement.
-
-

These statements accept an argument that specify from which loop to exit/continue.

-

while loop

-

Enables to execute a set of commands repeatedly until some condition occurs. Basic syntax:

-
#!/bin/sh
-while expression
-do
-    do_something
-done
-
-

until loop

-

Similar to the while loop, the difference is that the while loop is executed as long as a condition is true, but the until loop… until a condition is true. Basic syntax (similar to while loop):

-
#!/bin/sh
-until expression
-do
-    do_something
-done
-
-

for loop

-

Operates on lists of items. It repeats a set of commands for every item in a list. Basic syntax:

-
#!/bin/sh
-for var in word1 word2 ... wordN
-do
-    do_something_with_var
-done
-
-

Where var is the current value (word1, word2, etc.) in the loop and the expression after for can refer to an array, or the output of a command that outputs a list of things, etc.

-

select loop

-

Provides an easy way to create a numbered menu from which users can select options. Basic syntax (similar to for loop):

-
select var in word1 word2 ... wordN
-do
-    do_something_with_var
-done
-
-

Meta characters

-

Meta characters are used to execute several commands on a single line (depending on what it’s needed). The most used meta characters to accomplish this are semi-colon ;, double ampersand && and double “pipe” ||.

- -

Functions

-

Enable to break down the overall functionality of a script into smaller, logical subsections, which can then be called upon to perform their individual tasks when needed (like in any other programming language…). For more: tutorialspoint: Unix / Linux - Shell Functions. Basic syntax:

-
#!/bin/sh
-function_name () {
-    do_something
-}
-
-

Functions can also take arguments and can access their individual arguments (each function will have a different “storage” for their arguments). Functions can also be nested. Here exit will not only will finish the function code, but also the shell script that called it, instead use return plus an exit code to just exit the function.

-
- -
- - - - diff --git a/blog/dst/a/shell_scripting_video_notes.html b/blog/dst/a/shell_scripting_video_notes.html new file mode 100644 index 0000000..d2ac546 --- /dev/null +++ b/blog/dst/a/shell_scripting_video_notes.html @@ -0,0 +1,313 @@ + + + + + + + Shell scripting tutorial video notes -- Luévano's Blog + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + +
+
+ +
+

Shell scripting tutorial video notes

+ +

Another summary, this time about shell scripting in general. And just like with the Linux notes, I also did most of the notes myself or with resources outside the video. The videos in question are: The Bad Tutorials (YT): Shell Scripting Tutorials and Automation with SCripting (YT): Complete Shell Scripting Tutorials. Also, some notes were taken from tutorialspoint: UNIX / LINUX Tutorial and general googling.

+

Basic concepts

+

A shell it’s an interface between the user and the kernel. While the kernel it’s the layer that interacts between the shell and the hardware. And you access the shell either via a terminal, or executing a shell script. Note that if you’re using a GUI environment, you need a terminal emulator to actually use a terminal (most Linux distros come with everything needed, so no need to worry).

+

When using a terminal a blank screen with some text and a cursor that shows you where to type will appear and depending on the shell being used (sh, dash, ksh, bash, zsh, fish, etc.) the prompt will be different. The most common one being of the form user@host:~$, which tells that the user is using host machine and the current working directory is ~ (can be /any/path/ too), and lastly, the $ shows the current privileges of the shell/user using the shell (a $ for normal user and # for root access).

+

To clear the screen use command clear or simply do Ctrl + l (most terminals let you do this) and to cancel or create a new prompt do Ctrl + c, this also cancels any running program that’s using the terminal (typing q when a program is running also stops the process, sometimes).

+

Also there are POSIX (portable operating system interface) compliant shells like sh, dash, ksh, etc., that have a standard syntax and are portable to any Unix system. Non POSIX compliant shells (or not necessary fully POSIX compliant) are bash, zsh, fish, etc., that provide a more modern syntax but lack speed on executing scripts.

+

Common commands/programs

+

A list of common commands or programs with a short description (for more, do man command or command -h or command --help):

+ +

And some special “commands” or “operators” (for more: gnu: 3.6 Redirections):

+ +

Shell scripting

+

A shell script is nothing more but a file that contains commands in it; they’re executed in the same order they are present in the file. A shell script file is usually terminated with a .sh extension, independently of the shell being used, but it’s not 100% necessary as in Unix systems, an extension mean nothing, other than distinction (visually) between files. Then one can just have an extension-less file as a script. The script must have execution permissions (chmod +x file), unless shell script is executed in the terminal, where shell could be sh, bash, etc. Comments are created by prepending # to whatever the text should be a comment.

+

It’s common practice to have the first line as a she-bang (#!), which is just a comment telling the interpreter which shell to execute the script with (usable when having the script in your PATH so you only call the name of the script like any other command/program). A she-bang has the syntax #!/path/to/shell some_other_options, the most common she-bangs being: #!/bin/sh, #!/bin/bash, #!/usr/bin/python, etc.

+

Also, some people argue that you shouldn’t use absolute paths, since not all Unix operating systems have the same directory structure, or not all programs are going to be installed in the same folder. So a portable she-bang can be made by prepending /usr/bin/env and the specify the program to run, for example: #!/usr/bin/env bash.

+

Like always… the basic “Hello, world!” script:

+
#!/bin/sh
+echo "Hello, world!"
+
+

Three ways of executing this script (assuming the file name is hw):

+
    +
  1. Type in terminal sh hw.
  2. +
  3. Type in terminal ./hw. Requires the file to have execute permissions.
  4. +
  5. Type in terminal hw. Requires the file to have execute permissions. Requires the file to be in your PATH.
  6. +
+

Variables

+

Variables are case sensitive, meaning that my_var and MY_VAR are different and a variable name can only contain letters and numbers (a-z, A-Z and 0-9) or the underscore character _. Can’t contain a space. Variables are called by prepending $ to the variable name.

+

Like in most programming languages, there are some reserved words like if, select, then, until, while, etc., that can’t be used as variables or as values of variables. For more: D.2 Index of Shell Reserved Words.

+

There is no need to specify a variable type. Anything surrounded by " will be treated as text. You can use booleans, numbers, text and arrays (the implementation of arrays depends on the shell being used). Make a variable readonly by calling readonly variable_name. Basic syntax:

+ +

There are special variables (for more. tutorialspoint: Unix / Linux - Special Variables):

+ +

When calling a script, you can pass optional (or required) positional arguments like: command arg1 arg2 arg3 argn.

+

Note that a variable can also take the output of another command, one common way to do this is using $(command) or `command`, for example: var="$(echo 'this is a command being executed inside the definition of a variable')" which, since the echo command is being run, var="this is a command being executed inside the definition of a variable", which doesn’t seem like much, but there could be any command inside $() or `command`. Note that this is not special to defining variables, could also be used as arguments of another command.

+

Internal Field Separator (IFS)

+

This is used by the shell to determine how to do word splitting (how to recognize word boundaries). The default value for IFS consists of whitespace characters (space, tab and newline). This value can ve overridden by setting the variable IFS to something like, for example, :.

+

Conditionals

+

Exit status

+

Any command being run has an exit status, either 0 or 1, if the command has been executed successfully or otherwise (an error), respectively.

+

if statement

+

Pretty similar to other programming languages, evaluates an expression to a true or false and executes code as specified. if statements can be nested, and follow normal rules of logical operations. Basic syntax is:

+
#!/bin/sh
+if expression
+then
+do_something
+elif another_expression
+then
+do_another_thing
+else
+do_something_else
+fi
+
+

The expression is usually wrapped around [] or [[]], the first being POSIX compliant and the second bash-specific (and other shells).

+

Also, some operators to compare things use == for “equals” and > for “greater than”, for example; while in a POSIX compliant shell, = for “equals” and -gt for “greater than” has to be used. For more operators: tutorialspoint: Unix / Linux - Shell Basic Operators (this also covers logical operators and file test operators).

+

Case statement

+

A common good alternative to multilevel if statements, enables you to match several values against one variable. Basic syntax is:

+
case $var in
+    pattern1)
+        do_something1
+        ;;
+    pattern2)
+        subpattern1)
+            do_subsomething1
+            ;;
+        subpattern2)
+            do_subsomething2
+            ;;
+        *)
+    pattern3|pattern4|...|patternN)
+        do_something3
+        ;;
+    patternM)
+        do_somethingM
+        ;;
+    *)
+        do_something_default
+        ;;
+esac
+
+

Where the * pattern is not necessary but serves the same purpose as a “default” case.

+

Loops

+

Loops enable execution of a set of commands repeatedly. Loops, naturally, can be nested. expression here (in the basic syntax examples) work the same as mentioned in the “if statement” section. For more: tutorialspoint: Unix / Linux - Shell Loop Types.

+

Loop control

+

Similar than other programming languages, there are loop controls to interrupt or continue a loop:

+
* `break` statement.
+* `continue` statement.
+
+

These statements accept an argument that specify from which loop to exit/continue.

+

while loop

+

Enables to execute a set of commands repeatedly until some condition occurs. Basic syntax:

+
#!/bin/sh
+while expression
+do
+    do_something
+done
+
+

until loop

+

Similar to the while loop, the difference is that the while loop is executed as long as a condition is true, but the until loop… until a condition is true. Basic syntax (similar to while loop):

+
#!/bin/sh
+until expression
+do
+    do_something
+done
+
+

for loop

+

Operates on lists of items. It repeats a set of commands for every item in a list. Basic syntax:

+
#!/bin/sh
+for var in word1 word2 ... wordN
+do
+    do_something_with_var
+done
+
+

Where var is the current value (word1, word2, etc.) in the loop and the expression after for can refer to an array, or the output of a command that outputs a list of things, etc.

+

select loop

+

Provides an easy way to create a numbered menu from which users can select options. Basic syntax (similar to for loop):

+
select var in word1 word2 ... wordN
+do
+    do_something_with_var
+done
+
+

Meta characters

+

Meta characters are used to execute several commands on a single line (depending on what it’s needed). The most used meta characters to accomplish this are semi-colon ;, double ampersand && and double “pipe” ||.

+ +

Functions

+

Enable to break down the overall functionality of a script into smaller, logical subsections, which can then be called upon to perform their individual tasks when needed (like in any other programming language…). For more: tutorialspoint: Unix / Linux - Shell Functions. Basic syntax:

+
#!/bin/sh
+function_name () {
+    do_something
+}
+
+

Functions can also take arguments and can access their individual arguments (each function will have a different “storage” for their arguments). Functions can also be nested. Here exit will not only will finish the function code, but also the shell script that called it, instead use return plus an exit code to just exit the function.

+ +
+ +
+ + + + \ No newline at end of file diff --git a/blog/dst/a/sql_video_notes.html b/blog/dst/a/sql_video_notes.html index 1ef739c..ae5c5c3 100644 --- a/blog/dst/a/sql_video_notes.html +++ b/blog/dst/a/sql_video_notes.html @@ -1,10 +1,10 @@ - + - SQL tutorial video notes -- Luévano's Blog + SQL tutorial video notes -- Luévano's Blog @@ -64,8 +64,9 @@
-

SQL tutorial video notes

-

I was requested to make summaries of videos about SQL, these are the notes (mostly this is a transcription of what I found useful). The videos in question are: SQL Tutorial - Full Database Course for Beginners, MySQL Tutorial for Beginners [Full Course] and Advanced SQL course | SQL tutorial advanced. Also, some notes were taken from w3schools.com’s SQL Tutorial and MySQL 8.0 Reference Manual.

+

SQL tutorial video notes

+ +

I was requested to make summaries of videos about SQL, these are the notes (mostly this is a transcription of what I found useful). The videos in question are: SQL Tutorial - Full Database Course for Beginners, MySQL Tutorial for Beginners [Full Course] and Advanced SQL course | SQL tutorial advanced. Also, some notes were taken from w3schools.com’s SQL Tutorial and MySQL 8.0 Reference Manual.

What is a database (DB)?

Any collection of related information, such as a phone book, a shopping list, Facebook’s user base, etc.. It can be stored in different ways: on paper, on a computer, in your mind, etc..

Database Management Systems (DBMS)

@@ -201,17 +202,19 @@
  • Identifying relationship: a diamond inside a diamond with its name inside; a relationship that serves to uniquely identify the weak entity.
  • ERD example taken from wikipedia

    -
    - + +
    +
    - + \ No newline at end of file diff --git a/blog/dst/a/website_with_nginx.html b/blog/dst/a/website_with_nginx.html index ae8c4b3..13d9ec6 100644 --- a/blog/dst/a/website_with_nginx.html +++ b/blog/dst/a/website_with_nginx.html @@ -1,10 +1,10 @@ - + - Create a website with Nginx and Certbot -- Luévano's Blog + Create a website with Nginx and Certbot -- Luévano's Blog @@ -64,8 +64,9 @@
    -

    Create a website with Nginx and Certbot

    -

    These are general notes on how to setup a Nginx web server plus Certbot for SSL certificates, initially learned from Luke’s video and after some use and research I added more stuff to the mix. And, actually at the time of writing this entry, I’m configuring the web server again on a new VPS instance, so this is going to be fresh.

    +

    Create a website with Nginx and Certbot

    + +

    These are general notes on how to setup a Nginx web server plus Certbot for SSL certificates, initially learned from Luke’s video and after some use and research I added more stuff to the mix. And, actually at the time of writing this entry, I’m configuring the web server again on a new VPS instance, so this is going to be fresh.

    As a side note, (((i use arch btw))) so everything here es aimed at an Arch Linux distro, and I’m doing everything on a VPS. Also note that most if not all commands here are executed with root privileges.

    Prerequisites

    You will need two things:

    @@ -177,17 +178,21 @@ systemctl restart nginx

    And a file will be opened where you need to add a new rule for certbot, just append the line: 1 1 1 * * certbot renew (renew on the first day of every month) and you’re good. Alternatively use systemd timers as stated in the Arch Linux Wiki.

    For more: Arch Linux Wiki: Certbot.

    That’s it, you now have a website with SSL certificate.

    -
    - + +
    +
    - + \ No newline at end of file -- cgit v1.2.3-70-g09d2