Skip to content

Instantly share code, notes, and snippets.

View panayotoff's full-sized avatar

Chris panayotoff

View GitHub Profile
exportImage(event) {
event.stopPropagation();
this.ctx.fillStyle = "#333333";
this.ctx.font = 'bold 16px Helvetica, Arial, sans-serif';
this.ctx.textBaseline = "top";
var textSize = this.ctx.measureText("esimov.com");
//this.ctx.fillText("esimov.com", this.size - textSize.width - 10, 5);
//retrieve canvas image as data URL:
@panayotoff
panayotoff / sw.js
Last active November 15, 2016 23:08
Service Worker - custom strategy
let cacheVersion = 10;
let apiCacheName = 'api';
let staticCacheNamespace = 'static';
let staticCacheName = staticCacheNamespace + '-' + cacheVersion;
let staticFiles = [
'/',
'/index.html',
'use strict';
window._ = {};
_.templateSettings = {
evaluate: /<%([\s\S]+?)%>/g,
interpolate: /<%=([\s\S]+?)%>/g,
escape: /<%-([\s\S]+?)%>/g
};
@panayotoff
panayotoff / firebaseUtils.js
Created January 13, 2017 13:47
ES6 firebase object to array
/*
* Converts firebase object to Array;
* Each object from the array will contain 'key' property,
* corresponding to the firebase key
* */
const toArray = function (firebaseObj) {
return Object.keys(firebaseObj).map((key)=> {
return Object.assign(firebaseObj[key], {key});
//Test if the PWA is running in standalone mode
window.matchMedia( '(display-mode: standalone)' ).matches
(function(window){
const mediaRegex = /img|video/gi;
const linkStyles = {
display: 'inline-block',
padding: '5px 10px',
backgroundColor: '#ffffff',
color: '#262626',
fontWeight: '600',
cursor: 'pointer',
import {TRACKING_ID} from '../appConfig';
import store from '../store/store';
let gaAvailable = false;
let ga = null;
const loadAnalytics = () => {
const isPageSpeedBot = (navigator.userAgent.indexOf('Speed Insights') !== -1);
const blockTracking = store.getters.track.toString() === 'false';
if (blockTracking || isPageSpeedBot) {
@panayotoff
panayotoff / stinky_wc.php
Created September 19, 2017 12:51
WooCommerce - list of latest products
<?php
$args = array(
'post_type' => 'product',
'stock' => 1,
'posts_per_page' => 4,
'orderby' => 'date',
'order' => 'DESC'
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
@panayotoff
panayotoff / Gulpfile.js
Created September 26, 2017 20:57
Example Gulp config for working with WP themes;
/*
Package.json
{
"name": "gulpdev",
"version": "0.0.1",
"description": "",
"main": "index.php",
"scripts": {
"dev": "gulp"
@panayotoff
panayotoff / slugify.js
Created January 24, 2018 11:16
Slugify
export default function slugify(text) {
const a = 'àáäâèéëêìíïîòóöôùúüûñçßÿœæŕśńṕẃǵǹḿǘẍźḧ·/_,:;';
const b = 'aaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------';
const p = new RegExp(a.split('').join('|'), 'g');
/* eslint-disable */
return text
.toString()
.toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -