Skip to content

Instantly share code, notes, and snippets.

View panayotoff's full-sized avatar

Chris panayotoff

View GitHub Profile
@ulises-jeremias
ulises-jeremias / auth-hook.js
Last active January 3, 2024 06:39
Examples of hooks utils using axios, recoil.js, keycloak-js, @react-keycloak/web and more.
import { useCallback, useEffect, useState } from 'react';
import { useSetRecoilState } from 'recoil';
import { useKeycloak } from '@react-keycloak/web';
import { commonNotification } from './common';
/**
* Returns the auth info and some auth strategies.
*
*/
/*
* ============================================================================
*
* Filename: day4.cpp
*
* Description: Day 4 of Advent of Code solution
*
* Version: 1.0
* Created: 12/4/2019 7:23:58 PM
* Revision: none
// 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;
}
@mikowl
mikowl / oneliners.js
Last active March 28, 2024 20:52
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
function Mutilator(data, name, context) {
this.n = name || `mutilation-${+new Date()}`;
this.d = data;
this.c = context || window;
this.isArr = function(p) {
return this.d[p].constructor == Array;
};
this.dispatch = function(p, v, t) {
this.c.dispatchEvent(
new CustomEvent(this.n, {
@asvae
asvae / Hunt for perfect modal.md
Created July 16, 2018 09:16
Hunt for perfect modal

Hunt for perfect modal

#modal #popup #javascript #vuejs 2017-05-08

vue navigation

Hey. Today we will pursue our dream for perfect modal. Being perfect means:

  • Floats above everything else.
  • Is not blocking.
  • Supports nesting of any depth.
@kjbenk
kjbenk / class-taxonomy-top-level-url.php
Last active November 26, 2019 09:27
WordPress: Taxonomy Top Level URL
<?php
/**
* The class used to make certain taxonomies have a top level URL.
*/
/**
* The Taxonomy_Top_Level_URL class.
*/
class Taxonomy_Top_Level_URL {
/**
@zgordon
zgordon / registerblock-custom-icon-gutenberg.js
Last active January 2, 2022 19:56
Example for how to create use a custom SVG icon for a block in Gutenberg
// Import __ from i18n internationalization library
const { __ } = wp.i18n;
// Import registerBlockType() from block building libary
const { registerBlockType } = wp.blocks;
// Import the element creator function (React abstraction layer)
const el = wp.element.createElement;
/**
* Example of a custom SVG path taken from fontastic
*/
@Geoff-Ford
Geoff-Ford / master-javascript-interview.md
Last active May 2, 2024 13:13
Eric Elliott's Master the JavaScript Interview Series