Skip to content

Instantly share code, notes, and snippets.

View jhyland87's full-sized avatar

J jhyland87

View GitHub Profile
function curlcmd() {
method=${1:-GET}
method=$(echo $method | tr '[a-z]' '[A-Z]')
/usr/bin/curl -X ${method} -i --header 'Accept: application/json' ${@:2} && echo
}
alias cjpost="curlcmd post"
alias cjget="curlcmd get"
@jhyland87
jhyland87 / ps1.sh
Created December 22, 2016 01:06
/etc/profile.d/ps1.sh
#!/bin/bash
# Create /etc/profile.d/prompt.sh and add the content of this gist to it.
#
# Prompt example:
# (2)[Fri May 06 10:00:30| 0:003]{4}root@ip-172-31-1-226:~(0)#
# Format is:
# (sessions on server)[date time| Last command exec time]{sessions on server}username@hostname:working_directory(exit code of last cmd)#
#
# Example Output (of $[prompt[0]}): http://d.pr/i/19B87
#
@jhyland87
jhyland87 / parse-ini.awk
Created May 15, 2017 16:33
Basic awk script that can be used to parse a config similar to the INI layout (var = val)
#! /usr/local/bin/awk -f
# Solution by Ed Morton (http://stackoverflow.com/a/43946907/5154806)
# Example: echo -e "personal.name.first=John\npersonal.name.last\t=Doe\npersonal.other.dob=\t05/07/87\npersonal.contact.phone\t=\t602123456\npersonal.contact.email\t = \tjohn.doe@idk\nemployment.jobs.1\t\t= Company One\nemployment.jobs.2 \t =Company Two\nemployment.jobs.3\t= Company Three" | ./tst.awk
BEGIN {
FS="[\t ]*=[\t ]*"
}
{
split($1,d,/\./)
data[d[1]][d[2]][d[3]] = $2
#!/usr/local/bin/awk -f
# Todo:
# skip empty rows
# Look for duplicate pids
# Validate data types in columns:
# - pid (int)
# - ppid (int)
# - uid (int)
# - ruid (int)
@jhyland87
jhyland87 / ps-totaler.awk
Created October 11, 2017 19:10
Awk script to total the data returned from ps
#!/usr/bin/awk -f
# Examples
# $ ps -o pid,user,cpu,%cpu,%mem,nswap,sess,tty | ./ps_total.awk
# Count : 58
# USER : 0
# CPU : 0
# %CPU : 1.8
# %MEM : 2.5
# NSWAP : 0
#! /usr/local/bin/awk -f
# Examples:
# ls -1 | ./hr-with-string.1.awk
# ls -1 | ./hr-with-string.1.awk -v pad=30
# ls -1 | ./hr-with-string.1.awk -v pad=30 -v hr='-'
# ls -1 | ./hr-with-string.1.awk -v pad=30 -v hr='><'
function center( str, a, left, right ){
right = int(( CFG[ pad ] - length(str)) / 2)
@jhyland87
jhyland87 / get_cli_awk_vars.awk
Last active May 13, 2022 23:43
Parse the executed command, assessing all variables set via -v or --assign, adding the key/values to an array
#!/usr/bin/env awk -f
#
# THIS IS CURRENTLY BROKEN - im working on it.
#
# Description: Grabs the fully executed command by using the ps command to find the "args" data
# for the pid PROCINFO["pid"], then parses it by looking for any awk variables set
# using -v or --assign via the execution.
#
#! /usr/local/bin/awk -f
# Functions to add:
# arrSort : Sort array by value in specific key or index
# arrType : Determine if an array is a scalar or hash array
# parsedate : Function to parse a date provided (EG: ps -o etime)
#
# Function to check if a value (typically an entire line of a file) is either empty, or
Question:
Tell me about a time that you strongly disagreed with your
manager on something you deemed to be very important to the
business. What was it about and how did you handle it?
Answer:
I think the most prevalent example would be the mentality in which my
previous manager and I had towards potential problems related to
monitoring, logging and security weaknesses. It seemed to me that he
had more of a reactive oriented mentality, where as I thought it was
@jhyland87
jhyland87 / AmazonUIPageJS-namespaces.list
Created September 18, 2018 20:48
Generated via: grep -A 1 -nH _namespace *.js | grep -Eo '\(".+"\)' | grep -Eo '([a-zA-Z]+)' | sort -u
AUIBuild
ActionPanelAssets
AmazonCertifiedDetailPageAssets
AmazonCustomBuyBoxAssets
AmazonCustomCommonAssets
AmazonCustomPreviewerAssets
AmazonPopoversAUIShim
AmazonsChoiceAssets
Assets
BabyRegistryDPAssets