Skip to content

Instantly share code, notes, and snippets.

View tatemz's full-sized avatar

Tate Barber tatemz

View GitHub Profile
@tatemz
tatemz / example.ts
Created December 29, 2021 16:31
Sample of isomorphic git in Deno
import { encode } from "https://deno.land/[email protected]/encoding/base64url.ts";
import { join } from "https://deno.land/[email protected]/path/mod.ts";
import fs from "https://deno.land/[email protected]/node/fs.ts";
import git from "http://esm.sh/[email protected]";
import http from "http://esm.sh/[email protected]/http/web";
import { QueryHandler } from "./QueryHandler.ts";
const throwFSError = (e: Error) => {
if (e instanceof Deno.errors.AlreadyExists) {
throw { ...e, code: "EEXIST" };
@tatemz
tatemz / abstract-multi-singleton-factory.php
Last active July 11, 2019 22:53
Singleton factories for creating unique single and multi instance classes.
<?php
abstract class Multi_Singleton_Factory extends Singleton_Factory {
public static function get_singleton_key( $class, $args ) {
// Create a unique key based on instance-specific information (i.e. classname + args)
return md5( $class . '_' . serialize( $args ) );
}
}
@tatemz
tatemz / docker-wpcli.sh
Last active December 18, 2020 06:59
A quick way to use one-off wp-cli commands with Docker. See Part 1: https://gist.github.com/tatemz/504383c921aa5898c49b82d4ee181362
#!/bin/bash
cd wordpress-site
cat >> docker-compose.yml <<EOL
my-wpcli:
image: tatemz/wp-cli
volumes_from:
- my-wp
links:
@tatemz
tatemz / docker-wordpress.sh
Last active December 29, 2020 17:25
A quick way to get a WordPress installation up and running with Docker
#!/bin/bash
mkdir wordpress-site && cd wordpress-site
touch docker-compose.yml
cat > docker-compose.yml <<EOL
version: "2"
services:
my-wpdb:
@tatemz
tatemz / HelloWorld.java
Last active July 6, 2016 19:06
A build system for sublime text using docker java containers. Edit to fit your own needs... Check out this page for more build variables http://docs.sublimetext.info/en/latest/reference/build_systems/configuration.html
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
@tatemz
tatemz / functions.php
Last active December 19, 2017 20:38
Fixing W3 Total Cache CDN with Beaver Builder CSS media
<?php
// W3 Total Cache Integration with Beaver Builder
add_filter( 'fl_builder_render_css', __NAMESPACE__ . '\bb_plugin_cdn_url' );
function bb_plugin_cdn_url( $css ) {
// Based on wp-content/plugins/w3-total-cache/extensions/WordPressSEO.php
if ( class_exists( 'W3_Plugin_CdnCommon' ) ) {
$site_url = wp_upload_dir();
@tatemz
tatemz / cmb2-fields.php
Created November 8, 2015 19:48
Add "Other" option to allow for custom radio input with CMB2
<?php
if ( file_exists( dirname( __FILE__ ) . '/cmb2/init.php' ) ) {
require_once dirname( __FILE__ ) . '/cmb2/init.php';
} elseif ( file_exists( dirname( __FILE__ ) . '/CMB2/init.php' ) ) {
require_once dirname( __FILE__ ) . '/CMB2/init.php';
}
add_action( 'cmb2_admin_init', 'yourprefix_register_demo_metabox' );
/**
<!-- /app/code/local/MyCompany/MyModule/etc/config.xml -->
<?xml version="1.0"?>
<config>
<adminhtml>
<layout>
<updates>
<mycompany_mymodule>
<file>mycompany/mytemplate.xml</file>
@tatemz
tatemz / app.css
Last active August 29, 2015 14:15
An example how css-condense can optimize Foundation Apps (line breaks are turned on for better visual).
/* AUTOCOMPLETE */
.autocomplete{
width: 100%;
position: relative;
}
.autocomplete input{
font-size: 1.2em;
width: 100%;
<?php
if ( empty( $_POST['acf'] ) ) {
return;
}
if (
!isset( $_POST['acf']['field_543aee78c4176'] )
|| !isset( $_POST['acf']['field_543aee84c4177'] ) )
{
return;