Skip to content

Instantly share code, notes, and snippets.

@matthewjackowski
matthewjackowski / wordpress.vcl
Last active December 27, 2022 02:56
Varnish 4 VCL configuration for WordPress. Also allows purging
# A heavily customized VCL to support WordPress
# Some items of note:
# Supports https
# Supports admin cookies for wp-admin
# Caches everything
# Support for custom error html page
vcl 4.0;
import directors;
import std;
@matthewjackowski
matthewjackowski / install-wp-tests.sh
Last active May 8, 2022 10:45
Install Wordpress and Tests
#!/usr/bin/env bash
##
# This script installs wordpress for phpunit tests and rspec integration tests
##
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
DIR=$(dirname ${DIR})
if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
exit 1
@matthewjackowski
matthewjackowski / pg-cron-setup.sh
Created July 12, 2017 08:01
Pg-cron on a Amazon AMI
sudo yum -y update
sudo yum -y localinstall https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm
sudo yum -y install postgresql96 postgresql96-server
sudo su - postgres -c "/usr/pgsql-9.6/bin/initdb"
sudo service postgresql-9.6 start
curl https://install.citusdata.com/community/rpm.sh | sudo bash
sudo yum install -y pg_cron_96
sudo -u postgres echo "shared_preload_libraries = 'pg_cron'" >> /var/lib/pgsql/9.6/data/postgresql.conf
@matthewjackowski
matthewjackowski / edgecache.vcl
Last active June 19, 2021 01:35
A basic vcl setup for edge caching
# A basic setup for the edge
# Strips cookies and un-needed params
# Does a few redirects
# Sets forwarded proxy headers
# Custom error page
vcl 4.0;
import std;
# Backend setup
backend default {
@matthewjackowski
matthewjackowski / browser_remote.py
Created March 23, 2019 21:44
Raspberry Pi Remote Browser
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--noerrdialogs")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--kiosk")
chrome_options.add_argument("--start-maximized")
chrome_options.accept_untrusted_certs = True
chrome_options.assume_untrusted_cert_issuer = True
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
public class Main
{
public static void main(String[] args) {
@matthewjackowski
matthewjackowski / Facade.py
Created June 10, 2017 17:21
Pythonic Facade
# ChangeInterface/Facade.py
class A:
def __init__(self, x): pass
class B:
def __init__(self, x): pass
class C:
def __init__(self, x): pass
# Other classes that aren't exposed by the
# facade go here ...
@matthewjackowski
matthewjackowski / angular-translate-basic-setup.js
Last active February 13, 2017 10:47
Basic App Setup for Angular Translate
var translations = {
"All": "All",
"Active": "Active",
"Completed": "Completed",
"Clear_Completed": "Clear_Completed"
};
var estranslations = {};
app.config(['$translateProvider', function ($translateProvider) {
@matthewjackowski
matthewjackowski / Dockerfile
Last active October 9, 2016 23:34
An opinionated Docker build for Txgh
FROM alpine:3.3
MAINTAINER Matthew Jackowski <matthew@transifex.com>
# Update and install all of the required packages.
# At the end, remove the apk cache
RUN apk update && \
apk upgrade && \
apk add bash curl-dev ruby-dev build-base && \
apk add ruby ruby-io-console ruby-bundler && \
rm -rf /var/cache/apk/*
@matthewjackowski
matthewjackowski / remove-translation-segmentation.rb
Created July 28, 2016 06:10
For XLIFF files - remove segmentation markup
#!/usr/bin/env ruby
require 'optparse'
require 'nokogiri'
# This will hold the options we parse
options = {}
# Build command line parser
OptionParser.new do |p|