Skip to content

Instantly share code, notes, and snippets.

View w33zy's full-sized avatar

Kemory Grubb w33zy

  • 13:41 (UTC -04:00)
View GitHub Profile
@w33zy
w33zy / json-schema-mockup.php
Created January 19, 2018 22:47
JSON Schema Mockup
<?php
/**
* Generates the markup for the 'Review' schema type in the JSON+LD format.
*
* @since 1.0.0
*
* @param int $review_id The post ID of the current review.
*
* @return string
(function(window) {
'use strict';
var toggleEvent = function(el, name, fn, unbind) {
var methodName = (unbind ? 'remove' : 'add') + 'EventListener';
el[methodName](name, fn, false);
};
@w33zy
w33zy / cat-like-custom-taxonomy.php
Created January 7, 2018 16:11 — forked from gschoppe/cat-like-custom-taxonomy.php
Use category (checkbox-based) interface with non-hierarchical custom taxonomies
<?php
// Event taxonomies
add_action( 'init', function() {
$labels = array(
'name' => _x( 'Terms', 'taxonomy general name' ),
'singular_name' => _x( 'Term', 'taxonomy singular name' ),
);
register_taxonomy( 'taxonomy_name', array( 'post' ), array(
'hierarchical' => false,
@w33zy
w33zy / php7.1.md
Last active May 28, 2018 01:32 — forked from VirtuBox/php7.1.md
How to install php7.1-fpm with EasyEngine

How to install php7.2-fpm with EasyEngine


Install php7.2-fpm

apt install php7.2-common php7.2-cli php7.2-zip php7.2-opcache php7.2-mysql php7.2-mcrypt php7.2-mbstring php7.2-json php7.2-intl php7.2-gd php7.2-fpm php7.2-curl php7.2-bz2

Copy the php7.2-fpm pool configuration from php7.0-fpm

cp -f /etc/php/7.0/fpm/pool.d/www.conf /etc/php/7.2/fpm/pool.d/www.conf
@w33zy
w33zy / jpg-png-optimize.md
Created January 4, 2018 20:39 — forked from VirtuBox/jpg-png-optimize.md
Optimize your jpg & png images with jpegoptim and optipng on linux

JPG and PNG image bulk optimization

Install jpegoptim and optipng

apt update && apt install jpegoptim optipng -y

JPG optimization

cd /path/to/your/image/folder
@w33zy
w33zy / index.md
Created October 29, 2017 22:26 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@w33zy
w33zy / stars-block.js
Created September 30, 2017 20:18 — forked from pento/stars-block.js
Gutenberg Stars Block
( function( blocks, element ) {
var el = element.createElement;
function Stars( { stars } ) {
return el( 'div', { key: 'stars' },
'★'.repeat( stars ),
( ( stars * 2 ) % 2 ) ? '½' : '' );
}
blocks.registerBlockType( 'stars/stars-block', {
@w33zy
w33zy / repeatable-fields-metabox.php
Created May 11, 2017 02:04 — forked from helen/repeatable-fields-metabox.php
Repeating Custom Fields in a Metabox
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@w33zy
w33zy / add-term-to-custom-taxonomy.php
Created April 19, 2017 22:25 — forked from ms-studio/add-term-to-custom-taxonomy.php
add term metabox to custom taxonomy - using WP 4.4 term meta functions
<?php
// source: http://wordpress.stackexchange.com/questions/211703/need-a-simple-but-complete-example-of-adding-metabox-to-taxonomy
// code authored by jgraup - http://wordpress.stackexchange.com/users/84219/jgraup
// CREATE CUSTOM TAXONOMY
add_action( 'init', '___create_my_custom_tax' );
@w33zy
w33zy / Inflect.php
Created April 18, 2017 01:51 — forked from tbrianjones/Inflect.php
A PHP Class for converting English words between Singular and Plural.
<?php
// original source: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
/*
The MIT License (MIT)
Copyright (c) 2015
Permission is hereby granted, free of charge, to any person obtaining a copy