### Basic Ktor Application with Routing Setup Source: https://metanit.com/kotlin/ktor/2.1 A complete example of a basic Ktor application using Netty as the engine. It demonstrates how to install the RoutingRoot plugin and define a simple GET route for the root path ("/") that responds with "Hello Ktor". ```kotlin package com.example import io.ktor.server.application.Application import io.ktor.server.application.install import io.ktor.server.engine.embeddedServer import io.ktor.server.netty.Netty import io.ktor.server.response.respondText import io.ktor.server.routing.* fun main(args: Array){ embeddedServer(Netty, port = 8080, module = Application::module) .start(wait = true) } fun Application.module() { install(RoutingRoot) { get("/") { call.respondText("Hello Ktor") } } } ``` -------------------------------- ### Install Go on Linux using Tarball and Update PATH Source: https://metanit.com/go/tutorial/1.1 This snippet demonstrates how to install Go on Linux by extracting a tarball archive and then updating the system's PATH environment variable to include the Go binary directory. It first removes any existing Go installation and then extracts the new version to /usr/local/go. Finally, it adds the Go bin directory to the PATH and sources the profile file for immediate effect. ```bash sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.4.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin source $HOME/.profile ``` -------------------------------- ### Verify NASM Installation Source: https://metanit.com/assembler/nasm/1.4 Command to check the installed version of the NASM assembler. This helps confirm a successful installation and provides version information. ```bash nasm -v ``` -------------------------------- ### Установка библиотек для X Window System на Debian/Ubuntu Source: https://metanit.com/cpp/vulkan/1.1 Команды для установки дополнительных библиотек, необходимых для работы с X Window System на Debian/Ubuntu. Включают libxxf86vm-dev и libxi-dev. ```bash sudo apt install libxxf86vm-dev sudo apt install libxi-dev ``` -------------------------------- ### MASM Program Structure with Comments (MASM) Source: https://metanit.com/assembler/tutorial/1.4 This snippet demonstrates how to include comments in a MASM program. Comments, denoted by a semicolon (;), are ignored by the assembler and are used for explaining the code. This example shows comments for the code section, the main function, the return instruction, and the end of the file. ```assembly .code ; начало секции с кодом программы main proc ; Функция main ret ; возвращаемся в вызывающий код main endp ; окончание функции main end ; конец файла кода ``` -------------------------------- ### Установка библиотек для X Window System на Fedora Source: https://metanit.com/cpp/vulkan/1.1 Команды для установки дополнительных библиотек, необходимых для работы с X Window System на Fedora. Включают libXxf86vm-devel и libXi-devel. ```bash dnf install libXxf86vm-devel dnf install libXi-devel ``` -------------------------------- ### Install NASM Assembler on Ubuntu Source: https://metanit.com/assembler/nasm/1.4 Commands to update package repositories and install the NASM assembler on Ubuntu systems. This ensures you have the necessary tools for assembly programming. ```bash sudo apt update sudo apt -y install nasm ``` -------------------------------- ### Start and Stop MongoDB Service using Homebrew Source: https://metanit.com/nosql/mongodb/1.4 Commands to manage the MongoDB service on macOS using Homebrew. 'brew services start' initiates the MongoDB server, while 'brew services stop' shuts it down. These commands assume MongoDB has been installed via Homebrew. ```bash brew services start mongodb-community@7.0 brew services stop mongodb-community@7.0 ``` -------------------------------- ### Создание нового консольного проекта .NET в WSL Source: https://metanit.com/sharp/tutorial/1.7 Эта команда использует .NET CLI для инициализации нового консольного приложения. Она создает необходимые файлы проекта, такие как Program.cs и .csproj файл. ```bash dotnet new console ``` -------------------------------- ### Rust Installation Interactive Prompt and Configuration Source: https://metanit.com/rust/tutorial/1.1 This snippet demonstrates the interactive installation process for Rust on Linux. It shows the user selecting the default installation option and the subsequent messages indicating successful installation and how to configure the shell environment. ```shell eugene@Eugene:~$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh info: downloading installer Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. Rustup metadata and toolchains will be installed into the Rustup home directory, located at: /home/eugene/.rustup This can be modified with the RUSTUP_HOME environment variable. The Cargo home directory is located at: /home/eugene/.cargo This can be modified with the CARGO_HOME environment variable. The cargo, rustc, rustup and other commands will be added to Cargo's bin directory, located at: /home/eugene/.cargo/bin This path will then be added to your PATH environment variable by modifying the profile files located at: /home/eugene/.profile /home/eugene/.bashrc You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable (default) profile: default modify PATH variable: yes 1) Proceed with standard installation (default - just press enter) 2) Customize installation 3) Cancel installation > 1 info: installing component 'rustc' 61.6 MiB / 61.6 MiB (100 %) 15.3 MiB/s in 4s ETA: 0s info: installing component 'rustfmt' info: default toolchain set to 'stable-x86_64-unknown-linux-gnu' stable-x86_64-unknown-linux-gnu installed - rustc 1.76.0 (07dca489a 2024-02-04) Rust is installed now. Great! To get started you may need to restart your current shell. This would reload your PATH environment variable to include Cargo's bin directory ($HOME/.cargo/bin). To configure your current shell, you need to source the corresponding env file under $HOME/.cargo. This is usually done by running one of the following (note the leading DOT): . "$HOME/.cargo/env" # For sh/bash/zsh/ash/dash/pdksh source "$HOME/.cargo/env.fish" # For fish eugene@Eugene:~$ ``` -------------------------------- ### Verify GCC Version Source: https://metanit.com/assembler/gas/1.4 Checks the installed version of the GNU Compiler Collection (GCC). This command is useful for confirming that the compiler toolchain, which includes the assembler, has been successfully installed. ```bash gcc --version ``` -------------------------------- ### Compile and Run C Program Example Source: https://metanit.com/c/patterns/4.5 This example shows the command-line instructions to compile and run the C program (`app.c` and `database.c`). It uses `gcc` with specific flags (`-Wall -pedantic`) to compile the source files into an executable named `app`. The output demonstrates the expected behavior of the database connection pooling module, showing the user lists for both clients. ```bash c:\C>gcc -Wall -pedantic app.c database.c -o app & app Users List for 1 client Tom Bob Sam Users List for 2 client Tom Bob Sam Alice c:\C> ``` -------------------------------- ### Verify MASM Assembler Installation (MASM) Source: https://metanit.com/assembler/tutorial/1.4 This snippet shows how to verify the MASM assembler installation by running the ml64 command in the Visual Studio Developer Command Prompt. It displays the assembler version and usage information, confirming that the tools are set up correctly. ```bash ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.5.5 ** Copyright (c) 2022 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' C:\Program Files\Microsoft Visual Studio\2022\Community>ml64 Microsoft (R) Macro Assembler (x64) Version 14.35.32217.1 Copyright (C) Microsoft Corporation. All rights reserved. usage: ML64 [ options ] filelist [ /link linkoptions] Run "ML64 /help" or "ML64 /?" for more info C:\Program Files\Microsoft Visual Studio\2022\Community> ``` -------------------------------- ### NASM Comments Source: https://metanit.com/assembler/nasm/1.4 Example of using comments in NASM assembly, denoted by a semicolon (;). Comments are ignored by the assembler and are used for explaining code. ```assembly global _start ; make _start label visible externally ``` -------------------------------- ### Простая программа 'Hello, World!' на C Source: https://metanit.com/c/tutorial/1.8 Этот код демонстрирует базовую структуру программы на C, включая подключение стандартной библиотеки ввода-вывода, определение функции main и вывод строки на консоль с помощью функции printf. Функция main возвращает 0 для обозначения успешного выполнения. ```c #include int main(void) { printf("Hello METANIT.COM!\n"); return 0; } ``` -------------------------------- ### Complete GtkApplication Example Source: https://metanit.com/c/gtk/1.4 A self-contained example demonstrating the creation, running, and memory management of a GtkApplication. ```APIDOC ## Complete GtkApplication Example ### Description This example shows a complete, runnable GTK application using GtkApplication, including initialization, running, and cleanup. ### Method Combination of `gtk_application_new()`, `g_application_run()`, and `g_object_unref()`. ### Parameters None directly for the example, but `gtk_application_new` and `g_application_run` take parameters as described previously. ### Request Example ```c #include int main(int argc, char **argv) { // Create the application GtkApplication *app = gtk_application_new ("com.metanit", G_APPLICATION_DEFAULT_FLAGS); // Run the application int status = g_application_run (G_APPLICATION (app), argc, argv); // Free the application memory g_object_unref(app); return status; } ``` ### Response #### Success Response (int) - The status code of the application execution. #### Response Example ```c // When compiled and run, this will launch a minimal GTK application. // A warning about g_application_activate() might appear if not implemented. ``` ``` -------------------------------- ### Install GCC Build Tools on Ubuntu Source: https://metanit.com/assembler/gas/1.4 Installs the 'build-essential' package, which includes GCC, make, and other development tools required for compiling software, including GNU Assembler. This command is essential for setting up a development environment on Ubuntu. ```bash sudo apt install build-essential ``` -------------------------------- ### Verify GNU Assembler Version Source: https://metanit.com/assembler/gas/1.4 Displays the version information for the GNU assembler (as). This command helps confirm the assembler component of the GNU Binutils is installed and accessible. ```bash as --version ``` -------------------------------- ### Create and Build WebApplication in C# Source: https://metanit.com/sharp/aspnet6/2.1 Demonstrates the basic setup of an ASP.NET Core application by creating a WebApplicationBuilder and then building the WebApplication instance. This is the entry point for configuring and running the application. ```csharp WebApplicationBuilder builder = WebApplication.CreateBuilder(); WebApplication app = builder.Build(); ``` -------------------------------- ### NASM Instruction: mov Source: https://metanit.com/assembler/nasm/1.4 Illustrates the 'mov' instruction in NASM assembly, used for moving data between registers and memory. This example shows setting system call numbers and arguments. ```assembly mov rax, 60 mov rdi, 22 ``` -------------------------------- ### Вывод 'Hello World!' в консоль на VB.NET Source: https://metanit.com/visualbasic/tutorial/1.2 Базовый пример вывода строки 'Hello World!' на консоль с использованием метода Console.WriteLine(). Этот метод является стандартным для вывода текстовой информации в консольное приложение. ```vb.net Sub Main() Console.WriteLine("Hello World!") End Sub ``` -------------------------------- ### Initialize GTK, Create Window, Add Button, and Run Event Loop (C) Source: https://metanit.com/c/gtk/2.1 This comprehensive C code example demonstrates the complete process of initializing the GTK library, creating a main window, setting its properties, creating a button, adding it to the window, and running the GTK event loop to display the application. It covers essential GTK application structure. ```c #include int main (int argc, char **argv) { gtk_init (); GtkWidget *window = gtk_window_new(); gtk_window_set_title (GTK_WINDOW (window), "METANIT.COM"); gtk_window_set_default_size(GTK_WINDOW (window), 250, 200); // создаем кнопку GtkWidget *button = gtk_button_new_with_label("Click"); // устанавливаем кнопку в качестве содержимого окна gtk_window_set_child (GTK_WINDOW (window), button); gtk_window_present (GTK_WINDOW (window)); while (g_list_model_get_n_items (gtk_window_get_toplevels ()) > 0) { g_main_context_iteration(NULL, TRUE); } return 0; } ``` -------------------------------- ### Compiling MASM Assembly with ml64 Source: https://metanit.com/assembler/tutorial/1.4 This command demonstrates how to compile and link a MASM assembly file named 'hello.asm' into an executable. It specifies the entry point for the program as the 'main' procedure. ```bash ml64 hello.asm /link /entry:main ``` -------------------------------- ### Update Package Repository on Ubuntu Source: https://metanit.com/assembler/gas/1.4 Updates the local package index to ensure you have the latest information about available packages. This is a prerequisite for installing new software on Ubuntu-based systems. ```bash sudo apt update ``` -------------------------------- ### Create GTK Application and Window Source: https://metanit.com/c/gtk/2.14 This C code snippet demonstrates how to create a basic GTK application and load a UI file to display a window. It initializes the GTK application, connects a signal handler for activation, and runs the application. ```c #include static void app_activate (GtkApplication *app, gpointer *user_data) { GtkBuilder* builder = gtk_builder_new_from_file("builder.ui"); GObject* window = gtk_builder_get_object (builder, "window"); g_object_unref (builder); gtk_window_set_application (GTK_WINDOW (window), app); gtk_window_present (GTK_WINDOW (window)); } int main (int argc, char **argv) { GtkApplication *app = gtk_application_new ("com.metanit", G_APPLICATION_DEFAULT_FLAGS); g_signal_connect (app, "activate", G_CALLBACK (app_activate), NULL); int status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref(app); return status; } ``` -------------------------------- ### Compiling and Running a GTK Application in C Source: https://metanit.com/c/gtk/1.4 This example shows the command-line instructions for compiling and running a GTK C application. It uses `pkg-config` to fetch the necessary compiler and linker flags for GTK4. The commands demonstrate how to compile the source file (`app.c`) into an executable (`app`) and then how to run the compiled application. ```bash gcc $(pkg-config --cflags gtk4) -o app app.c $(pkg-config --libs gtk4) ./app ``` -------------------------------- ### Manage PostgreSQL Service (Linux) Source: https://metanit.com/sql/postgresql/1.1 Provides commands to control the PostgreSQL server service on Linux systems. These include starting, restarting, and stopping the PostgreSQL server, which are crucial for administration and maintenance tasks. ```bash # Запуск sudo service postgresql start # Перезапуск sudo service postgresql restart # Остановка sudo service postgresql stop ``` -------------------------------- ### Компиляция программы на C с использованием Clang Source: https://metanit.com/c/tutorial/1.8 Эти команды показывают, как скомпилировать файл исходного кода C (`hello.c`) в исполняемый файл (`hello.exe`) с помощью компилятора Clang. Сначала используется `cd` для перехода в каталог с файлом, а затем `clang` для компиляции. ```bash cd C:\c ``` ```bash clang hello.c -o hello.exe ``` -------------------------------- ### GUID Route Constraint Example Source: https://metanit.com/visualbasic/aspnet/3.3 This example illustrates the GUID route constraint. The `{id:guid}` pattern ensures that the 'id' segment of the URL is a valid Globally Unique Identifier (GUID). This is often used for unique resource identifiers. ```csharp {id:guid} ``` -------------------------------- ### MASM Assembly Program Structure Source: https://metanit.com/assembler/tutorial/1.4 This is a basic MASM assembly program structure. It defines the code section, a main procedure, and returns control to the calling code. This serves as a minimal template for MASM programs. ```assembly .code main PROC ret main ENDP END ``` -------------------------------- ### C# GTK Application Setup and Window Creation Source: https://metanit.com/sharp/gtk/1.1 This snippet demonstrates the core logic for initializing a GTK application in C#. It includes setting up the application object, defining an activation handler to create and show a window, and running the application's event loop. Dependencies include the Gtk and Gio namespaces. ```csharp using Gtk; // подключаем пространство имен GTK // создаем объект приложения var app = Application.New("com.metanit.hello", Gio.ApplicationFlags.FlagsNone); // обработчик активации приложения app.OnActivate += (sender, args) => { Window window = new Window(); // Создаем новое окно window.Title = "METANIT.COM"; // Устанавливаем заголовок окна window.DefaultWidth = 250; // Устанавливаем начальную ширину окна window.DefaultHeight = 200; // Устанавливаем начальную высоту окна // Свойство Application окна указывает на текущий объект приложения window.Application = (Application) sender; window.Show(); // Отображаем окно на экране }; // запускаем приложение return app.RunWithSynchronizationContext(null); ``` -------------------------------- ### Install pip on Debian/Ubuntu Source: https://metanit.com/python/pytorch/1.1 Installs the pip package manager for Python on Debian or Ubuntu systems, which is required for installing PyTorch. ```bash sudo apt install python3-pip ``` -------------------------------- ### Kotlin: Full Execution Output Example Source: https://metanit.com/kotlin/tutorial/1.1 This example demonstrates the sequence of commands to navigate to the project directory, compile the Kotlin source file, and then run the compiled application. It shows the expected console output, including the 'Hello METANIT.COM' message. ```bash C:\Windows\system32>cd c:\kotlin c:\kotlin>c:\kotlinc\bin\kotlinc app.kt c:\kotlin>c:\kotlinc\bin\kotlin AppKt Hello METANIT.COM c:\kotlin> ``` -------------------------------- ### MASM Compilation and Linking Output Source: https://metanit.com/assembler/tutorial/1.4 This output shows the successful compilation and linking process of a MASM assembly program. It indicates the assembler version, linker version, and the generated output files, including 'hello.obj' and 'hello.exe'. ```bash ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.5.5 ** Copyright (c) 2022 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' C:\Program Files\Microsoft Visual Studio\2022\Community>cd c:\asm c:\asm>ml64 hello.asm /link /entry:main Microsoft (R) Macro Assembler (x64) Version 14.35.32217.1 Copyright (C) Microsoft Corporation. All rights reserved. Assembling: hello.asm Microsoft (R) Incremental Linker Version 14.35.32217.1 Copyright (C) Microsoft Corporation. All rights reserved. /OUT:hello.exe hello.obj /entry:main c:\asm> ``` -------------------------------- ### Установка Vulkan SDK через apt на Ubuntu Source: https://metanit.com/cpp/vulkan/1.1 Последовательность команд для установки Vulkan SDK на Ubuntu 24.04 с использованием пакетного менеджера apt. Включает добавление ключа GPG, добавление репозитория и установку пакета vulkan-sdk. ```bash wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.4.309-noble.list https://packages.lunarg.com/vulkan/1.4.309/lunarg-vulkan-1.4.309-noble.list sudo apt update sudo apt install vulkan-sdk ``` -------------------------------- ### Ввод и вывод данных в консоль на VB.NET Source: https://metanit.com/visualbasic/tutorial/1.2 Пример программы на VB.NET, которая запрашивает у пользователя ввод имени, считывает его и выводит персонализированное приветствие. Используются методы Console.Write, Console.ReadLine и форматирование строк с '$'. ```vb.net Module Program Sub Main() Console.Write("Введите имя: ") Dim name = Console.ReadLine() Console.WriteLine($"Привет, {name}") End Sub End Module ``` -------------------------------- ### Configure MongoDB Data and Log Directories (Intel) Source: https://metanit.com/nosql/mongodb/1.4 This is an example of a MongoDB configuration file for Intel x86-64 architecture. It specifies the paths for the log file and the database directory. Ensure the dbPath is accessible for read/write operations. ```yaml systemLog: destination: file path: /usr/local/var/log/mongodb/mongo.log logAppend: true storage: dbPath: /usr/local/var/mongodb net: bindIp: 127.0.0.1, ::1 ipv6: true ``` -------------------------------- ### Создание и запуск программы 'Hello World' на Си в Qt Creator Source: https://metanit.com/c/tutorial/1.7 Этот пример демонстрирует создание простого проекта на языке Си в Qt Creator. Он включает в себя написание базовой программы 'Hello World' и ее запуск. Проект создается с использованием шаблона 'Plain C Application'. ```c #include int main() { printf("Hello World!\n"); return 0; } ``` -------------------------------- ### VB.NET Imports Statement Source: https://metanit.com/visualbasic/tutorial/1.2 The 'Imports' statement in VB.NET is used to include namespaces, which organize .NET Framework functionality. This specific example imports the 'System' namespace, providing access to fundamental classes like 'Console'. ```vb.net Imports System ``` -------------------------------- ### Configure MongoDB Data Directory (Custom Path) Source: https://metanit.com/nosql/mongodb/1.4 This example shows how to customize the MongoDB data directory path in the configuration file. It sets the dbPath to a user-defined location. Ensure the specified directory is created and has appropriate write permissions. ```yaml systemLog: destination: file path: /usr/local/var/log/mongodb/mongo.log logAppend: true storage: dbPath: /Users/eugene/Documents/mongodb net: bindIp: 127.0.0.1, ::1 ipv6: true ```