Skip to content

Instantly share code, notes, and snippets.

View panayotoff's full-sized avatar

Chris panayotoff

View GitHub Profile
[
{
"block":"Basic Latin",
"range":"0000-007F",
"low":"0000",
"high":"007F"
},
{
"block":"Latin-1 Supplement",
"range":"0080-00FF",
@panayotoff
panayotoff / MquDOM.js
Created October 20, 2018 19:07
Mqu.js DOM helpers
// shorthand helpers
export const html = document.documentElement;
export const body = document.body;
export const el = (e, p = document) => p.querySelector(e);
export const els = (e, p = document) => Array.prototype.slice.call(p.querySelectorAll(e));
export const onLoad = cb => document.addEventListener('DOMContentLoaded', cb, false);
export const isArray = obj => (Object.prototype.toString.call(obj).toLowerCase().indexOf('array') >= 0);
export const isArrayLike = obj => {
@panayotoff
panayotoff / anyrest.php
Created October 22, 2018 11:08
Simple rest controller to get page by slug
<?php
/**
* @package Any_Rest
* @version 1.7
*/
/*
Plugin Name: Any Rest
Description: Get any page by slug
Usage: http://test1.localhost/wp-json/anyrest/v2/apt?slug=hello-world
@panayotoff
panayotoff / Component.js
Last active January 15, 2019 11:06
Gia.js-ish component registration
/**
* Single Component helper
*/
import $ from 'jquery';
import Emitter from './Events';
class Component {
constructor(element, options) {
this.element = element;
@panayotoff
panayotoff / pre.php
Last active January 10, 2019 12:42
Helper to pretty output variable
function pre($var){
$styles = [
'display:block',
'padding:1em',
'margin:1em',
'border-radius:3px',
'font-size:14px',
'font-family: monospace',
'white-space: pre-wrap',
'word-wrap: break-word',
<?php
/*
* Return the asset path as variable
* */
function get_asset($url)
{
return get_template_directory_uri() . '/assets/' . $url;
}
/*
<?php
/**
* @package SPA_Sections
* @version 1.0
*/
/*
Plugin Name: SPA Sections
Description: Adding navigations to SPA sections
Author: Chris Panayotoff
Version: 1.0
@panayotoff
panayotoff / wp-cli posts
Created January 23, 2019 15:11
WP-CLI Generate dummy posts
curl http://loripsum.net/api/4 | wp post generate --post_content --count=10
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.*)\-.*(jpe?g|png) $1.webp [T=image/webp,E=accept:1]
Source:
https://buttercms.com/blog/front-end-performance-optimization-techniques
// https://medium.com/@romualdasromasdakeviius/using-vue-cli-to-build-wordpress-plugin-including-hmr-1a71dfdf05c2
// https://medium.com/@devs_group/wordpress-vue-js-with-webpack-and-hot-reload-7c4faea9d0d9
function is_develop_serve()
{
$connection = @fsockopen('localhost', '8080');
return $connection ? true : false;
}