Skip to content

Instantly share code, notes, and snippets.

View codelance's full-sized avatar

Brandon Brisbon codelance

View GitHub Profile
@rowanu
rowanu / function-and-log-group.yaml
Last active March 19, 2021 12:38
Clean up a Lambda function's logs when you delete it
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
InlineCode: |
exports.handler = async () => {
@wolfeidau
wolfeidau / cognito.yml
Last active January 28, 2020 04:22
Cognito CFN stack with domain verification
AWSTemplateFormatVersion: 2010-09-09
Description: 'authentication: Resources for hosting authentication using AWS Cognito, a @wolfeidau template'
Parameters:
AppName:
Description: Name of application, used in signup emails and naming of aws resources.
Type: String
AllowedPattern: '^[a-zA-Z0-9]*$'
@aaronanderson
aaronanderson / S3Util.java
Last active February 6, 2024 10:52
Workaround to create presigned S3 URL using the new aws-sdk-java-v2 library preview
//updated for 2.0.0-preview-11
import java.io.ByteArrayInputStream;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import software.amazon.awssdk.auth.signer.AwsS3V4Signer;
import software.amazon.awssdk.auth.signer.internal.AwsSignerExecutionAttribute;
@singledigit
singledigit / cognito.yaml
Last active April 28, 2024 15:12
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole:

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4
@maxcampolo
maxcampolo / AVThumbnailGen.swift
Last active November 26, 2023 15:24
Generate images from AVAsset with AVAssetImageGenerator and from AVPlayerItem with AVPlayerItemVideoOutput
/// Generate thumbnail with AVAssetImageGenerator
func generateThumbnailFromAsset(asset: AVAsset, forTime time: CMTime) -> UIImage {
let imageGenerator = AVAssetImageGenerator(asset: asset)
imageGenerator.appliesPreferredTrackTransform = true
var actualTime: CMTime = kCMTimeZero
do {
let imageRef = try imageGenerator.copyCGImageAtTime(time, actualTime: &actualTime)
let image = UIImage(CGImage: imageRef)
return image
} catch let error as NSError {
@JCotton1123
JCotton1123 / fetchenv.sh
Created June 9, 2016 20:38
Export env variables for each AWS CloudFormation stack output
#!/bin/bash
# This script will find all AWS CloudFormation stacks matching the supplied filter
# and export the outputs into environment variables.
#
# This script is assumed to be run on a host with an IAM profile matching the following:
#
# {
# "Version": "2012-10-17",
# "Statement": [
@glarrain
glarrain / connect-heroku-app-to-postgres-rds-with-ssl.md
Last active January 4, 2023 14:01 — forked from jonyt/connect_heroku_to_amazon_rds
How to connect a Heroku application to an Amazon RDS PostgreSQL instance, forcing SSL and certificate chain verification

1 - Download the RDS certificates (root plus region-specific intermediate ones) bundle:

wget -O config/rds-combined-ca-bundle.pem https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

2 - Add config/rds-combined-ca-bundle.pem to the repository and redeploy to Heroku.

3 - Update the DATABASE_URL env var:

@rkuzsma
rkuzsma / gist:b9a0e342c56479f5e58d654b1341f01e
Last active September 19, 2022 17:16
Example Kubernetes yaml to pull a private DockerHub image
Step by step how to pull a private DockerHub hosted image in a Kubernetes YML.
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
export DOCKER_USER=Type your dockerhub username, same as when you `docker login`
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \