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
#!/bin/bash | |
# Manages concurrent execution of nohup jobs with a maximum limit. | |
# Number of maximum concurrent jobs | |
MAX_JOBS=4 | |
# List of commands you want to run with nohup | |
declare -a commands=( | |
"./sleepTest.sh" |
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
# Define the variables | |
# The server or root directory | |
$localserver = "\\<localserver>" | |
# Share | |
$share = "\share" | |
# Source data folders you wish to backup | |
$dataFolders = @("\backups", "\pics") # You can add more folders to this array if needed |
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
# Check for administrator privileges | |
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
# Relaunch the script as an administrator | |
Start-Process powershell -Verb runAs -ArgumentList "-File `"$($MyInvocation.MyCommand.Path)`"" | |
exit | |
} | |
# init directory existence check variable | |
$dirExists = $false |
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
backup_dir_function() { | |
# Log the start of the command | |
logger -p syslog.info "Starting backup process." | |
# must pass in a directory | |
directory="$1" | |
# Convert to absolute path if a relative path is given | |
if [[ ! "$directory" = /* ]]; then | |
directory="$(pwd)/$directory" | |
fi |
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
(gci -include *.cpp,*.h -recurse | select-string .).Count |
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
#!/bin/bash | |
counter=0 | |
while true; do | |
counter=$((counter + 1)) | |
output=$(./MyApp) # Execute the program and store its output | |
last_line=$(echo "$output" | tail -n 1) # Extract the last line of the output | |
echo "$output" # Print the output | |
if [ "$last_line" == "output" ]; then # Change this string to desired match | |
echo "Output found after: $counter" # Shows number of program executions |
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
# Install Github CLI | |
winget install -e --id GitHub.cli | |
# Log into Github | |
gh auth login | |
mkdir c:\_all | |
cd c:\_all | |
gh repo list | ForEach-Object { gh repo clone $_.Split("`t")[0] } |
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
#include "C:\gsl\narrow" // path to GSL include files | |
#include <string> | |
/*** | |
* Center text in a fixed-width field | |
* https://stackoverflow.com/questions/14861018/center-text-in-fixed-width-field-with-stream-manipulators-in-c | |
*/ | |
std::string center(const std::string& text, int width) | |
{ | |
/*** |
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
#include <iostream> // cout | |
#include <iomanip> // fixed, setprecision | |
#include <chrono> // time library | |
{ | |
auto startTime = std::chrono::high_resolution_clock::now(); | |
/* work */ | |
auto endTime = std::chrono::high_resolution_clock::now(); |
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
/* Pg. 87 - The C Programming Language (2nd Ed) - Recursive Quicksort */ | |
/* qsort: sort v[left]..v[right into increasing order */ | |
void qsort(int v[], int left, int right) | |
{ | |
int i, last; | |
void swap(int v[], int i, int j); | |
if (left >= right) /* do nothing if array contains */ | |
return; /* fewer than two elements */ |