### Example Startup Link Source: https://speedsheet.io/s/linux An example of a startup link file located in the rc3.d directory, indicating the start order for a specific service. ```bash /etc/rc.d/rc3.d/S79apachewebserver ``` -------------------------------- ### Example: Poll for Start and Stop Commands Source: https://speedsheet.io/s/aiogram?q=bot-commands An example demonstrating how to register handlers for '/start' and '/stop' commands. ```Python from aiogram import Dispatcher async def process_message(message): if message.text == '/start': await message.answer('Starting.') else: await message.answer('Stopping.') dispatcher = Dispatcher(bot_1) dispatcher.register_message_handler( process_message, commands={'start', 'stop'}) await dispatcher.start_polling() ``` -------------------------------- ### Create MySQL Server Instance with Full Steps Source: https://speedsheet.io/s/mysql This sequence initializes a MySQL server, prompts to record the temporary password, starts the server using mysqld_safe, and then secures the installation. ```bash mysqld --initialize --user=root_user ``` ```bash mysqld_safe --user=root_user & ``` ```bash mysql_secure_installation ``` -------------------------------- ### Python Wheel - Setup Configuration Source: https://speedsheet.io/s/python?q=distribution Example `setup.py` file for creating a Python Wheel distribution. It specifies package metadata and includes necessary packages. ```python from setuptools import setup, find_packages setup( name='package_name', version='2.0.1', description='package description here.', packages=find_packages(exclude=['contrib', 'docs', 'tests']) ) ``` -------------------------------- ### Install fswatch Source: https://speedsheet.io/s/homebrew_packages Installs fswatch for monitoring file changes and reloading a browser. Includes a usage example. ```bash brew install fswatch ``` ```bash fswatch file_name file_name_2 ... | (while read; run_command; done) ``` -------------------------------- ### Basic Argparse Setup Source: https://speedsheet.io/s/python?q=argparse-only Initializes an ArgumentParser with a description. This is the starting point for defining command-line arguments. ```python from argparse import ArgumentParser parser = ArgumentParser(description = 'description') ``` -------------------------------- ### Create Startup Link Example Source: https://speedsheet.io/s/linux This command creates a symbolic link for a service to start in run level 3. Ensure the source script path and link name format are correct. ```bash sudo ln -s /etc/rc.d/init.d/service_1 /etc/rc.d/rc3.d/S91service_1 ``` -------------------------------- ### Aiohttp GET Request Example Source: https://speedsheet.io/s/aiohttp?q=examples-only Demonstrates how to perform a simple GET request and retrieve the response text. ```python from aiohttp import ClientSession from asyncio import run async def main(): url = "https://httpbin.org/get" async with ClientSession() as session: response = await session.get('https://httpbin.org/get') text = await response.text() print(text) run(main()) ``` -------------------------------- ### Add Startup Link for init.d Service Source: https://speedsheet.io/s/linux These examples show how to create symbolic links to ensure a service starts automatically at specific run levels. The 'S' prefix and '99' indicate startup order. ```bash /etc/rc.d/rc2.d/S99service_name ``` ```bash /etc/rc.d/rc3.d/S99service_name ``` -------------------------------- ### Example Test Class with Assertions Source: https://speedsheet.io/s/python?q=unit+tests Demonstrates a simple test class with `setUp` and `tearDown` methods, and includes examples of `assertTrue` and `assertFalse` assertions. ```python from unittest import TestCase class BasicTest(TestCase): def setUp(self): self.field1 = True def tearDown(self): self.field1 = None def test_IsTrue(self): self.assertTrue(self.field1, "failed_assertion_message") def test_IsFalse(self): self.assertFalse(self.field1, "failed_assertion_message") ``` -------------------------------- ### Install htop Source: https://speedsheet.io/s/homebrew_packages Installs htop, an interactive process viewer, using Homebrew. ```bash brew install htop ``` -------------------------------- ### Match - Get Start Position Source: https://speedsheet.io/s/rust_regex Get the starting index of the matched text within the original string. ```rust = match_1.start() ``` -------------------------------- ### Install go Source: https://speedsheet.io/s/homebrew_packages Installs the Go programming language using Homebrew. ```bash brew install go ``` -------------------------------- ### MySQL Regex Example: Match Last Name Starting with 'O' Source: https://speedsheet.io/s/regex?q=mysql Example query to select all contacts from the 'contacts' table where the 'last_name' field starts with 'O' using a regular expression. ```sql SELECT * FROM contacts WHERE last_name REGEX '^O' ``` -------------------------------- ### Get Match Start Position Source: https://speedsheet.io/s/rust_regex?q=match-only Returns the byte index of the start of the match within the original string. ```rust match_1.start() ``` -------------------------------- ### Start Application with Arguments Source: https://speedsheet.io/s/dos Use the 'start' command to launch an application, optionally with arguments such as a file to open. ```bash start notepad text_file ``` -------------------------------- ### Initialize Repository, Add All Files, and Commit Source: https://speedsheet.io/s/git Creates a new repository, adds all files to be tracked, and makes the initial commit. ```bash git init git add -A git commit -m "Initial commit." ``` ```bash git init && git add -A && git commit -m "Initial commit." ``` -------------------------------- ### Create and Start a Basic Process Source: https://speedsheet.io/s/python?q=process-only Demonstrates how to create a process with a target function and arguments, start it, and wait for its completion. ```python from processing import Process # Define a worker function (assuming worker_function and worker_argument_1 are defined elsewhere) # def worker_function(arg): # pass # worker_argument_1 = "some_value" process_1 = Process( target = worker_function, args = (worker_argument_1,) process_1.start() process_1.join() ``` -------------------------------- ### Install pynput from requirements.txt Source: https://speedsheet.io/s/pynput?q=install-only Install pynput by referencing it in a requirements.txt file and using the pip install -r command. ```text pynput ``` ```bash pip install -r requiremets.txt ``` -------------------------------- ### Get Sublist from Array Source: https://speedsheet.io/s/javascript?q=array-only Extracts a portion of an array into a new array. Can specify start index or start and end indices. ```javascript let sublist = array1.slice(start); ``` ```javascript let sublist = array1.slice(start, end); ``` -------------------------------- ### builder.setup Source: https://speedsheet.io/s/tauri Specifies a setup function to be executed once when the application is built. This function receives the application instance and can be used for initialization tasks. ```APIDOC ## Builder - Setup App ### Description Defines a setup function that runs once during the application's build process. This function receives a mutable reference to the `App` instance, allowing for initial configuration and setup tasks. ### Method `setup(setup_function)` ### Endpoint N/A (Builder method) ### Parameters - **setup_function** (`FnOnce(&mut App) -> Result<(), Box> + Send + 'static`): A closure that takes a mutable reference to the `App` and returns a `Result`. ### Request Example ```rust builder.setup(|app| { // Perform setup tasks here println!("Tauri app setup complete!"); Ok(()) }); ``` ### Response Returns the modified `Builder` instance. ``` -------------------------------- ### Install http-server Source: https://speedsheet.io/s/homebrew_packages Installs a command-line folder synchronization tool using Homebrew. ```bash brew install http-server ``` -------------------------------- ### Get Element Type Example Source: https://speedsheet.io/s/javascript Demonstrates how to get the nodeName and tagName of an element. nodeName is generally preferred as it applies to all node types. ```javascript
...
``` -------------------------------- ### Setup Express Application Source: https://speedsheet.io/s/node_js Initializes an Express application instance. ```javascript var express = require('express') var app = express() ``` -------------------------------- ### Minimal setup.py for Packaging Source: https://speedsheet.io/s/python?q=how-to A basic `setup.py` file using setuptools for defining package metadata and structure. Assumes source code is within a 'src' directory. ```python from setuptools import find_packages, setup setup( name='app_name', version='1.0.0', description='App description.', packages=find_packages('src'), package_dir={'': 'src'} ) ``` -------------------------------- ### Get Pytest Version Source: https://speedsheet.io/s/pytest?q=commands-only Displays the installed Pytest version. ```bash pytest --version ``` -------------------------------- ### Sample package.json Configuration Source: https://speedsheet.io/s/node_js An example of a more comprehensive package.json file, including keywords, repository details, and scripts. ```json { "name": "package_name", "version": "1.0.0", "description": "App description.", "author": "Author Name", "license": "MIT", "homepage": "https://github.com/owner/repo_name#readme" "keywords": [ "keyword_1", "keyword_2" ], "bugs": { "url": "https://github.com/owner/repo_name/issues" }, "repository": { "type": "git", "url": "git+https://github.com/owner/repo_name.git" }, "main": "index.js", "dependencies": { "library_name": "1.0.0" }, "scripts": { "start": "start_command", "test": "test_command" } } ``` -------------------------------- ### Get Remainder of 1D Array Source: https://speedsheet.io/s/numpy?q=array+slicing Extract a subarray from a specified start index to the end of the 1D NumPy array, effectively getting the remainder. ```python from numpy import array array_1 = array([0, 1, 2, 3, 4]) remainder = array_1[1:] # Returns [1, 2, 3, 4] ``` -------------------------------- ### Install Project Dependencies Source: https://speedsheet.io/s/node_js Installs all the libraries and dependencies listed in the package.json file. ```bash npm install ``` -------------------------------- ### User Application Configuration Directory Examples Source: https://speedsheet.io/s/macos Illustrates the paths for user-specific application configuration directories using Unix-style dotfiles. ```bash ${HOME}/.config ``` ```bash ${HOME}/.config/app_name ``` -------------------------------- ### Extract Right Substring in Lua Source: https://speedsheet.io/s/lua Get the rightmost part of a string by specifying the starting index. All characters from the start index to the end of the string are returned. ```lua local string1 = "12345" right = string1:sub(4) print(right) -- Prints: 45 ``` -------------------------------- ### Example Bash Prompt: Host and Path Source: https://speedsheet.io/s/bash Configures the prompt to show the hostname and the current working directory. Example output: host-1:~/downloads>. ```bash PS1="\h:\w>" ``` -------------------------------- ### Open Application with Parameters Source: https://speedsheet.io/s/macos Launch an application, optionally with parameters. Use -a to open the application and -n to open a new instance. ```bash open -a application.app param1... ``` ```bash open -n application.app param1... ``` -------------------------------- ### Get Exit Code from Bash Function (Example) Source: https://speedsheet.io/s/bash An example showing how to retrieve the exit code of the last executed function using the '$?' special variable. ```bash function_1() { return 1 } function_1 return_code=$? echo "$return_code" # Prints: 1 ``` -------------------------------- ### Install Package Source: https://speedsheet.io/s/python?q=pip-only Installs a package by its name. You can also specify a version. ```bash pip install package_name ``` ```bash pip install package_name==1.2.3 ``` -------------------------------- ### Async Tokio Example with Mini Redis Client Source: https://speedsheet.io/s/rust_tools Demonstrates basic asynchronous operations using Tokio and a mini-redis client to set and get a key-value pair. Requires `tokio` and `mini_redis` crates. ```rust use mini_redis::{client, Result as redis_Result}; #[tokio::main] async fn main() -> redis_Result<()> { println!("in tokio"); let mut client = client::connect("127.0.0.1:6379").await?; client.set("hello", "world".into()).await?; let result = client.get("hello").await?; println!("got value result={:?}", result); Ok(()) } ``` -------------------------------- ### Initialize New Project Source: https://speedsheet.io/s/node_js Creates a package.json file for a new project. Run this command from the project's root directory. It will prompt for default values. ```bash npm init ``` -------------------------------- ### Get PIP Version Source: https://speedsheet.io/s/python?q=pip-only Displays the currently installed version of PIP. ```bash pip -V ``` ```bash pip --version ``` -------------------------------- ### RPi.GPIO - Control an LED Source: https://speedsheet.io/s/raspberry_pi Example of setting up a pin as an output and turning an LED on using RPi.GPIO. ```python import RPi.GPIO as GPIO LED_PIN = 18 GPIO.setmode(GPIO.BCM) GPIO.setup(LED_PIN, GPIO.OUT) # Turn On: GPIO.output(LED_PIN, GPIO.HIGH) ``` -------------------------------- ### Invalid Identifier Examples Source: https://speedsheet.io/s/rust?q=fundamentals-only Identifiers cannot be a single underscore or start with a digit. ```Rust _ 3_items 🎈 ``` -------------------------------- ### Get Rust Compiler Version Source: https://speedsheet.io/s/rust?q=command-line-only Displays the installed version of the Rust compiler. ```rust rustc -V ``` ```rust rustc --version ``` -------------------------------- ### Aiohttp Hello World GET Request Source: https://speedsheet.io/s/aiohttp?q=hello-world-only This script makes a GET request to https://httpbin.org/get using aiohttp and prints the response body. It requires the aiohttp library to be installed. ```python from aiohttp import ClientSession from asyncio import run async def main(): async with ClientSession() as session: response = await session.get('https://httpbin.org/get') text = await response.text() print(text) run(main()) ``` -------------------------------- ### Start MySQL Server Source: https://speedsheet.io/s/mysql Starts the MySQL database server process. ```bash mysqld ``` -------------------------------- ### Tauri Setup Function Source: https://speedsheet.io/s/tauri?q=app Calls a setup function during the build process, passing an instance of the application. This function can perform initial setup tasks. ```rust builder_1.setup(|app| { ... }) ``` -------------------------------- ### Hello World Example Source: https://speedsheet.io/s/rand A basic 'Hello World' example demonstrating the use of the rand crate to generate a random float and print it. ```Rust use rand::prelude::*; fn main() { let mut random = rand::rng(); let random_float: f64 = random.gen(); println!("{}", random_float); } ``` -------------------------------- ### Get Substring from Start Index to End (ASCII Only) Source: https://speedsheet.io/s/rust?q=string-only Extracts a substring from a specified start index to the end of the string using direct slicing. This method is NOT safe for Unicode strings. ```rust let string_1 = "12345".to_string(); let index_1_to_end = &string_1[1..]; // "2345" ``` -------------------------------- ### package.json Example Source: https://speedsheet.io/s/node_js A sample package.json file demonstrating dependencies, including versioning with the caret symbol, and script definitions for running the application. ```json { "name": "AppName", "version": "1.0.0", "devDependencies": { "dependencyName": "^1.2.3", "express": "^4.15.2", "mysql": "^2.13.0" }, "scripts" : { "npmCommand": "node javascript_command_file.js", "start": "node server.js" } } ``` -------------------------------- ### Match - Get Range Source: https://speedsheet.io/s/rust_regex Retrieve the start and end indices of the matched text as a range. ```rust = match_1.range() ``` -------------------------------- ### Get Python Home Directory Source: https://speedsheet.io/s/python?q=how-to Retrieves the installation prefix of the current Python environment. ```python from sys import prefix python_home_directory = prefix ``` -------------------------------- ### Test Setup Method Source: https://speedsheet.io/s/python?q=unit+tests Demonstrates the `setUp` method, which is executed before each test method in a test class. It's used to initialize test-specific data or state. ```python class TestClass1(TestCase): def setUp(self): ... ``` -------------------------------- ### Start EC2 Instances Source: https://speedsheet.io/s/aws Starts specified EC2 instances. ```bash aws ec2 start-instances --instance-ids instance_id ``` -------------------------------- ### Inline Comment Example Source: https://speedsheet.io/s/rust?q=fundamentals-only Inline comments start with '//' and are used for single-line explanations. ```Rust // This is a comment. Start a comment with '//'. ``` -------------------------------- ### Hello World with Color Source: https://speedsheet.io/s/colored A basic example demonstrating how to print a colored string to the terminal using the colored library. ```Rust use colored::* fn main() { println!("{}", "Hello World (Light Cyan on Dark Blue".bright_cyan().on_blue()); } ``` -------------------------------- ### Create and Start a Process Using a Class Source: https://speedsheet.io/s/python Shows how to define a custom process class by inheriting from `Process` and overriding the `run` method, then creating and starting an instance. ```python from processing import Process class ProcessClass(Process): def run(self): print("ProcessClass is running") # Create process_1 = ProcessClass() # Start process_1.start() # Wait for Completion process_1.join() ``` -------------------------------- ### GET Request Example Source: https://speedsheet.io/s/http?q=verbs-only Use GET to retrieve a web resource. Parameters are passed in the URL and must be escaped. GET requests can be cached, remain in browser history, can be bookmarked, and have length restrictions. They should only be used for retrieving data and never with sensitive information. ```HTTP http://www.site.com/login?user=test1&password=pass123 ``` -------------------------------- ### Initialize Poetry for an Existing Project Source: https://speedsheet.io/s/poetry?q=project-only Sets up a Poetry environment for a project that does not yet have a `pyproject.toml` file. It will create this file. ```bash poetry init ``` -------------------------------- ### Get Starting Module Name Source: https://speedsheet.io/s/python?q=how-to Retrieves the name of the Python script file that was initially executed. ```python from sys import argv module_name = argv[0] ``` -------------------------------- ### Create and Start a Process Using a Class Source: https://speedsheet.io/s/python?q=process-only Shows how to define a custom process class by inheriting from 'Process' and overriding the 'run' method, then creating and managing an instance. ```python from processing import Process class ProcessClass(Process): def run(self): # Custom process logic here pass process_1 = ProcessClass() process_1.start() process_1.join() ``` -------------------------------- ### Multiline Comment Example Source: https://speedsheet.io/s/rust?q=fundamentals-only Multiline comments start with '/*' and end with '*/', allowing for longer explanations. ```Rust /* Multiline Comment */ Start a multiline comment with '`/*`'. End with '`*/>' ``` -------------------------------- ### Create Virtual Environment and Install Dependencies Source: https://speedsheet.io/s/poetry Creates a new virtual environment using the specified Python executable and then installs all project dependencies. This is a convenient way to set up a project from scratch. ```bash poetry env use python3 poetry install ``` ```bash poetry env use python3.exe poetry install ``` -------------------------------- ### Get Variable Type Name in Python Source: https://speedsheet.io/s/python?q=type%28%29 Access the `__name__` attribute of the type object returned by `type()` to get the type's name as a string. For example, `type(1.0).__name__` returns `'float'`. ```python float_1 = 1.0 print(type(float_1).__name__) # Prints `'float'`. ``` -------------------------------- ### Initialize Go Workspace Source: https://speedsheet.io/s/go?q=Create+Workspace Use `go work init` to create a new workspace. Provide the paths to the modules you want to include in the workspace. ```go go work init module1 module2 ... ``` ```go go work init ./main ./utils ``` -------------------------------- ### Monitor - Position Source: https://speedsheet.io/s/tauri Gets the physical position of the monitor on the screen. This is useful for window placement and multi-monitor setups. ```APIDOC ## Monitor - Position ### Description Gets the physical position of the monitor on the screen. This is useful for window placement and multi-monitor setups. ### Method ```rust monitor.position() ``` ### Returns - **&PhysicalPosition** - A reference to the monitor's position (x, y coordinates). ### Example ```rust let position = monitor.position(); println!("Monitor position: x={}, y={}", position.x, position.y); ``` ``` -------------------------------- ### builder_1.setup(setup_function) Source: https://speedsheet.io/s/tauri?q=builder Specifies a setup function to be called during the application build process. This function receives a mutable reference to the application instance and can be used for initial configuration. ```APIDOC ## Builder - Setup App `builder_1.setup(setup_function)` ### Description Specifies a setup function to be called during the application build process. This function receives a mutable reference to the application instance and can be used for initial configuration. ### Method `setup` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters - **setup_function** (FnOnce(&mut App) -> Result<(), Box> + Send + 'static) - Required - The function to execute during application setup. ### Usage Example ```rust builder_1.setup(|app| { ... }) ``` ### Response N/A ``` -------------------------------- ### Python Sequence - Get Sublist From Position Source: https://speedsheet.io/s/python?q=slice-only Extracts a sublist from a specified start index to the end of the sequence. ```python list_1 = [0, 1, 2, 3, 4] value = list_1[2:] # Returns [2, 3, 4] ``` -------------------------------- ### User Application Support Directory Examples Source: https://speedsheet.io/s/macos Shows the paths for user-specific application support directories, including general and app-specific locations. ```bash ${HOME}/Library/Application Support ``` ```bash ${HOME}/Library/Application Support/app_name ``` -------------------------------- ### Create Environment and Install Dependencies Source: https://speedsheet.io/s/poetry?q=environment-only Creates a new virtual environment using the default Python executable and then installs all project dependencies. This is a convenient way to set up a new project environment. ```bash poetry env use python3 poetry install ``` ```bash poetry env use python3.exe poetry install ``` -------------------------------- ### Get Java Home Directory Source: https://speedsheet.io/s/macos Finds the path to the current Java Development Kit (JDK) installation. ```bash /usr/libexec/java_home ``` -------------------------------- ### builder_1.setup Source: https://speedsheet.io/s/tauri?q=Rust Calls a setup function during the application build process. This function receives a mutable reference to the application instance, allowing for initial configuration and setup logic. ```APIDOC ## builder_1.setup ### Description Calls a setup function during the application build process. This function receives a mutable reference to the application instance, allowing for initial configuration and setup logic. ### Method Rust ### Endpoint N/A ### Parameters - **setup_function** (FnOnce(&mut App) -> Result<(), Box> + Send + 'static) - Required - The setup function to execute. ### Request Example ```rust builder_1.setup(|app| { ... }) ``` ### Response None. Modifies the builder instance. ``` -------------------------------- ### Valid Identifier Examples Source: https://speedsheet.io/s/rust?q=fundamentals-only Identifiers must start with a letter or underscore and can contain letters, numbers, or underscores. ```Rust _identifier identifier 식별자 item_1 ``` -------------------------------- ### Python Comment Example Source: https://speedsheet.io/s/python?q=fundamentals-only Use the hash symbol '#' to start a comment. Comments are ignored by the Python interpreter. ```python # This is a comment. Start the comment with a hash '#'. Comments are ignored by the compiler. ``` -------------------------------- ### Get Element Name Source: https://speedsheet.io/s/beautiful_soup?q=element-properties-only Retrieves the tag name of an element. For example, a 'div' element will return 'div'. ```python element.name ``` -------------------------------- ### Render Jinja Template from File Example Source: https://speedsheet.io/s/jinja Demonstrates creating and rendering a Jinja template loaded from a file named 'hello.text'. ```python from jinja2 import Environment, FileSystemLoader loader = FileSystemLoader('.') environment = Environment(loader = loader) template = environment.get_template('hello.text') result = template.render(name = 'John') print(result) ``` -------------------------------- ### GET Request Handling Source: https://speedsheet.io/s/spring_boot Demonstrates how to define a GET endpoint using @GetMapping. It can be used to retrieve data from the server. The example shows a basic health check endpoint and a user retrieval endpoint with a path variable. ```APIDOC ## GET / ### Description Handles GET requests to the root path. ### Method GET ### Endpoint / ### Parameters None ### Request Example None ### Response #### Success Response (200) - **body** (String) - A confirmation message. #### Response Example ``` "The system is up 👍" ``` ## GET /health ### Description Provides a health check endpoint for the system. ### Method GET ### Endpoint /health ### Parameters None ### Request Example None ### Response #### Success Response (200) - **body** (String) - A confirmation message indicating the system is up. #### Response Example ``` "The system is up 👍" ``` ## GET /api/user/{id} ### Description Retrieves a specific user by their ID. ### Method GET ### Endpoint /api/user/{id} ### Parameters #### Path Parameters - **id** (int) - Required - The unique identifier of the user to retrieve. ### Request Example None ### Response #### Success Response (200) - **body** (User) - The User object corresponding to the provided ID. #### Response Example ```json { "id": 1, "name": "John Doe" } ``` ``` -------------------------------- ### Rust BufReader Basics Example Source: https://speedsheet.io/s/rust?q=file+io Demonstrates how to open a file, create a BufReader, and read its contents into a buffer in a loop until the end of the file is reached. ```rust use std::fs::File; use std::io::BufReader; use std::io::Read; // Open: let file = File::open(path)?; let mut reader = BufReader::new(file); let mut buffer = [0_u8; max_size]; // Read: loop { let size = match reader.read(&mut buffer) { Err(error) => return Err(error), Ok(0) => break, // EOF Ok(size) => size, }; let content = &buffer[..size]; ... } ``` -------------------------------- ### Get Registry Instance Source: https://speedsheet.io/s/tracing Retrieves an instance of the tracing subscriber registry. This is the starting point for building a subscriber pipeline. ```rust use tracing_subscriber::registry; reg = registry() ``` -------------------------------- ### Trie - Get Prefixed Subtree Operation Source: https://speedsheet.io/s/rust_radix_trie Retrieves a subtree containing all items that start with the specified partial key. ```APIDOC ## Trie - Get Prefixed Subtree ### Description Returns all items that starts with the partial key. ### Method `get_raw_descendant(partial_key)` ### Parameters - **partial_key**: The prefix to search for. ### Returns `SubTrie` - A SubTrie containing entries that match the prefix. ### Docs radix_trie::Trie.get_raw_descendant ``` -------------------------------- ### Start an init.d Service Source: https://speedsheet.io/s/linux Use this command to start a service managed by init.d. The exact path to the script may vary depending on the operating system. ```bash /etc/init.d/script_name start ``` ```bash /etc/rc.d/init.d/script_name start ``` -------------------------------- ### Rust Trie Get Prefixed Subtree Source: https://speedsheet.io/s/rust_radix_trie Retrieves a `SubTrie` containing all items that start with the given partial key. ```rust // Assuming trie_1 is a valid Trie and partial_key is of the appropriate type // let subtrie = trie_1.get_raw_descendant(partial_key); ``` -------------------------------- ### Create MySQL Server Instance with Custom Settings Source: https://speedsheet.io/s/mysql Initializes a new MySQL server instance with specified custom configurations for base directory, data directory, and language settings. ```bash mysqld --initialize \ --user="root_user_id" \ --basedir="basedir" \ --datadir="datadir" \ --lc_messages_dir="language_directory" \ --lc_messages="server_language" ``` -------------------------------- ### Window - Get URL Hash / Path Fragment Source: https://speedsheet.io/s/javascript?q=window-only Retrieves the hash fragment (the part starting with '#') of the current URL. ```APIDOC ## Window - Get URL Hash / Path Fragment ### Description Returns the `#...` portion of the URL path. ### Endpoint `location.hash` or `window.location.hash` ### Response - **Hash** (string) - The hash fragment of the URL (e.g., "#section") ``` -------------------------------- ### Go Hello World with Command Line Arguments Source: https://speedsheet.io/s/go?q=hello+world Prints a greeting using the first command-line argument provided. Includes basic argument validation. ```go package main import ( "fmt" "os" ) func main() { if len(os.Args) == 1 { fmt.Println("Usage: hello ") return } fmt.Println("Hello", os.Args[1:]) } ``` -------------------------------- ### Get Default Shell Path Source: https://speedsheet.io/s/bash?q=how-to-only Displays the path to the default shell that will be used when starting a new shell session. ```bash which $SHELL ``` -------------------------------- ### Example: Get Node or Tag Name Source: https://speedsheet.io/s/javascript?q=Element-Only Demonstrates retrieving the `nodeName` of an element, which returns the tag name in uppercase. ```javascript let item1 = document.getElementById('div-1'); console.log(item1.nodeName); ``` -------------------------------- ### Tauri Builder Setup Application Source: https://speedsheet.io/s/tauri?q=builder-only Executes a setup function during the application build process. This function receives a mutable reference to the `App` instance, allowing for initialization tasks. ```rust builder_1.setup(setup_function) ``` ```rust builder_1.setup(|app| { ... }) ``` -------------------------------- ### Get Running Shell Source: https://speedsheet.io/s/bash?q=how-to-only Identifies the currently active shell process. Example results include 'bash' or 'zsh'. ```bash ps -ocomm= $$ ``` -------------------------------- ### Python Egg - Create Startup Module Source: https://speedsheet.io/s/python?q=distribution Create a `__main__.py` file in the root of your source directory. This file will be executed when the Egg file is run. ```python __main__.py ``` -------------------------------- ### Install from requirements.txt Source: https://speedsheet.io/s/aiohttp?q=install-only Use this command to install all dependencies listed in your requirements.txt file, including aiohttp. ```bash pip install -r requiremets.txt ``` -------------------------------- ### Get Subarray from 1D Array from Position Source: https://speedsheet.io/s/numpy?q=array+slicing Extract a subarray from a specified start index to the end of the 1D NumPy array. ```python from numpy import array array_1 = array([0, 1, 2, 3, 4]) subarray = array_1[2:] # Returns [2, 3, 4] ``` -------------------------------- ### Install Static Build Adapter for SvelteKit Source: https://speedsheet.io/s/svelte Install the adapter-static package using npm. This is the initial step for deploying a static SvelteKit site. ```bash npm install @sveltejs/adapter-static ``` -------------------------------- ### Get Subarray from 1D Array by Range Source: https://speedsheet.io/s/numpy?q=array+slicing Extract a portion of a 1D NumPy array by specifying start and end indices. ```python from numpy import array array_1 = array([0, 1, 2, 3, 4]) subarray = array_1[2 : 4] # Returns [2, 3] ``` -------------------------------- ### Start MySQL Server with Custom Settings Source: https://speedsheet.io/s/mysql Starts the MySQL database server with custom configurations for data directory, PID file, log files, and port. ```bash mysqld --datadir=datadir \ --pid-file=server_pid_file \ --general_log_file=server_log_file \ --log-bin=server_bin_log_file \ --log-error=server_error_log_file \ --port=server_port ``` -------------------------------- ### Get Sublist from Java List Source: https://speedsheet.io/s/java?q=list-only Extracts a portion of the list as a new list, from a starting index up to (but not including) an ending index. ```Java = list1.sublist(from, to) ``` -------------------------------- ### Install Project Dependencies Source: https://speedsheet.io/s/tauri?q=app Run from the project root directory to install all necessary project dependencies. ```bash npm install ``` ```bash pnpm install ``` ```bash deno install ``` ```bash cargo tauri dev ``` -------------------------------- ### Get Windows Version Source: https://speedsheet.io/s/windows Run the 'winver' command from the command line or Start search to display the current Windows version information. ```batch winver ``` -------------------------------- ### package.json 'main' Configuration Source: https://speedsheet.io/s/node_js Specifies the entry point file for the package or application. Examples show different path formats. ```json "main": "starting_module.js" ``` ```json "main": "index.js" ``` ```json "main": "js/main.js" ``` ```json "main": "js/app.js" ``` -------------------------------- ### Get Match Range Source: https://speedsheet.io/s/rust_regex?q=match-only Returns a `Range` representing the start and end byte indices of the match within the original string. ```rust match_1.range() ``` -------------------------------- ### Install aiohttp from requirements.txt Source: https://speedsheet.io/s/aiohttp Install the aiohttp library from a requirements.txt file. Include speedup libraries by specifying `aiohttp[speedups]`. ```bash aiohttp ``` ```bash aiohttp[speedups] ``` ```bash pip install -r requiremets.txt ``` -------------------------------- ### Get Raw Descendant SubTrie Source: https://speedsheet.io/s/radix_trie Returns a SubTrie containing all items that start with the given partial key. This is useful for prefix-based lookups. ```rust // Assuming trie_1 is a valid Trie instance // let subtrie = trie_1.get_raw_descendant(partial_key); ``` -------------------------------- ### Get Object Property Source: https://speedsheet.io/s/javascript?q=object-only Object properties can be accessed using dot notation. The example shows retrieving the value of a 'name' property. ```javascript = object1.property1; let user1 = {name: "your_name_here"}; let name = user1.name; console.log(name); ``` -------------------------------- ### Split String into Words Example Source: https://speedsheet.io/s/go?q=string-only An example demonstrating how to split a string into words using strings.Fields and print the result. Requires 'fmt' and 'strings' packages. ```Go import "fmt" import "strings" string1 := " one two three" words := strings.Fields(string1) fmt.Println(words) // Prints: [one two three] ``` -------------------------------- ### Get Right Substring (ASCII Only) Source: https://speedsheet.io/s/rust?q=string-only Extracts a substring from the right side of a string starting from a specified index to the end. Do NOT use for Unicode strings. ```rust let string_1 = "12345".to_string(); let substring = &string_1[2..]; println!("{}", &substring); // Prints: 345 ``` -------------------------------- ### List All Packages Source: https://speedsheet.io/s/poetry Lists all installed packages in the environment. Use --tree to show dependency trees. ```bash poetry show ``` ```bash poetry show --tree ``` -------------------------------- ### Slice a Bash array to get a subarray Source: https://speedsheet.io/s/bash?q=array-only Extracts a portion of an array defined by a starting index and a length. The original array remains unchanged. ```bash array_1=(1 2 3 4 5 6) array_2=("${array_1[@]:2:3}") # Returns (3 4 5) ``` -------------------------------- ### NumPy Slice Syntax Examples Source: https://speedsheet.io/s/numpy Demonstrates various ways to define slices for selecting elements, such as from the start, to the end, with steps, or specific ranges. ```python first = array_1[0] nth = array_1[n] # Indexes are 0 based second_last = array_1[-2] last = array_1[-1] all = array_1[:] all_but_first = array_1[1:] all_but_last = array_1[:-1] from_1_to_3 = array_1[1:4] from_1_step_to_3 = array_1[1:4:2] even = array_1[::2] odd_from_1 = array_1[1::2] reversed = array_1[::-1] from_ = array_1[start:] from_to = array_1[start:end_plus_1] from_to_with_step = array_1[start:end_plus_1:step] from_with_step = array_1[start::step] to = array_1[:end_plus_1] step_over = array_1[::step] m_to_nth = array_1[m : n + 1] ``` -------------------------------- ### Install multiple packages Source: https://speedsheet.io/s/raspberry_pi Install several packages simultaneously by listing their names, separated by spaces. ```bash sudo apt install package_1 package_2 ... ``` -------------------------------- ### List All init.d Services Source: https://speedsheet.io/s/linux This command lists all services managed by init.d and their current run level configurations. ```bash chkconfig --list ``` -------------------------------- ### Get Variable Type in Python Source: https://speedsheet.io/s/python?q=type%28%29 Use the `type()` function to retrieve the type of a variable. For example, `type(1.0)` returns ``. ```python item_1 = 1.0 item_1_type = type(item_1) # Returns `class 'float'`. ``` -------------------------------- ### Install btop Source: https://speedsheet.io/s/homebrew_packages Installs the btop package, a visual process monitor, using Homebrew. ```bash brew install btop ``` -------------------------------- ### Get Character at Position Source: https://speedsheet.io/s/javascript?q=string-only Retrieves the character at a specific position (index) within a string. Example shows retrieving the character at index 2. ```javascript char2 = "012345".charAt(2); // Returns "2" ``` -------------------------------- ### Basic CLAP CLI Application Structure Source: https://speedsheet.io/s/rust_tools Illustrates the basic structure for defining command-line arguments using the CLAP crate. This example shows how to set up application version, author, about information, arguments, and subcommands. ```rust fn clap_main() { let _matches = clap_app!( myapp => (version: "1.0") (author: "Alice A. ") (about: "Does awesome things") (@arg CONFIG: -c --config +takes_value "config") (@arg debug: -d ... "Sets debugging level") (@subcommand test => (about: "controls testing features") (@arg verbose: -v --verbose "Verbose test") ) .get_matches(); // Handle cli args from here } ``` -------------------------------- ### Python Sequence - Get Sublist by Range Source: https://speedsheet.io/s/python?q=slice-only Extracts a portion of a Python sequence (sublist) defined by a start and end index. The end index is exclusive. ```python list_1 = [0, 1, 2, 3, 4] value = list_1[2 : 4] # Returns [2, 3] ``` -------------------------------- ### Get all elements except the first from a Bash array Source: https://speedsheet.io/s/bash?q=array-only Returns a new array containing all elements starting from the second element (index 1) to the end. ```bash array_1=("one" "two" "three") remainder=${array_1[@]:1} echo "${remainder[@]}" ``` -------------------------------- ### Install and Compile Hugo from Source Source: https://speedsheet.io/s/hugo Install necessary libraries and build the Hugo executable after cloning the repository. ```bash cd hugo go install --tags extended go build ``` -------------------------------- ### Add Startup Command to rc.local (Root) Source: https://speedsheet.io/s/raspberry_pi?q=how-to Example of adding a command to rc.local to run as root on startup. Ensure the command is placed before 'exit 0'. ```bash ... app_start_command exit 0 ``` -------------------------------- ### View init.d Service Configuration Source: https://speedsheet.io/s/linux This command lists the run levels and startup/kill orders for a specific service managed by init.d. ```bash chkconfig --list service_name ``` -------------------------------- ### Linux System Directory: /usr/local/bin Source: https://speedsheet.io/s/linux Stores command-line utilities for applications installed in `/usr/local`. For example, the 'code' command for VS Code might be placed here. ```bash /usr/local/bin ``` -------------------------------- ### Rust BufReader Creation Example Source: https://speedsheet.io/s/rust?q=file+io Shows how to create a new BufReader instance by wrapping a File object. ```rust use std::fs::File; use std::io::BufReader; let file = File::open(path)?; let mut reader_1 = BufReader::new(file); ``` -------------------------------- ### Get Middle Substring of a String (ASCII Only) Source: https://speedsheet.io/s/rust?q=string-only Extracts a substring from a string using direct slicing with start and end indices. This method is NOT safe for Unicode strings. ```rust let string_1 = "12345".to_string(); let index_1 = &string_1[1..=1]; // "2" let index_1_to_3 = &string_1[1..4]; // "234" ``` -------------------------------- ### Python List Slicing - Odd Elements from Position 1 Source: https://speedsheet.io/s/python?q=sequence-only Demonstrates extracting elements starting from index 1 with a step of 2 to get odd-indexed elements. ```python list_1 = [0, 1, 2, 3, 4] odd_from_1 = list_1[1::2] # Returns [1, 3] ``` -------------------------------- ### Install Packages from Requirements File Source: https://speedsheet.io/s/python?q=pip-only Installs all packages listed in a requirements.txt file. This is useful for setting up a project environment. ```bash pip install -r requirements.txt ``` -------------------------------- ### Extract Left Substring in Lua Source: https://speedsheet.io/s/lua Get the leftmost part of a string by specifying the start and end indices. The end index indicates the last character to include. ```lua local string1 = "12345" left = string1:sub(1, 3) print(left) -- Prints: 123 ```