Skip to content

Instantly share code, notes, and snippets.

@strongjz
strongjz / docker-credentials.sh
Created September 4, 2020 19:19 — forked from piersharding/docker-credentials.sh
Create Docker config.json file credentials
#!/bin/bash
# This script creates a docker config.json file with the auth section
# as an example of what can be passed into GitLab-CI and used in
# conjunction with DOCKER_CONFIG - the config file directory location.
# command line parameter default values
DOCKER_REGISTRY=""
DOCKER_USER=""
DOCKER_PASSWORD=""
@miguelmota
miguelmota / Makefile
Last active June 19, 2023 21:56
Makefile docker push to AWS Elastic Container Registry (ECR)
# Login to AWS registry (must have docker running)
docker-login:
$$(aws ecr get-login --no-include-email --region us-east-1 --profile=mycompany)
# Build docker target
docker-build:
docker build -f Dockerfile --no-cache -t mycompany/myapp .
# Tag docker image
docker-tag:
@teppeis
teppeis / README.md
Created March 15, 2018 03:41 — forked from prog893/README.md
ECS Container Instance scale-in protector
@iMilnb
iMilnb / README.md
Last active January 18, 2024 08:08
AWS Terraform configuration: Stream CloudWatch Logs to ElasticSearch

Rationale

This snippet is a sample showing how to implement CloudWatch Logs streaming to ElasticSearch using terraform. I wrote this gist because I didn't found a clear, end-to-end example on how to achieve this task. In particular, I understood the resource "aws_lambda_permission" "cloudwatch_allow" part by reading a couple of bug reports plus this stackoverflow post.

The js file is actually the Lambda function automatically created by AWS when creating this pipeline through the web console. I only added a endpoint variable handling so it is configurable from terraform.

@dunkelstern
dunkelstern / style.xsl
Created September 21, 2016 12:58
nginx rtmp status style sheet
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
@pahud
pahud / check_spot_price_now.md
Created August 10, 2016 08:10
check current spot price with aws-cli
$ aws --region=ap-northeast-2 ec2 describe-spot-price-history --instance-types c4.large --start-time=$(date +%s) --product-descriptions="Linux/UNIX" --query 'SpotPriceHistory[*].{az:AvailabilityZone, price:SpotPrice}'
[
    {
        "price": "0.024900", 
        "az": "ap-northeast-2a"
    }, 
 {
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@younes0
younes0 / RateLimitSubscriber.php
Last active December 4, 2015 09:13
Rate Limit Subscriber for Guzzle 4.x + Laravel
<?php
/**
* Todo: Decouple from Laravel's Caching system
**/
use GuzzleHttp\Collection;
use GuzzleHttp\Event\BeforeEvent;
use GuzzleHttp\Event\CompleteEvent;
use GuzzleHttp\Event\EmitterInterface;
@jjmaestro
jjmaestro / whisper-calculator.py
Last active November 26, 2019 07:13
whisper-calculator.py: Calculates the size of the whisper storage for the given retention (in frequency:history format)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def archive_to_bytes(archive):
def to_seconds(s):
SECONDS_IN_A = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,
@gdvalle
gdvalle / putty-monokai.reg
Created December 2, 2012 05:24
Monokai style theme for PuTTY; colors copied from ST2's theme
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\monokai]
"Colour21"="255,255,255"
"Colour20"="245,222,179"
"Colour19"="200,240,240"
"Colour18"="0,217,217"
"Colour17"="179,146,239"
"Colour16"="174,129,255"
"Colour15"="122,204,218"