Skip to content

Instantly share code, notes, and snippets.

@24HOURSMEDIA
24HOURSMEDIA / docker-compose.yml
Last active January 19, 2024 17:20
Caching proxy for S3 with SSL terminator
View docker-compose.yml
services:
ssl_terminator:
# ssl terminator docs: https://24hoursmedia.github.io/docker-nginx-ssl-terminator/
image: 24hoursmedia/nginx-ssl-terminator:1.2.0-nginx1.25-alpine3.18-slim
restart: always
depends_on:
- caching_proxy
ports:
- "${PUBLIC_HTTPS_PORT:-443}:12443"
@24HOURSMEDIA
24HOURSMEDIA / install-docker-x86.sh
Last active November 7, 2023 15:01
AWS AMI 2023 Add docker and docker compose plugin
View install-docker-x86.sh
#/bin/bash
set -e
set -o pipefail
# Install docker and docker compose plugin on AWS Linux AMI 2023
# Defaults to compose plugin for intel machines
# Run this with:
# bash <(curl -sL https://gist.githubusercontent.com/24HOURSMEDIA/52b3f516ee1427437b6f52b9b65ac969/raw/install-docker-x86.sh?_cb=$(date +%s))
@24HOURSMEDIA
24HOURSMEDIA / test-disk-speed.sh
Last active July 29, 2023 12:07
test disk speed with had-arm
View test-disk-speed.sh
!/bin/bash
sudo apt-get install hdparm
# get disk names with
sudo lsblk -l
# test speed without cache
sudo hdparm -Tt --direct /dev/sda1
# with cache
@24HOURSMEDIA
24HOURSMEDIA / __info.txt
Last active July 29, 2023 11:45
public key authentication only
View __info.txt
# Add your ssh keys first to .ssh/authorized keys
# Be sure to have the proper permissions:
chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys
@24HOURSMEDIA
24HOURSMEDIA / install-docker-rpi.sh
Last active July 29, 2023 12:15
Install docker on raspberry pi
View install-docker-rpi.sh
#!/bin/sh
sudo curl -sSL https://get.docker.com | sh
sudo usermod -aG docker $USER
@24HOURSMEDIA
24HOURSMEDIA / Jenkinsfile
Last active July 26, 2023 18:53
Jenkinsfile that shows how variables are handled in a regular agent and an agent running docker
View Jenkinsfile
pipeline{
/**
* A declarative Jenkins pipeline tjat demonstrates how variables are handled in Jenkins pipelines
* and more specifically how they are handled in stages where the agent running the stage is a docker containers.
*
* EAP Bachman / 24hoursmedia
* https://www.24hoursmedia.com
*/
@24HOURSMEDIA
24HOURSMEDIA / output.txt
Created October 8, 2021 07:40
test php deferred destruction when callbacks are injected
View output.txt
output:
no callback: testing...destruct...
with callback: testing...callback...destruct...
with callback 2: testing...callback...destruct...was unset...
(destruct was always called so that's ok)
@24HOURSMEDIA
24HOURSMEDIA / auto_decompress_kernel
Last active May 14, 2021 07:45
auto_decompress_kernel for ubuntu20.04 server / rpi usb boot (improved)
View auto_decompress_kernel
#!/bin/bash -e
# Put this script in the root of the boot partition (i.e. system-boot) and chmod it with +x
# Set Variables
BTPATH=/boot/firmware
CKPATH=$BTPATH/vmlinuz
DKPATH=$BTPATH/vmlinux
#Check if compression needs to be done.
if [ -e $BTPATH/check.md5 ]; then
@24HOURSMEDIA
24HOURSMEDIA / country_currency_map.php
Created February 6, 2021 10:18
Array of country codes to ISO-4217 currency codes as php array
View country_currency_map.php
<?php
return [
'AD' => 'EUR',
'AE' => 'AED',
'AF' => 'AFN',
'AG' => 'XCD',
'AI' => 'XCD',
'AL' => 'ALL',
'AM' => 'AMD',
@24HOURSMEDIA
24HOURSMEDIA / aws-s3-examples.php
Created January 28, 2019 15:50
Some quick examples in php to read and store data and files on AWS S3
View aws-s3-examples.php
<?php
// assume aws sdk is in composer: "aws/aws-sdk-php": "^3.0",
require __DIR__ . '/../../vendor/autoload.php';
// load $AWS_KEY, $AWS_SECRET
require __DIR__ . '/../../local/credentials.php';
$bucket = 'BUCKETNAME'
$awsCredentials = new \Aws\Credentials\Credentials($AWS_KEY, $AWS_SECRET);