Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris panayotoff

View GitHub Profile
@panayotoff
panayotoff / Eventify.js
Last active Mar 22, 2020
ES6 small event system in 30 LOC
View Eventify.js
/**
* Basic event system. Use in component or as event bus
* Author: Chris Panayotoff <chris.panayotoff[at]gmail[dot]com>
*/
export default class Eventify {
constructor() {
this.list = {};
}
@panayotoff
panayotoff / nodemon.json
Created Jan 28, 2020
NodeJS Nodemon + TypeScript
View nodemon.json
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "ts-node ./src/index.ts"
}
@panayotoff
panayotoff / wp-seeder.js
Created Nov 1, 2019
NodeJS + wp-cli post seeder
View wp-seeder.js
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const wp_path = '/Users/<User>/Documents/Sites/<WP>';
async function seed(postData = {}, rawArgs = {}) {
const wpArgs = { ...rawArgs };
let postId;
let featuredImageId;
View vue_spa_hotreload.php
// 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;
}
View webp.htaccess
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
@panayotoff
panayotoff / wp-cli posts
Created Jan 23, 2019
WP-CLI Generate dummy posts
View wp-cli posts
curl http://loripsum.net/api/4 | wp post generate --post_content --count=10
View spa-nav.php
<?php
/**
* @package SPA_Sections
* @version 1.0
*/
/*
Plugin Name: SPA Sections
Description: Adding navigations to SPA sections
Author: Chris Panayotoff
Version: 1.0
View wp-helpers.php
<?php
/*
* Return the asset path as variable
* */
function get_asset($url)
{
return get_template_directory_uri() . '/assets/' . $url;
}
/*
@panayotoff
panayotoff / pre.php
Last active Jan 10, 2019
Helper to pretty output variable
View pre.php
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',
@panayotoff
panayotoff / Component.js
Last active Jan 15, 2019
Gia.js-ish component registration
View Component.js
/**
* Single Component helper
*/
import $ from 'jquery';
import Emitter from './Events';
class Component {
constructor(element, options) {
this.element = element;