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
# Bash function to prompt terminal user for yes|no | |
# Author: Oscar Kramer | |
# | |
# If interactive shell, prompts user for confirmation considering optional default (Y|N) specified. | |
# The default is returned if <enter> is typed in lieu of a y|n character. The prompt is appended with | |
# " [Y|n]:" or " [y|N]:" depending on default provided. | |
# | |
# If not interactive, returns answerYes=1, answerNo=0 | |
# Returns boolean | |
# |
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
# Usage: printHorizontalLine [c] | |
function printHorizontalLine { | |
local c="-" | |
local strlen=1 | |
if [ -n "$1" ]; then | |
c=$1 | |
strlen=${#c} | |
fi | |
echo |
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
# Converts input YAML file to JSON and writes the JSON to same filename but with ".json" ext. | |
import os, json, sys, yaml | |
if len(sys.argv) < 2: | |
print("Usage: "+sys.argv[0]+" <input.yaml>") | |
exit | |
try: | |
yamlFname = sys.argv[1] | |
pre, ext = os.path.splitext(yamlFname) | |
jsonFname = pre + ".json" |
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 <getopt.h> | |
#include <iostream> | |
using namespace std; | |
void usage(const char* appName, int exitCode, string errMsg="") | |
{ | |
if (!errMsg.empty()) | |
cout<<"\n"<<errMsg<<endl; | |
cout<<"\nProgram description goes here..." |
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 | |
usage() { | |
echo; | |
echo "Description here." | |
echo | |
echo "Usage: $0 [options] <arg1> " | |
echo | |
echo " <arg1> Arg1 blah blah" | |
echo |
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 | |
pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null | |
SCRIPT_DIR=`pwd -P` | |
popd >/dev/null | |
echo "Script directory is $SCRIPT_DIR" |
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
// C Program for IPC Message Queue. Adapted from https://www.geeksforgeeks.org/ipc-using-message-queues/ | |
#include <stdio.h> | |
#include <sys/ipc.h> | |
#include <sys/msg.h> | |
#include <cstring> | |
using namespace std; | |
// structure for message queue |