Skip to content

Instantly share code, notes, and snippets.

Oscar Kramer oscarkramer

  • KramerAnalytic
  • Miami Beach
Block or report user

Report or block oscarkramer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@oscarkramer
oscarkramer / LongOptionsParse.cpp
Last active Dec 14, 2018
Long Option Parsing in C++
View LongOptionsParse.cpp
#include <getopt.h>
#include <iostream>
using namespace std;
void usage(const char* appName, int exitCode, string errMsg="")
{
if (!errMsg.empty())
cout<<"\n"<<errMsg<<endl;
@oscarkramer
oscarkramer / yaml2json.py
Last active Jul 31, 2018
YAML to JSON File converter in python
View yaml2json.py
# 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"
@oscarkramer
oscarkramer / printHorizontalLine
Created May 18, 2018
Bash script to output a horizontal line spanning the width of the terminal using dashes (or optional string provided)
View printHorizontalLine
# Usage: printHorizontalLine [c]
function printHorizontalLine {
local c="-"
local strlen=1
if [ -n "$1" ]; then
c=$1
strlen=${#c}
fi
echo
@oscarkramer
oscarkramer / answerYesNo.sh
Last active May 18, 2018
Bash functions for prompting yes/no question
View answerYesNo.sh
# 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
#
You can’t perform that action at this time.