Skip to content

Instantly share code, notes, and snippets.

View andrewnimmo's full-sized avatar

Andrew David Nimmo andrewnimmo

View GitHub Profile
version: "3"
services:
sftpgo:
image: "drakkan/sftpgo:v2-alpine"
# default user id
user: 1026
restart: always
expose:
# HTTP
- "8080"
@andrewnimmo
andrewnimmo / gist:470e0b6e8b76d6fa96577866cdfb1f8c
Created November 1, 2022 12:13 — forked from rhelmer/gist:b075f21f44f3e98579b1
herokuish build+deploy using LXC

Introduction

Heroku differs from traditional build & deploy by having the concept of "buildpacks", which are a generic method to identify, compile and package builds. The traditional method here would be to have hardcoded build commands, in a Makefile for instance. Buildpacks generally make custom build+deploy steps uneccessary, although one can specify custom buildpacks if necessary.

When notifying Heroku that a deploy is needed (usually by a Github webook), Heroku will run through all supported buildpacks until one can identify your app, which is then compiled and packaged by the buildpack. The output of this process is referred to as a "slug", which contains your app and all dependencies. For instance, a Python app would have the virtualenv packaged inside it. Heroku automatically deploys slugs that are built successfully.

This document describes a way to use LXC and existing third-party tools to reproduce this setup.

You need to have a server running that accepts webhooks and can take act

@andrewnimmo
andrewnimmo / default.vcl_PREFACE.md
Created June 1, 2022 09:39 — forked from fevangelou/default.vcl_PREFACE.md
The perfect Varnish configuration for WordPress, Joomla, Drupal & other (common) CMS based websites

The perfect Varnish configuration for WordPress, Joomla, Drupal & other (common) CMS based websites

Updated on December 15th, 2021

IMPORTANT: Read this before implementing one of the configuration files below (for either Varnish 3.x or 4.x+).

USE: Replace the contents of the main Varnish configuration file located in /etc/varnish/default.vcl (root server access required - obviously) with the contents of the configuration you'll use (depending on your Varnish version) from the 2 examples provided below.

IMPORTANT: The following setup assumes a 180 sec (3 minute) cache time for cacheable content that does not have the correct cache-control HTTP headers. You can safely increase this to 300 sec (or more) for less busier sites or drop it to 60 sec or even 30 sec for high traffic sites. It obviously depends on your use case.

@andrewnimmo
andrewnimmo / install-proxmox-s3-snippet-storage.sh
Created April 11, 2022 09:50 — forked from bilalinamdar/install-proxmox-s3-snippet-storage.sh
This script will install an s3 snippet storage server for ProxMox (cicustom) using Samba and MinIO
#!/bin/bash
echo "Password for Samba User 'snippets':"
read -s smb_password_snippets
echo "Password for S3 User 'admin':"
read -s s3_password_admin
echo "Password for S3 User 'dev' (min-length: 8):"
read -s s3_password_dev
echo "Password for S3 User 'api' (min-length: 8):"
read -s s3_password_api
wget -O /usr/local/bin/minio https://dl.min.io/server/minio/release/linux-amd64/minio
@andrewnimmo
andrewnimmo / python_pymysql_notes.md
Created March 28, 2022 06:32 — forked from simonrw/python_pymysql_notes.md
Notes about pymysql connections

Database transactions

pymysql

  • Defaults to autocommit=False
connection = pymysql.connect(user='user', db='test')
cursor = connection.cursor()
cursor.execute('insert into test (value) values (10)')
@andrewnimmo
andrewnimmo / ssl_redirect.py
Created March 24, 2022 09:02 — forked from devries/ssl_redirect.py
WSGI middleware to redirect incoming http requests to https. This is not original, but I can't remember where I first found it.
from urllib import quote
class SSLRedirect(object):
def __init__(self,app):
self.app=app
def __call__(self,environ,start_response):
proto = environ.get('HTTP_X_FORWARDED_PROTO') or environ.get('wsgi.url_scheme', 'http')
if proto=='https':
@andrewnimmo
andrewnimmo / dynamicUpdate.py
Created March 19, 2022 10:33 — forked from rschutjens/dynamicUpdate.py
dynamic update of selectField options Flask Ajax
from flask import Flask
from flask import json, make_response, render_template_string, request
from flask_wtf import Form
from wtforms import IntegerField, SelectField
from wtforms.validators import DataRequired
template = """
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
@andrewnimmo
andrewnimmo / podman_macos.md
Created March 16, 2022 20:08 — forked from kaaquist/podman_macos.md
Podman with docker-compose on MacOS.

Podman with docker-compose on MacOS.

Podman an alternative to Docker Desktop on MacOS

Getting podman installed and started is super easy.
Just use brew to install it.

> brew install podman

Now since podman uses a VM just like the Docker Client on MacOS we need to initialize that and start it.

@andrewnimmo
andrewnimmo / wtf_required_if.py
Created March 13, 2022 00:13 — forked from devxoul/wtf_required_if.py
WTForms `RequiredIf` validator.
class RequiredIf(object):
"""Validates field conditionally.
Usage::
login_method = StringField('', [AnyOf(['email', 'facebook'])])
email = StringField('', [RequiredIf(login_method='email')])
password = StringField('', [RequiredIf(login_method='email')])
facebook_token = StringField('', [RequiredIf(login_method='facebook')])
"""
@andrewnimmo
andrewnimmo / install-proxmox-s3-snippet-storage.sh
Created January 7, 2022 18:21 — forked from JanHolger/install-proxmox-s3-snippet-storage.sh
This script will install an s3 snippet storage server for ProxMox (cicustom) using Samba and MinIO
#!/bin/bash
echo "Password for Samba User 'snippets':"
read -s smb_password_snippets
echo "Password for S3 User 'admin':"
read -s s3_password_admin
echo "Password for S3 User 'dev' (min-length: 8):"
read -s s3_password_dev
echo "Password for S3 User 'api' (min-length: 8):"
read -s s3_password_api
wget -O /usr/local/bin/minio https://dl.min.io/server/minio/release/linux-amd64/minio