Skip to content

Instantly share code, notes, and snippets.

@douglampe
douglampe / VSDiff.bat
Created June 4, 2016 21:39
Compare 2 files using VisualStudio 2015 diff tool
"%VS140COMNTOOLS%/../ide/vsdiffmerge" "%1" "%2"
@douglampe
douglampe / gist:738fd9634cb30938b9e98a2f13491e4a
Created August 1, 2017 18:32
Use sed to add beta prerelease to version in package.json
sed -r -i "s|(\"version\"\s*:\s*\")([^\"]+)(\")|\1\2-beta.$CI_JOB_ID\3|" package.json
@douglampe
douglampe / click-outside-directive.js
Created August 12, 2017 20:34
AngularJS directive to evaluate expression when clicking outside element
/* This is handy with ui-bootstrap since you can do this:
<nav click-outside="expanded = false"
...
<button type="button" class="navbar-toggle collapsed" ng-click="expanded = !expanded" ...
...
<div uib-collapse="!expanded" class="collapse navbar-collapse">
*/
angular.module('myModule').directive('clickOutside', ExpandCollapse);
@douglampe
douglampe / docker-rebuild.sh
Last active August 12, 2017 20:35
Bash script to rebuild and run docker image from content in ~/app/publish.tar.gz
# Note: Assumes dockerfile is in ~/app and content is in ~/app/publish.tar.gz
proj=$1
cd ~/app
docker rm $(docker stop $(docker ps -a -q --filter ancestor=$proj --format="{{.ID}}"))
rm -rf publish
tar -xvzf publish.tar.gz
docker build -t $proj .
docker run -d -p 80:5000 $proj
@douglampe
douglampe / docker-rm-all.sh
Created August 14, 2017 14:34
Bash script to stop and remove all docker containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@douglampe
douglampe / find-mkdocs-components.sh
Created August 16, 2021 17:51
Find all folders named ./components/[folder]/docs and copy contents to ./docs/components/[folder]
#!/bin/bash
find . | grep -E "^\./components/(.*)/docs$" | while read -r path; do
folder=$(echo "$path" | sed 's/^.\/components\(.*\)\/docs$/\1/')
mkdir -p ./docs/components/$folder
cp -r $path/* ./docs/components/$folder
done
@douglampe
douglampe / sam-pipeline-bootstrap.yaml
Created October 25, 2021 14:56
CloudFormation Template generated by sam pipeline bootstrap
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
PipelineUserArn:
Type: String
PipelineExecutionRoleArn:
Type: String
CloudFormationExecutionRoleArn:
Type: String
@douglampe
douglampe / github-actions-sam-pipeline.yaml
Created October 25, 2021 15:58
Pipeline for GitHub created by sam pipeline init
name: Pipeline
on:
push:
branches:
- 'main'
- 'feature**'
env:
PIPELINE_USER_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@douglampe
douglampe / sam-bootstrap-stack-named.yaml
Last active November 5, 2021 21:59
CloudFormation Template for SAM pipeline with names
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
This template deploys resources required for deploying a Lambda function via SAM. This template was initially
created by running sam pipeline bootstrap. This command creates a CloudFormation stack and deploys it to
a specific account. Therefore, this template can be updated to match future SAM requirements by running
sam pipeline bootstrap and then capturing the template from the generated stack.
The names of resources have been set in this template to allow for reuse across multiple Lambda deployments.
The GitHub actions workflow included in this project uses default values for resources which match the naming
@douglampe
douglampe / postgres-stack.yml
Created November 6, 2021 21:02
CloudFormation Template for EC2 running Postgres on Docker
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
PostgresVpcId:
Type: 'AWS::EC2::VPC::Id'
Subnet1:
Type: String
Subnet2:
Type: String
HostedZoneId:
Type: String