Skip to content

Instantly share code, notes, and snippets.

@zpawn
zpawn / PageBuilder.js
Last active July 29, 2022 07:18
Deskpro. Example how to use PageBuilder
const IssuePage = () => {
const [state, dispatch] = useStore();
useEffect(() => {
// load data and save to state
});
return (
<PageBuilder
blocksMap={{
/*
const gendersByName: {
"Ибрагимов": "male"
"Ибрагимова": "female"
"Иванникова": "female"
"Иванов": "male"
"Иванова": "female"
"Иващенко": undefined
"Ивлев": "male"
"Ивлева": "female"
import React from 'react';
import { connect } from 'react-redux';
import {
compose,
lifecycle,
withState,
withPropsOnChange
} from 'recompose';
import { CityService } from './CityService';
/**
$blue: #007bff - rgb(0, 123, 255)
$indigo: #6610f2 - rgb(102, 16, 242)
$purple: #6f42c1 - rgb(111, 66, 193)
$pink: #e83e8c - rgb(232, 62, 140)
$red: #dc3545 - rgb(220, 53, 69)
$orange: #fd7e14 - rgb(253, 126, 20)
$yellow: #ffc107 - rgb(255, 193, 7)
$green: #28a745 - rgb(40, 167, 69)
$teal: #20c997 - rgb(32, 201, 151)
@zpawn
zpawn / gulpfile.style.js
Last active April 13, 2018 16:37
Gulp Task For Compiled Style
"use strict";
/** Plugins:
gulp-autoprefixer
gulp-csso
gulp-if
gulp-load-plugins
gulp-notify
gulp-plumber
gulp-sass
@zpawn
zpawn / font-size.scss
Last active April 7, 2018 08:24
Calculate Font Size
/** Rem output with px fallback
* desired pixel size / current pixel size = em / rem size = 20px / 16px = 1.25rem
*/
@mixin font-size($sizeValue: 1) {
font-size: ($sizeValue * 20) * 1px;
font-size: $sizeValue * 1.25rem;
}
https://codex.wordpress.org/Theme_Unit_Test
https://wordpress.org/plugins/show-current-template/
https://wordpress.org/plugins/developer/
@zpawn
zpawn / debug.php
Created March 9, 2018 10:59
Function to prints any data like a print_r function
<?php
/**
* Prints any data like a print_r function
* @param mixed ... Any data to be printed
*/
function debug () {
static $count = 0;
$args = func_get_args();
$prefix = '<ol style="font-family: Courier; font-size: 12px; border: 1px solid #dedede; background-color: #efefef; float: left; padding-right: 20px;">';
@zpawn
zpawn / wp-custom-post-taxonomy-tpl.php
Last active March 7, 2018 22:37
Wordpress: create custom Post Type & Taxonomy
<?php $terms_list = wp_get_post_terms( $post->ID, 'year' ); ?>
<?php foreach ($terms_list as $term) : ?>
<a href="<?= get_term_link( $term, 'year' ); ?>"><?= $term->name ?></a>
<?php endforeach; ?>
@zpawn
zpawn / Mediator.js
Last active October 27, 2017 17:07
Mediator
const Mediator = (() => {
"use strict";
let publisher = {
subscribers: {
any: [] // event type: subscribers
},
subscribe (fn, type = 'any') {
if (typeof this.subscribers[type] === "undefined") {