Skip to content

Instantly share code, notes, and snippets.

View jackdpeterson's full-sized avatar

Jack Peterson jackdpeterson

View GitHub Profile
@jackdpeterson
jackdpeterson / Dockerfile-debian-bookworm
Last active April 25, 2024 20:48
Asterisk install_prereq tests - debian:[buster|bullseye|bookworm]
FROM --platform=linux/amd64 debian:bookworm
WORKDIR /app
RUN apt update \
&& apt dist-upgrade -y \
&& apt autoremove -y \
&& apt install -y -q \
build-essential \
subversion \
wget \
@jackdpeterson
jackdpeterson / Dockerfile-debian-bullseye
Created April 25, 2024 20:32
Asterisk install_prereq test for Debian Bullseye
FROM --platform=linux/amd64 debian:bullseye
WORKDIR /app
RUN apt update \
&& apt dist-upgrade -y \
&& apt autoremove -y \
&& apt install -y -q \
build-essential \
subversion \
wget \
@jackdpeterson
jackdpeterson / ec2-codedeploy-docker.pkr.hcl
Created August 23, 2023 20:29
Packer Build manifest for EC2 + CodeDeploy for Docker based architecture
packer {
required_plugins {
docker = {
version = ">= 1.2.6"
source = "github.com/hashicorp/amazon"
}
}
}
locals {
@jackdpeterson
jackdpeterson / install.sh
Created August 23, 2023 20:25
EC2 CodeDeploy Packer installation script to execute on the instance being provisioned from a baseline Ubuntu 22.04 LTS AMI
#!/usr/bin/env bash
set -e
set -x
cloud-init status --wait
sudo cat /etc/lsb-release
uname -a
sudo apt-get update && \
@jackdpeterson
jackdpeterson / ec2_copy_security_group_to_another_region.sh
Created November 11, 2021 19:56
Copy an AWS EC2 security group to another region
#!/usr/bin/env bash
### inserts all CIDRs into a new security group.
### Doesn't set correct protocol or the description ... but at least it makes the data entry a bit quicker since you can't copy/pasta in the EC2 UI easily.
SOURCE_REGION=us-west-1
SOURCE_PROFILE=default
SOURCE_SG_ID=sg-id-goes-here
DESTINATION_REGION=us-east-2
DESTINATION_PROFILE=default
return this.cachedOfferResponseRepository.findCachedOfferResponseBySellerIdEqualsAndProductIdEquals(CLIENT_ID.toString(), gtin)
.flatMapIterable(CachedProductOfferResponse::getOffers)
.switchIfEmpty(this.requestAndCache(gtin));
package com.example.identity.config;
import com.example.identity.model.User;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import java.util.HashMap;
import java.util.Map;
@jackdpeterson
jackdpeterson / cleanup_closed_PRs.sh
Created June 10, 2019 19:12
clean up closed PRs in a Jenkins multibranch pipeline environment. Enable as a CRON job
#!/usr/bin/env bash
#set -x
GITHUB_ACCESS_TOKEN=TOKEN_GOES_HERE
GITHUB_USERNAME=USERNAME_GOES_HERE
GITHUB_ORGANIZATION=com.example
GITHUB_REPOSITORY=microservice
## Jenkins project name
PROJECT="com.example.microservice"
function clean_closed_prs {
@jackdpeterson
jackdpeterson / interpolate_env_into_compiled_js.sh
Last active September 29, 2018 08:33
Dynamically load environment variables after webpack compiles JS using a bash script to replace the values
#!/usr/bin/env bash
## Given env.js that looks something like
#
# const env = {
# application_env : '~REACT_ENV_REPLACE_JS_APPLICATION_ENV~',
# };
# module.exports = env;
# And an environment variable of JS_APPLICATION_ENV=whateverItOughtToBe ... replace any occurrences on runtime (add to docker CMD)
#
@jackdpeterson
jackdpeterson / TypedCollection.php
Created July 30, 2018 23:43
Sample immutable Typed collection
<?php
final class ImageCollection implements \Iterator, \JsonSerializable, \Countable
{
private $data;
public function __construct(array $values)
{
$this->data = (function (Image ...$values) {
return $values;