Skip to content

Instantly share code, notes, and snippets.

View onnimonni's full-sized avatar

Onni Hakala onnimonni

View GitHub Profile
@onnimonni
onnimonni / validate_sha256sum
Last active May 8, 2024 11:53
Shell script to validate file sha256 hashes. I use this to check if downloaded binaries are correct in Dockerfiles. This might make updating harder but at least it you see which parts have been updated since the last run.
#!/bin/sh
##
# This script contains helper for sha256 validating your downloads
#
# Source: https://gist.github.com/onnimonni/b49779ebc96216771a6be3de46449fa1
# Author: Onni Hakala
# License: MIT
##
# Stop program and give error message
@onnimonni
onnimonni / s3.tf
Created March 13, 2017 10:03
s3 replicated bucket with terraform
# Create all variables used in this Terraform run
variable "aws_access_key" {}
variable "aws_access_secret_key" {}
variable "aws_bucket_name" {}
variable "aws_region_main" {
default = "eu-west-1"
}
variable "aws_region_replica" {
default = "eu-central-1"
}
@onnimonni
onnimonni / rename-uploads.php
Created February 25, 2016 14:20
Remove accents from Wordpress uploads. This renames all files and replaces corresponding attachment in WordPress database. You probably use linux in production and might run OS X in development. This helps to avoid possible problems with filenames. To avoid this in future install mu-plugin which hooks in 'sanitize_file_name'
<?php
/*
* Replace-uploads.php
* This replaces all accents from your uploads
* you can run this with wp-cli: $ wp eval-file replace-uploads.php
*/
/**
* cd to right path before changes
*/
@onnimonni
onnimonni / wpai-run-imports.sh
Created September 19, 2016 06:58
Helper bash script which you can use to run wp all import synchronously. This also outputs problems which you may have with wpai.
#!/bin/bash
##
# Script to run WP All Import scripts sychronously with cron
##
# This is default wp core directory for us
ABSPATH="/var/www/project/wp"
function usage()
{
@onnimonni
onnimonni / terraform_digitalocean_dokku.tf
Created June 28, 2017 14:41
Example terraform config for creating a digitalocean droplet with volume.
variable "digitalocean_token" {
description = "This is the Digitalocean API-token which is used to setup the machines."
}
variable "digitalocean_region" {
description = "For example: nyc1, nyc2, ams2, ams3, fra2"
default = "fra1"
}
variable "digitalocean_dokku_size" {
description = "Instance size: 512mb, 1gb, 2gb, 4gb ..."
default = "2gb"
@onnimonni
onnimonni / debug-filters.php
Last active September 2, 2021 17:08
My helper for debugging wordpress filter the_content. put it in mu-plugins
<?php
/*
Plugin Name: Debug filters for WordPress
Version: 0.1
Author: Onni Hakala
Author URI: http://seravo.fi
*/
if (isset($_GET['debug']) && $_GET['debug']=='filters') {
//remove_filter( 'the_content','capital_P_dangit');
@onnimonni
onnimonni / composer.json
Last active January 25, 2021 20:42
composer.json for latest Wordpress using johnpbloch/wordpress and languages.koodimonni.fi. This file has also an example of how to handle wordpress dropin-files (e.g. object-cache.php, sunrise.php, ...) using composer.json
{
"repositories": [
{
"type": "composer",
"url": "https://wp-languages.github.io"
},
{
"type": "composer",
"url": "https://wpackagist.org"
}
@onnimonni
onnimonni / ssl_client_cert_if.conf
Last active September 14, 2020 04:32
How to regex from nginx variable with map directive
##
# I wanted to use same ssl client certificate CA in nginx for multple client certs
# but restrict the users outside our organisation accessing everything.
# Because I can decide what to put into the emailAddress I can force verify everything and only pass the proper users.
##
##
# This way you can restrict users only with email addresses from @koodimonni.fi
# Put this into http context in nginx configs
##
@onnimonni
onnimonni / Dockerfile
Last active August 8, 2018 11:24
How to fix cron and su 'System error' with debian and docker running with --net=host option. https://github.com/docker/docker/issues/5899
FROM debian:jessie
MAINTAINER Onni Hakala <onni.hakala@geniem.com>
ENV DEBIAN_FRONTEND=noninteractive
RUN set -x \
# Add all deb-src addresses
&& echo "deb http://deb.debian.org/debian jessie main\n\
deb-src http://deb.debian.org/debian jessie main\n\
@onnimonni
onnimonni / object-cache.php
Created November 28, 2014 12:44
Object cache plugin for wordpress (Pantheon wp-redis plugin) which respects Pragma headers. Only wp_cache_get() is modified since I think it's a good idea to allow the cache to be updated.
<?php
/*
Plugin Name: WP Redis
Plugin URI: http://github.com/alleyinteractive/wp-redis/
Description: WordPress Object Cache using Redis. Requires phpredis (https://github.com/nicolasff/phpredis).
Version: 0.1
Author: Matthew Boynes, Alley Interactive
Author URI: http://www.alleyinteractive.com/
Install this file to wp-content/object-cache.php