Skip to content

Instantly share code, notes, and snippets.

View restump's full-sized avatar

Reuben Stump restump

  • Philadelphia, PA
View GitHub Profile
@restump
restump / ISODateTimeToGlideDateTime.js
Last active November 17, 2020 14:07
ServiceNow javascript function to convert ISO8601 DateTime strings to GlideDateTime objects
/* function : ISODateTimeToGlideDateTime()
Convert ISO8601 DateTime string to GlideDateTime object
*/
function ISODateTimeToGlideDateTime(s) {
if ( (s == '') || (s == null) ) {
return null;
}
// GlideDateTime constructor expects date format: 'YY-MM-DD HH::MM::SS'
parts = s.split(/[-TZ:+]/g);
@restump
restump / AnsibleRegexSearchHTML.yml
Last active August 10, 2023 08:39
Example demonstrating string extraction from HTML content in Ansible with regex_search filter plugin
---
- hosts: localhost
connection: local
tasks:
- uri:
url: https://rstumph2.service-now.com/stats.do
return_content: yes
register: response
makeAssignments(reqItem, assignments, rule_variables, loggers);
/** Context contains
* reqItem - request item (sc_req_item) that the rule is running against
* assignments - name/value pairs set by previous rule assignments - assigning values to variables of the request item
* rule_variables - name/value pairs set by previous rule assignments with temporary values that do not persist after the rule finishes making assignments
* loggers - collection of logging functions, to use:
* loggers.log(msg, loggers.executor);
* loggers.logError(msg, loggers.executor);
* loggers.logWarning(msg, loggers.executor);
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "Username for the Virtual Machine."
}
},
IFS=$'\n' read -rd '' -a array <<< "$(aws ec2 describe-instances | jq -c .Reservations[])"
n=0; for i in "${array[@]}"; do n=$((n+1)); cbc create $n -V "${i}"; done
@restump
restump / keybase.md
Created September 28, 2017 19:50
keybase.md

Keybase proof

I hereby claim:

  • I am stumpr on github.
  • I am rstump (https://keybase.io/rstump) on keybase.
  • I have a public key ASCiNmhMHXwRBxXLmd2xlg5YlXNx6WqqlSjfUkt_Zm-Uego

To claim this, I am signing this object:

provider "aws" {
profile = "${var.profile}"
region = "${var.region}"
assume_role {
role_arn = "arn:aws:iam::${var.account_id}:role/${var.assume_role}"
}
}
resource "aws_s3_bucket" "tf_state_storage" {
@restump
restump / cli.sh
Last active January 15, 2019 21:55
Register AMI with SRIOV and ENA
aws ec2 register-image --ena-support --sriov-net-support simple --virtualization-type hvm --name ami-base-centos --block-device-mappings '[{"DeviceName":"/dev/sda1","Ebs":{"SnapshotId":"snap-05168016823a3fc9f"}}]' --root-device-name /dev/sda1 --architecture x86_64 --profile rdc-com-production
aws ec2 create-tags --tags Key=OS,Value=CentOS Key=Application,Value=base --resources ami-423a593d --profile rdc-com-production
@restump
restump / storm-athena-query-examples.sql
Last active March 20, 2019 20:23
Storm Athena query examples
-- Default VPCs
SELECT *
FROM "stormreports"."ec2_vpcs"
WHERE isDefault = true
AND date = date_format(current_date, '%Y-%m-%d')
-- VPCs with no ENIs attached (possibly unused)
WITH e AS
(SELECT vpcid,
@restump
restump / RemoveDefaultVPC.py
Created April 22, 2019 12:01
Remove default VPC
#!/usr/bin/env python
import boto3, argparse, sys, time
parser = argparse.ArgumentParser(description="Remove default VPC in specified account and region")
parser.add_argument('--account',
type=str )
parser.add_argument('--region',
type=str )
parser.add_argument('--role',