Skip to content

Instantly share code, notes, and snippets.

View chasen-bettinger's full-sized avatar
🏒

Chasen Bettinger chasen-bettinger

🏒
View GitHub Profile
@chasen-bettinger
chasen-bettinger / getRelationship.js
Created February 24, 2017 19:04
Compare the relationship between two variables
function getRelationship(x, y) {
if(x !== x) {
return "Can't compare relationships because " + x + " and undefined are not numbers";
}
if (typeof x != 'number' || typeof y != 'number') {
if(arguments.length === 2) {
if(typeof x != 'number' && typeof y != 'number') {
return "Can't compare relationships because " + x + " and " + y + " are not numbers";
@chasen-bettinger
chasen-bettinger / numberOfBytes.js
Created February 24, 2017 19:39
Parse a JSON with JavaScript
// Iterate through the localizedRuleNames in ruleResults and
// return an array of their strings.
function ruleList(results) {
var localizedRuleNamesArr = [];
var locationToIterate = results.formattedResults.ruleResults
for(var rule in locationToIterate) {
if(locationToIterate.hasOwnProperty(rule)) {
localizedRuleNamesArr.push(locationToIterate[rule].localizedRuleName);
}
}
var moonWalkers = [
"Neil Armstrong",
"Buzz Aldrin",
"Pete Conrad",
"Alan Bean",
"Alan Shepard",
"Edgar Mitchell",
"David Scott",
"James Irwin",
"John Young",
// check to see if a variable is an array
// from [Douglas_Crockford]_JavaScript_The_Good_Parts
var is_array = function (value) {
return value &&
typeof value === 'object' &&
typeof value.length === 'number' &&
typeof value.splice === 'function' &&
!(value.propertyIsEnumerable('length'));
};
@chasen-bettinger
chasen-bettinger / 0_reuse_code.js
Created March 25, 2017 16:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Verifying my Blockstack ID is secured with the address 1Ak8np9dvD8ytQ7zL2E77kSecbUCCQbfea https://explorer.blockstack.org/address/1Ak8np9dvD8ytQ7zL2E77kSecbUCCQbfea
version: '3'
services:
db:
image: mysql:5.7
ports:
- "8081:3306"
volumes:
- ./sql:/docker-entrypoint-initdb.d
restart: always
environment:
@chasen-bettinger
chasen-bettinger / unreviewed-aws-managed-policy-changes.json
Last active December 27, 2021 18:21
JupiterOne Alert Rule - Unreviewed Changes To AWS Managed Policies
{
"name": "Unreviewed Changes To AWS Managed Policies",
"description": "AWS Managed Policies that have been unreviewed by the Security team.",
"version": 1,
"specVersion": 1,
"pollingInterval": "ONE_DAY",
"templates": {},
"outputs": [
"alertLevel"
],
@chasen-bettinger
chasen-bettinger / date_diff.sh
Created July 13, 2023 18:16
# Bash function to read a date from stdin and then calculate the number of days from that date to today.
#!/bin/bash
# Bash function to read a date from stdin
# and then calculate the number of days from that date
# to today.
# Date to compare
read -r target_date
# Get the current date in UTC
current_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
@chasen-bettinger
chasen-bettinger / get_last_update_date.sh
Created July 13, 2023 18:20
bash function to find a repo's last push date and then get # of days since that date
get_last_update_date() {
days_since=$(gh repo view $1 --json pushedAt -q ".pushedAt" | ./diff_date.sh)
echo "$1 $days_since"
}