| name | nushell-testing | ||||||
|---|---|---|---|---|---|---|---|
| description | Use when writing or refactoring Nushell Rust tests that use nu_test_support, NuTester, Playground, rstest, deps, plugins, CompleteResult, or when replacing old nu!/nu_with_plugins! tests. | ||||||
| license | MIT | ||||||
| compatibility | opencode | ||||||
| metadata |
|
This example demonstrates how to securely handle sensitive (see Security Note) data, such as API keys and passwords, in a Rust application. The setup ensures that sensitive strings are not included in the binary in plaintext and uses encryption to protect secrets during the build process.
- Encryption during Build: The
build.rsscript encrypts thesecrets.tomlfile using a predefined key (key) and saves the result assecrets.toml.encrypted. - Decryption at Runtime: The main program decrypts the
secrets.toml.encryptedfile at runtime, parses the TOML content, and verifies the data structure. - Static Parsing: The
static_tomlcrate provides compile-time validation of the TOML structure. In this experiment, since the same TOML file (though encrypted) is used to build the data structure, deserialization after decryption should not fail unless there is an unexpected issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use nu_plugin::{ | |
| serve_plugin, EngineInterface, EvaluatedCall, MsgPackSerializer, Plugin, PluginCommand, | |
| SimplePluginCommand, | |
| }; | |
| use nu_protocol::{CustomValue, IntoValue, LabeledError, ShellError, Signature, Span, Type, Value}; | |
| use serde::{Deserialize, Serialize}; | |
| fn main() { | |
| serve_plugin(&BrokenValuePlugin, MsgPackSerializer) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ARG NODE_VERSION=latest | |
| FROM node:${NODE_VERSION} | |
| ARG PACKAGES | |
| RUN npm install -g ${PACKAGES} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #SingleInstance Force | |
| #HotIf WinActive("Pal") | |
| ; Clone Right Modifier to Left Ones | |
| RCtrl::LCtrl | |
| RShift::LShift | |
| ; Remap Numpad Numbers (0-9) to Their Top-Row Counterparts | |
| Numpad0::0 | |
| Numpad1::1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $env.config.buffer_editor = "micro" | |
| # Aliases | |
| alias clip = clip.exe | |
| # Starship | |
| source ~/.cache/starship/init.nu | |
| source ~/.cache/carapace/init.nu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env nu | |
| # Constants | |
| const STEAM_DIR = 'steam/dir' | |
| const USER_ID = 'userid' | |
| const TARGET_DIR = 'target/dir' | |
| # Function to get the current date | |
| def get-date [] { | |
| date now | format date '%Y-%m-%d' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Nexus Mods - right/left arrow pagination | |
| // @match https://www.nexusmods.com/* | |
| // @grant none | |
| // @version 1.0 | |
| // @author Tim 'Piepmatz' Hesse | |
| // @description Add event listeners to the right and left buttons for the pagination to allow to page with the arrow keys | |
| // ==/UserScript== | |
| const ARROW_KEYS = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "emojis": { | |
| "100": "💯", | |
| "1234": "🔢", | |
| ">:(": "😠", | |
| ">:-(": "😠", | |
| ">=(": "😠", | |
| ">=-(": "😠", | |
| ":\")": "😊", | |
| ":-\")": "😊", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {createServer, AddressInfo} from "net"; | |
| /** | |
| * Utility function to return a free port. | |
| * | |
| * Uses dummy server that listens to port 0 to let the OS assign the server a | |
| * port. | |
| * Then the server will be closed and the now open port will be returned. | |
| * | |
| * @return by OS assigned, free port |
NewerOlder