Skip to content

Instantly share code, notes, and snippets.

View gswallow's full-sized avatar

Greg Swallow gswallow

  • Indianapolis, IN, USA
View GitHub Profile
@gswallow
gswallow / strings.go
Created August 9, 2018 14:59
go book
package main
import "fmt"
import "strings"
func main() {
fmt.Println(strings.ToUpper(strings.Join([]string{"e", "i", "e", "i", "o!"}, "-")))
}
@gswallow
gswallow / create-param.sh
Last active July 20, 2018 18:52
Install the AWS Cloudwatch agent on Windows.
#!/bin/bash
aws ssm put-parameter --name AmazonCloudWatch-windows --type String --overwrite --value "$(cat cw-windows.json)"
#!/bin/bash
eval "$(jq -r '@sh "ID=\(.id) TAG_KEY=\(.tag_key) TAG_VALUE=\(.tag_value)"')"
aws ec2 create-tags --resources $ID --tags "Key=$TAG_KEY,Value=$TAG_VALUE"
jq -n --arg subnet_id "$ID" \
--arg tag_key "$TAG_KEY" \
--arg tag_value "$TAG_VALUE" \
'{"subnet_id": $subnet_id, "tag_key": $tag_key, "tag_value": $tag_value}'
@gswallow
gswallow / CreateTableInterw.php
Created June 12, 2018 19:30
PHP mysqli example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Creating HR Database and Interviews Table</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
172.19.10.40 - - [05/Jun/2018:21:26:38 +0000] "GET /streamer/var/lib/pulp/content/units/rpm/b5/55ab62d65879fe810c3407a663afa26cc845c5014f532747237b884fa151ac/mercurial-2.6.2-8.e
l7_4.x86_64.rpm?policy=eyJleHRlbnNpb25zIjogeyJyZW1vdGVfaXAiOiAiMTcyLjE5LjEwLjQwIn0sICJyZXNvdXJjZSI6ICIvc3RyZWFtZXIvdmFyL2xpYi9wdWxwL2NvbnRlbnQvdW5pdHMvcnBtL2I1LzU1YWI2MmQ2NTg3OW
ZlODEwYzM0MDdhNjYzYWZhMjZjYzg0NWM1MDE0ZjUzMjc0NzIzN2I4ODRmYTE1MWFjL21lcmN1cmlhbC0yLjYuMi04LmVsN180Lng4Nl82NC5ycG0iLCAiZXhwaXJhdGlvbiI6IDE1MjgyMzQwODd9;signature=4vQBWlLjrx-2OYgG
EgSeKes5zGnqrU5SHWo_7f2j1oNVsLKYHth2bAa6L8FCRybq9-spaH7jQL51bTcDVqNrxyyn60EHJDb4PkfPhfHZBhu4O8equRK2ACeVIJJeXCr5lYQP4v-R8YaiddBEko0ggqKNwY6mPRMjGSlMUFlyyNwGjuw16iYYxDJcxIw39lsx1
FwCvYtyMP_zoEpypQMg4oIbvjTby9FzpFo0M_1uxsCgrnkuJKrjj1D79fvTdlXGxtKmrkrXtc_uf-h3_c8j36ild1c7SFWMYm4_fKZqxxDsDyU1LkBNWx1_qxicBZlgmfSj9ynp8typ6ie0Z4m8_A%3D%3D HTTP/1.1" 404 - "-" "
urlgrabber/3.10 yum/3.4.3"
@gswallow
gswallow / host-report.rb
Created May 24, 2018 18:17
For Red Hat.
#!/usr/bin/ruby
require 'time'
require 'rest-client'
require 'json'
require 'yaml'
require 'mail'
ME = 'satellite.ivytech.edu'
url = "https://#{ME}"
@gswallow
gswallow / host-report.rb
Created May 24, 2018 18:17
For Red Hat.
#!/usr/bin/ruby
require 'time'
require 'rest-client'
require 'json'
require 'yaml'
require 'mail'
ME = 'satellite.ivytech.edu'
url = "https://#{ME}"
@gswallow
gswallow / promote-content.rb
Created May 9, 2018 13:58
Red Hat Satellite 6 Content Promotion
#!/usr/bin/ruby
require 'time'
require 'rest-client'
require 'json'
HOST = '{{ satellite_deployment_hostname_full }}'
ORG_NAME = '{{ satellite_deployment_organization }}'
DELAYED_ENVS = [ "training", "prod", "fye" ]
KEEP = 3
order = []
lifecycle_envs.each do |e|
if e['prior'].nil?
order.unshift(e['name'])
elsif order.include?(e['prior']['name'])
order.insert(order.index(e['prior']['name']) + 1, e['name'])
else
order.push(e['name'])
end
end
#!/usr/bin/ruby
require 'time'
require 'rest-client'
require 'json'
require 'yaml'
require 'mail'
url = 'https://satellite.mycompany.com'
foreman_url = "#{url}/api/v2"