Skip to content

Instantly share code, notes, and snippets.

def handleAuthError
puts 'Put error handling code here'
end
project_params = {
slug: "test-#{SecureRandom.uuid}",
description: 'wpml_project',
organization: user_data[:org_slug],
:private => true,
source_language_code: 'en',
@matthewjackowski
matthewjackowski / refactor_to_strategy.js
Last active December 20, 2015 08:55
Refactor to Strategy in Javascript
var message = require('./lib/zmessage');
var Strategy = function(f) {
this.send = f;
};
Strategy.prototype.execute = function(m) {
this.send(m);
};
@matthewjackowski
matthewjackowski / Message.java
Created December 28, 2015 08:40
Refactored For-Loop to Lambda in Java
package com.brilliantcoding;
public class Message {
int type;
public Message(int type){
this.type = type;
}
public String toString() {
switch (this.type) {
case 0:
@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 / txgh.yml
Last active February 26, 2016 14:26
Example txgh.yml for AWS
txgh:
github:
repos:
matthewjackowski/txgh-test-resources:
api_username: <%= 'matthewjackowski' %>
api_token: <%= 'Some Token' %>
push_source_to: <%= 'txgh-test-1' %>
branch: <%= 'master' %>
transifex:
projects:
@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 / Message.php
Created March 30, 2016 08:53
Refactoring to Factory Function in PHP
<?php
/**
* Message object class used to control when messages are output
* @package Brilliantcoding
*/
/**
* Message Class
*/
@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 / appcache.vcl
Last active April 5, 2016 14:46
A basic vcl for the app
vcl 4.0;
# Default backend definition. Set this to point to your content server.
backend default {
.host = "wordpress";
.port = "80";
}
acl edgecache {
"172.31.12.197";
@matthewjackowski
matthewjackowski / run-varnishd
Created April 2, 2016 20:07
Manually run a very small varnish
#!/bin/bash
set -e
exec bash -c \
"exec /usr/local/sbin/varnishd -F \
-a :80 \
-a :6443 \
-S /etc/varnish/secret \
-f /etc/varnish/default.vcl \