Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tomazzaman's full-sized avatar

Tomaž Zaman tomazzaman

  • Codeable ApS
  • Slovenia
View GitHub Profile
@tomazzaman
tomazzaman / observable_file.conf
Last active August 29, 2015 14:15
Do a git pull whenever a GitHub webhook triggers a php script
# This is a monit configuration file that watches a 'git.log' file
# which should be a 777 file inside your WordPress
check file observable_file with path /home/webmaster/www/domain.com/git.log
if changed checksum then exec "/usr/local/sbin/observable_file.sh"
@tomazzaman
tomazzaman / www.wp-kickstart.com.conf
Last active August 29, 2015 14:15
wp-kickstart.com Nginx vhost config
server {
include /home/webmaster/www/www.wp-kickstart.com.conf;
server_name www.wp-kickstart.com;
listen 443 ssl spdy;
server_tokens off;
client_body_buffer_size 10K;
client_header_buffer_size 1k;
@tomazzaman
tomazzaman / functions.php
Created February 18, 2015 20:35
Clear WP_Object_Cache on WPEngine to get around ACF's updating bug.
<?php
// Register script and add necessary options to it, make sure the path is correct
function flush_redis_enqueue_scripts() {
wp_enqueue_script( 'flush-redis', plugin_dir_url( __FILE__ ) . 'js/script.js', array( 'jquery' ) );
wp_localize_script( 'flush-redis', 'FlushRedis', array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'flushRedisNonce' => wp_create_nonce( 'flush-redis-nonce' ),
)
);
@tomazzaman
tomazzaman / render.php
Created February 25, 2015 11:01
Add Jetpack Markdown support for ACF
<?php
// Add these filters in functions.php
add_filter( 'meta_content', 'wptexturize' );
add_filter( 'meta_content', 'convert_smilies' );
add_filter( 'meta_content', 'convert_chars' );
add_filter( 'meta_content', 'wpautop' );
add_filter( 'meta_content', 'shortcode_unautop' );
add_filter( 'meta_content', 'prepend_attachment' );
var crypto = require("crypto");
var SECRET_KEY = 'MY_AWS_SECRET_KEY';
var POLICY_JSON = {
"expiration": "2030-12-01T12:00:00.000Z",
"conditions": [
{"bucket": "my-bucket-name"},
["starts-with", "$key", ""],
{"acl": "public-read"},
["starts-with", "$Content-Type", ""],
@tomazzaman
tomazzaman / config.py
Created July 1, 2016 20:36
Set configuration files with Jinja2
#!/usr/bin/env python
import os
import sys
from jinja2 import Environment, FileSystemLoader
def set_environment(template_dir):
env = Environment(loader=FileSystemLoader(template_dir), trim_blocks=True)
env.globals['env_var'] = lambda varname, default='': os.getenv(varname, default)
env.globals['exists'] = lambda varname: varname in os.environ
@tomazzaman
tomazzaman / postgresql
Created September 20, 2016 11:43
PostgreSQL health check through xinetd (with repmgr)
# description: An xinetd service to show PSQL status
# put this file into /etc/xinetd.d
service postgrescheck
{
type = UNLISTED
flags = REUSE
wait = no
disable = no
socket_type = stream
protocol = tcp
@tomazzaman
tomazzaman / hhvm.conf
Last active September 22, 2016 08:23
Restart HHVM with Monit
# This file should be in /etc/monit/conf.d
check process hhvm with pidfile /var/run/hhvm/pid
group hhvm
# Start program calls our custom script from above
start program = "/usr/local/sbin/start_hhvm.sh"
stop program = "/usr/sbin/service hhvm stop"
if failed unixsocket /var/run/hhvm/hhvm.sock then restart
if mem > 400.0 MB for 1 cycles then restart
if 5 restarts with 5 cycles then timeout
import fs from 'fs';
import path, { resolve } from 'path';
import assert from 'assert';
import Module from 'module';
import jsdom from 'jsdom';
import Mocha from 'mocha';
import chokidar from 'chokidar';
// Let's import and globalize testing tools so
// there's no need to require them in each test
kind: Endpoints
apiVersion: v1
metadata:
name: glusterfs
subsets:
- addresses:
# Change the following to match your GlusterFS instance IPs
- ip: 10.132.0.5
- ip: 10.132.0.6
ports: