Skip to content

Instantly share code, notes, and snippets.

View nikola-wd's full-sized avatar
💭
Available for full-time hire. React or Custom WordPress theme development.

Nikola Ivanov nikola-wd

💭
Available for full-time hire. React or Custom WordPress theme development.
View GitHub Profile
@nikola-wd
nikola-wd / async-await.js
Created January 26, 2020 20:38 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@nikola-wd
nikola-wd / remove-woocommerce-styles-scripts.php
Created November 25, 2019 01:55 — forked from gregrickaby/remove-woocommerce-styles-scripts.php
Remove WooCommerce styles and scripts.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below into functions.php
/**
* Manage WooCommerce styles and scripts.
*/
function grd_woocommerce_script_cleaner() {
// Remove the generator tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@nikola-wd
nikola-wd / asyncLoop.js
Created November 15, 2019 18:16
[async loop] Loop with setTimeout #javascript #async
const waitFor = ms => new Promise(r => setTimeout(r, ms));
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
};
(async function() {
await asyncForEach([1, 2, 3], async num => {
@nikola-wd
nikola-wd / wordpress.md
Created October 21, 2019 00:11 — forked from jermspeaks/wordpress.md
Resources collected for understanding Wordpress

Wordpress & PHP Resources

Background

I started this markdown file as a place to collect information about Wordpress and PHP when I started programming a Wordpress plugin for the first time. I decided to put out everything I could find in this gist. I will update it occassionally with code examples so I can track my progress in developing Wordpress plugins (or just the one I'm working on at work).

Wordpress 101

Wordpress Environment

@nikola-wd
nikola-wd / debounce.js
Last active December 6, 2020 16:17
[debounce] Useful for not making requests on every key stroke for example #havascript #helper #optimization
// send req after a few seconds have passed since user last wrote in the editor
export default function debounce(a,b,c){
let d,e;
return function(){
function h(){
d=null;
c||(e=a.apply(f,g));
}
let f=this,g=arguments;
return (clearTimeout(d),d=setTimeout(h,b),c&&!d&&(e=a.apply(f,g)),e)
@nikola-wd
nikola-wd / stripHTMLTags.js
Created October 1, 2019 00:43
[stripHtmlTags] Helper FN that strips html tags #javascript #html #helper
export function removeHTMLTags (str) {
return str.replace(/<[^>]*>?/gm, '');
}
@nikola-wd
nikola-wd / andy.scss
Last active August 5, 2019 02:10
[Useful SCSS Mixins 1] - Selection of useful SCSS mixins #scss #sass #mixin
/// Forces browsers to use hardware acceleration for transforms
/// @access public
/// @example scss - Usage
/// .foo {
/// @include ha;
/// }
/// @example css - Result
/// .foo {
/// -webkit-transform: translate3d(0, 0, 0);
/// -moz-transform: translate3d(0, 0, 0);
@nikola-wd
nikola-wd / _family.scss
Created August 5, 2019 00:23
[Family SCSS Mixins] - Easily use nth selectors #scss #sass #mixin
/// Select all children from the first to `$num`.
/// @group with-arguments
/// @content [Write the style you want to apply to the children, and it will be added within the @content directive]
/// @param {number} $num - id of the child
@mixin first($num) {
@if $num == 1 {
&:first-child {
@content;
}
} @else {
@nikola-wd
nikola-wd / _header.js
Created August 5, 2019 00:11
[Fixed Header onScroll] - Header get's class when scrolled #ui #sass #scss #code_bundles #header
const _headerFN = () => {
const $header = document.querySelector('.header');
const scrollTop = window.scrollY,
offsetTop = 60;
if (scrollTop >= offsetTop && window.innerWidth > 767) {
$header.classList.add('jsOnScroll');
document.body.classList.add('jsOnScroll-header');
} else {