Skip to content

Instantly share code, notes, and snippets.

@HauptJ
HauptJ / editors.yml
Created December 9, 2024 03:01
Single file Ansible Playbook to install text editors on Fedora
#!/usr/bin/env ansible-playbook
---
- name: Install Text Editors
hosts: localhost
become: true
gather_facts: False
tasks:
- name: Install Terminal Text Editors
dnf:
@HauptJ
HauptJ / ansible.sh
Last active December 9, 2024 03:07
Bash script to install Ansible on Fedora
#!/usr/bin/env bash
# Ensure we have root permissions
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "Not running as root"
exit
fi
dnf update -y
dnf install ansible -y
@HauptJ
HauptJ / tex.yml
Created December 9, 2024 02:17
Single file Ansible Playbook to install Latex Scheme Full and Latex editors on Fedora
#!/usr/bin/env ansible-playbook
---
- name: Install and Configure LaTex
hosts: localhost
become: true
gather_facts: False
vars:
tex_live: texlive-scheme-full
tex_live_retries: 888
You are given a two-digit integer n. Return the sum of its digits.
Example
For n = 29, the output should be
solution(n) = 11.
Input/Output
[execution time limit] 3 seconds (java)
param (
[Parameter(Position=0, mandatory=$true)]
[string] $jsonConfigFilePath,
[parameter(mandatory=$false)]
[int] $debugLvl = 0,
[parameter(mandatory=$false)]
[string] $reportFilePath
)
@HauptJ
HauptJ / fileWordArray.ps1
Last active April 19, 2024 14:46
Simple PowerShell Script with Arrays
$fileWordArray = [System.IO.File]::ReadAllLines("C:\Users\joshu\dev\temp\powershell\something.txt")
Write-Host "Begin: fileWordArray ----------------------------------------------------------------"
Write-Host $fileWordArray
Write-Host "Items in file: " $fileWordArray.Length
foreach ($word in $fileWordArray) {
Write-Host $word
}
@HauptJ
HauptJ / regex_count_example.ps1
Created April 13, 2024 22:55
PowerShell Script to Count Occurrences of Regular Expressions in a File
# PowerShell Script to Count Occurrences of Regular Expressions in a File
# Specify the path to the file
$filePath = "C:\Users\redacted\test.txt"
# Define the list of regular expressions to search for
$regexPatterns = @("\bwinget\b", "\bmsstore\b", "\bUnknown\b")
# Check if the file exists
if (Test-Path $filePath) {
@HauptJ
HauptJ / hash_table_example.ps1
Created April 13, 2024 19:56
PowerShell Hash Table Example with CLI Parameters and Try Catch Error Handling
# Input CLI params with default values
param (
$number=1,
$shape="Square",
$color="Blue"
)
try {
# Ordered hash table
[hashtable]$hash = [ordered]@{Number = $number; Shape = $shape; Color = $color}
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
# Set the variable value in *.tfvars file
@HauptJ
HauptJ / playbook.yml
Last active March 6, 2025 19:29
Ansible Playbook to install and configure T-POT on Debian 11
---
- hosts: all
become: true
vars_prompt:
- name: ssh_username
prompt: Enter SSH username
private: false
- name: tpot_username