GITEA EN typewriter

older-tomato

Code with comments

Problem solutions and solution descriptions

04.08.2023

Directory tree with links

Recursion • File processing • Web-navigation

We write a Bash script for building a directory tree for a repository in the Markdown file. We use only Bash tools and basic Linux software — ls, sed, tr and echo — without additional programs. The obtained file DIRECTORY_TREE.md will be used in the web interface to navigate through the objects of the repository.

We create a recursive function and use it to bypass all files and directories of the repository, excluding the list from .gitignore — we build a directory structure in the form of a tree. We output the elements as links <a>, collapse folders with one nested element into one line, place the constructed tree in a container <pre> and add the title — as a result, we get a short and concise Markdown file with links.


20.06.2023

Password generator

Cryptography • Random combinations

We write a program in JavaScript for the formation of random 20-symbol combinations of latin letters, numbers and special characters. There are 60 variants to choose from — 4 columns of 15 rows. First character — is always a letter, all characters in each combination go without repetitions. We will form passwords for web-sites in the browser.

I have been using this algorithm for a long time — I have all passwords for web-sites generated by this scheme, so I recommend it. The first version was written in Java, but for web-sites it turns out easier in JavaScript, so as not to go far.


08.03.2023

Drawing heart in console

Geometric figures • Text image • Font rendering

Let’s write two versions of the algorithm in Java to output a heart to the console in the form of a text image — let’s congratulate women on the eighth of March. Let’s draw a graph of the function in the form of a heart and, in addition, draw the symbol heart in the form of a picture, and output the picture as text — console congratulations on the eighth of March.


06.02.2023

Function graph in console

Geometric figures • Text image

Let’s write an algorithm to output a graph of a function or a system of equations to the console in the form of text. We will use Java tools. For calculations, we will use the Math class, and to bypass the range of coordinates, we will use two nested for loops. We draw in the console a graph of a circle and graphs of a rhombus and a square inscribed in it.


04.01.2023

Drawing simple captcha

Cryptography • Font rendering • Image rotation

Let’s write an algorithm for displaying text as an image using the Java AWT library. Symbols and font can be any, but for this example we will use a combination of uppercase latin letters and digits with the Comic Sans font — we will draw a simple captcha for a website or blog.

We’ll also consider special characters, but we won’t use them, because it will be difficult for the user to guess special characters with such a text decoration. For example, the plus + is still possible to guess, but the minus - or the underscore _ is already with difficulty, and even if you guess right, then to find these buttons with difficulty, especially on the phone. Therefore, for captcha we’ll use a combination of only capital latin letters and digits.


© Golovin G.G., Code with comments, translation from Russian, 2024