Skip to content

Instantly share code, notes, and snippets.

@maltechx
maltechx / clouflare-worker-static-page-backblaze.js
Last active October 26, 2023 08:41
Host a static page on Backblaze and distribute it via Cloudflare and their Workers.
// Imprved the script from this blog https://www.grahn.io/posts/2020-02-08-s3-vs-b2-static-web-hosting/
// Backblaze Url
const baseURL = "https://f000.backblazeb2.com/file/yourbucket"
addEventListener('fetch', event => {
event.respondWith(handleRequest(event))
})
async function handleRequest(event) {
@evadne
evadne / 01-multistage-build.sh
Last active July 11, 2023 06:33
Build & Cache multi-stage Docker images (with Build Specification for AWS CodeBuild)
# the general idea
ImageTag="git"
FilePath="/Dockerfile"
RepoURI="123456789012.dkr.ecr.eu-west-1.amazonaws.com/repo"
Stages=$(cat $FilePath | grep -oP '^FROM .+ (AS|as) \K(.+)$')
CacheArgs=$(for Stage in $Stages; do echo "--cache-from $RepoURI:cache-$Stage"; done | paste -sd ' ')
BuildArgs="--file $FilePath $CacheArgs"
for Stage in $Stages; do docker pull $RepoURI:cache-$Stage || true; done
for Stage in $Stages; do docker build $BuildArgs --tag $RepoURI:cache-$Stage --target $Stage . || break; done
docker build $BuildArgs --tag $RepoURI:$ImageTag .
@cmcconnell1
cmcconnell1 / dist-upated-tls-certs-etcd-nodes.sh
Created April 26, 2018 19:30
Distributes updated x509 tls certs to etcd2 kube nodes and resolves outdated cert problems
#!/usr/bin/env bash
#
# Summary:
# Distributes updated x509 tls certs and resolves outdate cert problems which effectively kill your kube cluster
# ref: https://github.com/kubernetes-incubator/kube-aws/issues/1132
# ref: https://github.com/kubernetes-incubator/kube-aws/issues/1057
#
# NOTES: Ensure this is the correct process for your etcd2 kube cluster before using.
# Test on a dev/test cluster first.
# Use at own risk.
@sdenier
sdenier / Dockerfile
Created January 16, 2018 11:16
Parameterize a multi-stage Docker build output using ARG and ENV
# Build the $MODULE target (which produces a $MODULE binary)
FROM debian:latest as builder
ARG MODULE
COPY src/ .
RUN make ${MODULE}
# Build a minimal image containing the $MODULE binary
FROM alpine:latest as product
@lmakarov
lmakarov / lambda-basic-auth.js
Created August 30, 2017 19:15
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
@chronon
chronon / ext.txt
Created February 18, 2017 15:38
List of docker-php-ext-install extension names
Possible values for ext-name:
bcmath
bz2
calendar
ctype
curl
dba
dom
enchant
Import-Module WebAdministration
# Get the latest certificate in store that applies to my site
$cert = (Get-ChildItem Cert:\LocalMachine\My |
Where-Object {$_.Subject.Contains('*.example.com')} |
Sort-Object -Descending {[System.DateTime]::Parse($_.GetExpirationDateString())} |
Select-Object -First 1)
Set-Location IIS:\Sites
@trestletech
trestletech / instance-types.sh
Created June 15, 2016 16:41
Get all EC2 Instance Types in All Availability Zones
#!/bin/bash
echo "Getting list of Availability Zones"
all_regions=$(aws ec2 describe-regions --output text --query 'Regions[*].[RegionName]' | sort)
all_az=()
while read -r region; do
az_per_region=$(aws ec2 describe-availability-zones --region $region --query 'AvailabilityZones[*].[ZoneName]' --output text | sort)
while read -r az; do
@s-fujimoto
s-fujimoto / cloudfront-logstash.conf
Created April 27, 2016 11:02
Logstash configuration file for throwing CloudFront logs to Amazon ES
input {
s3 {
bucket => "<CLOUDFRONT_LOG_BUCKET>"
prefix => "<CLOUDFRONT_LOG_KEY_PREFIX>"
region => "<BUCKET_REGION_NAME>"
}
}
filter {
@andyshinn
andyshinn / Dockerfile
Created December 24, 2015 19:07
BusyBox cron container example
FROM gliderlabs/alpine:3.3
COPY myawesomescript /bin/myawesomescript
COPY root /var/spool/cron/crontabs/root
RUN chmod +x /bin/myawesomescript
CMD crond -l 2 -f