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 / codeable.io.conf
Created February 26, 2015 21:38
Codeable.io Nginx config
server {
include /home/webmaster/www/codeable.io.conf;
server_name codeable.io;
listen 443 ssl spdy default_server;
root /home/webmaster/www/codeable.io;
index index.php index.html;
error_log /var/log/nginx/codeable.io.error.log warn;
@tomazzaman
tomazzaman / class-watermark-image.php
Created April 7, 2015 19:30
Watermarking uploads in WordPress with Imagemagick
function register_watermarked_size() {
add_image_size( 'watermarked', 550, 550, true ); // This is what should be uploaded
}
add_action( 'init', 'register_watermarked_size' );
class Watermark_Image {
// The attachment meta array
public $meta = array();
@tomazzaman
tomazzaman / api.js
Created September 26, 2016 15:10
API middleware for redux
import superagent from 'superagent';
import { merge } from 'lodash';
import { camelizeKeys, decamelizeKeys } from 'humps';
import config from 'config';
const CALL_API = Symbol.for('Call API');
export const GENERIC_ERROR = 'GENERIC_ERROR';
const genericErrors = {
400: 'You\'ve attempted to make a request the server didn\'t expect',
@tomazzaman
tomazzaman / etcd.yml
Created September 14, 2016 07:59
Etcd Kubernetes DaemonSet
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
labels:
name: etcd
name: etcd
spec:
template:
metadata:
labels:
@tomazzaman
tomazzaman / functions.php
Created February 18, 2015 23:57
Insert image in WordPress with HTML5 <figure> tag and caption
<?php
// Don't include the opening tag
function html5_insert_image( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
$src = wp_get_attachment_image_src( $id, $size, false );
$html5 = "<figure id=\"post-$id media-$id\" class=\"align-$align\">";
if ( $url ) {
$html5 .= "<a href=\"$url\" class=\"image-link\"><img src=\"$src[0]\" alt=\"$alt\" /></a>";
} else {
@tomazzaman
tomazzaman / admin-testimonials.js
Last active July 28, 2018 07:34
How to create a testimonial widget with Backbone
var myWidgets = myWidgets || {};
// Model for a single testimonial
myWidgets.Testimonial = Backbone.Model.extend({
defaults: { 'quote': '', 'author': '' }
});
// Single view, responsible for rendering and manipulation of each single testimonial
myWidgets.TestimonialView = Backbone.View.extend( {
@tomazzaman
tomazzaman / acf-gravity-forms-v5.php
Created April 9, 2015 17:48
Gravity forms and Sidebar selector for Advanced Custom Fields V5
<?php
class acf_field_gravity_forms extends acf_field {
function __construct() {
$this->name = 'gravity_forms_field';
$this->label = __( 'Gravity Forms', 'acf' );
$this->category = __( "Relational", 'acf');
$this->defaults = array(
'multiple' => 0,
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:
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
@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