Skip to content

Instantly share code, notes, and snippets.

View onnimonni's full-sized avatar

Onni Hakala onnimonni

View GitHub Profile
@onnimonni
onnimonni / migration directives
Created November 17, 2014 10:01
Wordpress migration with wp-cli
# These are directives to use for migrating wordpress sites into wordpress-palvelu
# In this example '123.123.123.123' is the source machine and 'www.example.com' is the site which is migrated.
# This migration mechanism demands wp-cli to be installed in both machines.
# More information about installing wp-cli: http://wp-cli.org
# Source machine: 123.123.123.123
# Source machine username: wp-user
# Wordpress siteurl: www.example.com
# ssh into your source machine
@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
@onnimonni
onnimonni / composer.json
Created December 22, 2014 00:43
koodimonni/composer-dropin-installer example composer.json
{
"name": "roots/bedrock",
"type": "project",
"license": "MIT",
"description": "A modern WordPress stack",
"homepage": "http://roots.io/wordpress-stack/",
"authors": [
{
"name": "Scott Walkinshaw",
"email": "scott.walkinshaw@gmail.com",
@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 / ufw.md
Created April 19, 2015 09:20 — forked from kimus/ufw.md

UFW

I use Ubuntu’s Uncomplicated firewall because it is available on Ubuntu and it's very simple.

Install UFW

if ufw is not installed by default be sure to install it first.

@onnimonni
onnimonni / organize.rb
Created May 14, 2015 17:52
File organizer for large amount of images
#!/usr/bin/env ruby
require 'fileutils'
def createNewFolder
picture_dir = ''
loop do
@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 / class-leaflet-options.php
Created August 2, 2015 10:39
Fixes problems with multiple default clauses. Using WordPress with HHVM results in fatal error: "Fatal error: Switch statements may only contain one default: clause in /data/wordpress/htdocs/wp-content/plugins/leaflet-maps-marker/inc/class-leaflet-options.php on line 446". I guess apache and php-fpm allow this kind of behaviour, but it isn't sta…
<?php
/**
* Leaflet Maps Marker Plugin - settings class
* based on class by Alison Barrett, http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
*/
//info prevent file from being accessed directly
if (basename($_SERVER['SCRIPT_FILENAME']) == 'class-leaflet-options.php') { die ("Please do not access this file directly. Thanks!<br/><a href='https://www.mapsmarker.com/go'>www.mapsmarker.com</a>"); }
class Class_leaflet_options {
private $panes;
private $sections;
@onnimonni
onnimonni / prepare-commit-message
Last active April 6, 2017 13:53
Git prepare commit message hook
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
#
##
# Installation on OSX:
# $ brew install aspell
# Then add Your custom word list to home folder
# The first line needs to be personal_ws-1.1 en 0