5/jekyll_site/en/index.md
2025-01-31 09:24:34 +03:00

4.1 KiB
Raw Permalink Blame History

title description sections tags canonical_url url_translated title_translated lang
Code with comments Notes about programming with code snippets and comments. Problem solutions and solution descriptions.
Problem solutions and solution descriptions
java
javascript
linux
bash
algorithms
implementation
text
fonts
combinations
images
pictures
cryptography
/en/ /ru/ Код с комментариями en

{%- assign articles = "" | split: "" %} {%- assign articles = articles | push: "Directory tree with links" %} {%- capture article_brief %} We write a Bash script for building a directory tree for a repository in the Markdown file. We use only Bash builtin tools and basic Linux software — ls, sed, tr and printf — without additional programs. The obtained file DIRECTORY_TREE.md is useful 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. {%- endcapture %} {%- assign articles = articles | push: article_brief %} {%- assign articles = articles | push: "Password generator" %} {%- capture article_brief %} 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. {%- endcapture %} {%- assign articles = articles | push: article_brief %} {%- assign articles = articles | push: "Drawing heart in console" %} {%- capture article_brief %} 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. {%- endcapture %} {%- assign articles = articles | push: article_brief %} {%- assign articles = articles | push: "Function graph in console" %} {%- capture article_brief %} 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. {%- endcapture %} {%- assign articles = articles | push: article_brief %} {%- assign articles = articles | push: "Drawing simple captcha" %} {%- capture article_brief %} 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. {%- endcapture %} {%- assign articles = articles | push: article_brief %} {%- include main_page.html articles = articles -%}