Skip to content

Instantly share code, notes, and snippets.

@geerlingguy
geerlingguy / cache-purge.yml
Last active November 30, 2022 19:26
Cache purge script to clear Nginx + Cloudflare cache for a given set of URLs.
---
- hosts: webserver
become: true
gather_facts: false
vars:
# API token should be created with cache_purge permissions.
cloudflare_purge_zone: [zone id from cloudflare]
cloudflare_purge_token: "{{ lookup('env','CLOUDFLARE_PURGE_TOKEN') }}"
cloudflare_purge_body:
@cmer
cmer / whitelist_telnyx_ip.sh
Created November 13, 2021 14:13
Whitelist IP with Telnyx (cronjob)
#!/bin/bash
# This simple bash script will auto-update Telnyx with the network's public IP address when it changes.
# Simply add a cron job to call it every minute or so.
#
# requirements: apt install curl dnsutils jq
#
API_KEY="{{ API_KEY_HERE }}"
@alyssacohen
alyssacohen / lapdogbackup.md
Last active October 2, 2022 02:35
My laptop backup with restic

My Laptop Backup with restic

Some notes about setting up automatic backup on IBM Cloud Object Storage.

Inspired by an article about making free backups to the cloud and this one about automating the process with systemd, I decided to set up automatic backup over the internet of my mule laptop "lapdog". It's an Arch Linux powered machine I mostly use to kill time, so it's not a big deal if for some reason I screw things up. Something went wrong when I followed that guide, so I decided to retrace all the steps following restic and aws documentation instead of those articles. And here is my version of the guide (hope it helps someone) IBM COS basically let you create an Amazon S3 bucket with up to 25GB of cloud space to upload your backups for free! 😁 Too small for a full system backup, but enough fo

@herberthamaral
herberthamaral / nats_to_sse.py
Last active January 3, 2024 14:51
Listen to a nats topic and write to a HTTP client listening via server-sent-events
import asyncio
from typing import AsyncGenerator, Dict
from fastapi import FastAPI
from nats.aio.client import Client as NATS
from nats.aio.client import Msg
from starlette.requests import Request
from starlette.responses import StreamingResponse
app = FastAPI()
@brasey
brasey / Configure systemd-resolved to use a specific DNS nameserver for a given domain.md
Created October 25, 2019 14:38
Configure systemd-resolved to use a specific DNS nameserver for a given domain

Configure systemd-resolved to use a specific DNS nameserver for a given domain

Use case

Given

  • I use a VPN to connect to my work network
  • I'm on a Linux computer that uses systemd-resolved
  • I have a work domain called example.com
  • example.com is hosted by both public and private DNS nameservers
@ruanbekker
ruanbekker / traefik_portainer.md
Last active January 30, 2024 20:15
Traefik with SSL + Portainer on Docker Swarm Repro

Traefik and Portainer on Docker Swarm with Letsencrypt

Reproducing a Traefik with SSL and Portainer setup on a 2 Node Docker Swarm

Install Docker:

Install Docker on both nodes with a Bootstrap Script:

$ curl https://gitlab.com/rbekker87/scripts/raw/master/setup-docker-ubuntu.sh | bash
@tuco86
tuco86 / Dockerfile
Last active May 30, 2019 21:05
Build packages as wheels, then install in small container.
FROM python:3.7-slim-stretch AS build
RUN \
apt-get -q update \
&& apt-get -q install -y --no-install-recommends \
build-essential \
libssl-dev \
&& rm -rf /var/lib/apt/lists/* \
&& pip install -U pip
@perfecto25
perfecto25 / resticheat.md
Last active March 3, 2024 12:34
Restic cheatsheet

Restic backup application - commands cheatsheet

Installation & config

  1. add Retic repo
  2. yum install restic

add a Restic credential file to root

vim /root/.restic
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@undernewmanagement
undernewmanagement / Dockerfile
Created April 2, 2019 22:32
Sentry Jira plugin patched for sentry onpremise v9
FROM sentry:9.0-onbuild
COPY plugin.py /usr/local/lib/python2.7/site-packages/sentry_plugins/jira/plugin.py