Skip to content

Instantly share code, notes, and snippets.

@pjaudiomv
pjaudiomv / upgrade-bmlt.sh
Last active April 13, 2020 01:59
script for upgrading a BMLT Root Server
#!/bin/sh
# Script for upgrading a BMLT server.
# Basic Usage: < ./bmlt-upgrade.sh > this will download the new release put it in a folder called new_main_server.
# when you have verified everything works you can run < ./bmlt-upgrade.sh complete >
# this will copy main_server to old_main server and new_main_server to main_server
# if url provided we use that, otherwise just get latest release.
if [[ -z "$1" ]];then
RELEASE_URL=$(curl -sL "https://api.github.com/repos/bmlt-enabled/bmlt-root-server/releases/latest" | grep -o '"browser_download_url": *"[^"]*' | grep -o '[^"]*$')
# if jq is available curl -sL "https://api.github.com/repos/bmlt-enabled/bmlt-root-server/releases/latest" | jq -r '.assets[].browser_download_url'
@pjaudiomv
pjaudiomv / jft.php
Last active April 13, 2020 13:55
get jft into array
<?php
$xml = new DOMDocument();
$xml->validateOnParse = true;
$xml->loadHTML(file_get_contents('https://jftna.org/jft/'));
$xpath = new DOMXPath($xml);
$table = $xpath->query("//table")->item(0);
$rows = $table->getElementsByTagName("tr");
$jftKeys = array('date', 'title', 'page', 'quote', 'source', 'content', 'thought', 'copyright');
@pjaudiomv
pjaudiomv / secgroupdelete_ec2classic.py
Created July 10, 2020 03:12 — forked from arpcefxl/secgroupdelete_ec2classic.py
AWS ec2 security group delete scripts. One script is for ec2-classic, the other is for VPC
#!/usr/bin/env python
# Authored by Chad Smith on 3/10/2015
# please feel free to contact me at [email protected] with comments or questions
# assumes you have already run aws configure or are running in an ec2 role
import boto.ec2, sys
region = sys.argv[1]
secgroup = sys.argv[2]
conn = boto.ec2.connect_to_region(region)
allgroups = conn.get_all_security_groups()
@pjaudiomv
pjaudiomv / update-ssm-tags.sh
Created October 1, 2020 14:11
Tags instances with detected platform and patch group
#!/bin/bash
INSTANCE_IDS=$(aws ssm describe-instance-information --query 'InstanceInformationList[?starts_with(InstanceId, `i-`) == `true` && starts_with(PingStatus, `Online`) == `true`].InstanceId' --output json)
# we don't wan't instances that start with m as they are not taggable, usually workspaces. We also will only tag instances that are online.
export INSTANCE_IDS
echo "Instances that are going to be updated: $INSTANCE_IDS"
echo "$INSTANCE_IDS" | jq -r '.[]' | while read INSTANCE; do
PLATFORM_NAME=$(aws ssm describe-instance-information --instance-information-filter-list key=InstanceIds,valueSet=$INSTANCE --output text --query 'InstanceInformationList[].PlatformName')
PLATFORM_VER=$(aws ssm describe-instance-information --instance-information-filter-list key=InstanceIds,valueSet=$INSTANCE --output text --query 'InstanceInformationList[].PlatformVersion')
@pjaudiomv
pjaudiomv / lambda-debug
Last active November 24, 2020 04:06
lambda-debug
2020-11-24T03:45:37.195Z [DEBUG] plugin.terraform-provider-aws_v3.17.0_x5: 2020/11/24 03:45:37 [DEBUG] [aws-sdk-go] DEBUG: Validate Response lambda/GetFunctionCodeSigningConfig failed, attempt 0/25, error AccessDeniedException:
2020-11-24T03:45:37.195Z [DEBUG] plugin.terraform-provider-aws_v3.17.0_x5: status code: 403, request id: 219fsd-ff81-4ba4-a7dc-58zasb9289
2020/11/24 03:45:37 [ERROR] eval: *terraform.EvalRefresh, err: error getting Lambda Function (test-lambda) code signing config AccessDeniedException:
status code: 403, request id: 2sfg74-ff81-4ba4-a7dc-58dgf5b9289
2020/11/24 03:45:37 [ERROR] eval: *terraform.EvalSequence, err: error getting Lambda Function (test-lambda) code signing config AccessDeniedException:
status code: 403, request id: 21sgf4-ff81-4ba4-a7dcgdf0805b9289
2020/11/24 03:45:37 [DEBUG] [aws-sdk-go] {}
@pjaudiomv
pjaudiomv / bmlt-emails.php
Created February 21, 2021 05:14
Get All Emails from BMLT Server (Requires Authentication)
<?php
$root_server = "https://my.root-server.org/main_server";
$bmlt_login_id = "";
$bmlt_login_password = "";
$login = get("$root_server/local_server/server_admin/json.php?c_comdef_admin_login=$bmlt_login_id&c_comdef_admin_password=$bmlt_login_password&admin_action=login");
$meetings = json_decode(get("$root_server/client_interface/json/?switcher=GetSearchResults&data_field_key=contact_email_1,contact_email_2,email_contact"), true);
$service_bodies = json_decode(get("$root_server/client_interface/json/?switcher=GetServiceBodies"), true);
@pjaudiomv
pjaudiomv / meetings-by-venue-type.php
Last active April 11, 2021 04:42
BMLT Get Meetings By Venue Type
<?php
$root_server = "https://my.root-server.org/main_server";
$meetings = json_decode(file_get_contents("$root_server/client_interface/json/?switcher=GetSearchResults"), true);
$console_color = true;
$tempvirtual = 0;
$virtual = 0;
$inperson = 0;
@pjaudiomv
pjaudiomv / gist:254c36db2575706167f4445409e32ab8
Created July 11, 2022 19:47
Convert boto3 tags to a dict
tags = [
{'Key': 'Environment', 'Value': 'staging'},
{'Key': 'Name', 'Value': 'STAGING TOOLS'}
]
tag_dict = {tag['Key']: tag['Value'] for tag in tags}
# {
# "Environment": "staging",
# "Name": "STAGING TOOLS"
@pjaudiomv
pjaudiomv / github_ssh_keys.tf
Created August 26, 2022 01:48
GitHub User SSH Keys
data "http" "users" {
for_each = toset(var.github_users)
url = "https://api.github.com/users/${each.value}/keys"
request_headers = {
Accept = "application/json"
}
}
variable "github_users" {
@pjaudiomv
pjaudiomv / bmlt-json-2-kml.php
Created September 8, 2022 19:11
BMLT JSON 2 KML
<?php
$bmlt_server = "https://latest.aws.bmlt.app/main_server";
$search_query = "&services=1010&weekdays=2";
$query_url = urldecode($bmlt_server . "/client_interface/json/?switcher=GetSearchResults" . $search_query);
$result = '';
if (str_contains($query_url, "/client_interface/json/?switcher=GetSearchResults")) {
$meetings = file_get_contents($query_url);
$meetings = json_decode($meetings, true);