TLDR: Use for...of
instead of forEach()
in asynchronous code.
For legacy browsers, use for...i
or [].reduce()
To execute the promises in parallel, use Promise.all([].map(...))
import * as React from 'react'; | |
import { useLocation } from '@reach/router'; | |
import queryString from 'query-string'; | |
const getSelectedTheme = (query) => { | |
const fallback = 'light'; | |
if (query) { | |
const queriedTheme = queryString.parse(query); |
/** | |
* A very simple autocomplete component | |
* | |
* This is to replace the OOTB Gutenberg Autocomplete component because it is | |
* currently broken as of v4.5.1. | |
* | |
* See Github issue: https://github.com/WordPress/gutenberg/issues/10542 | |
* | |
* Note: The options array should be an array of objects containing labels and values; i.e.: | |
* [ |
/** | |
* Check if Gutenberg is active. | |
* Must be used not earlier than plugins_loaded action fired. | |
* | |
* @return bool | |
*/ | |
private function is_gutenberg_active() { | |
$gutenberg = false; | |
$block_editor = false; |
import * as React from 'react'; | |
import { theme } from './theme'; | |
import { ThemeProvider, createGlobalStyle } from './styled-components'; | |
const GlobalStyle = createGlobalStyle` | |
body { | |
font-family: Times New Roman; | |
} | |
`; |
If you hate git submodule
, then you may want to give git subtree
a try.
When you want to use a subtree, you add the subtree to an existing repository where the subtree is a reference to another repository url and branch/tag. This add
command adds all the code and files into the main repository locally; it's not just a reference to a remote repo.
When you stage and commit files for the main repo, it will add all of the remote files in the same operation. The subtree checkout will pull all the files in one pass, so there is no need to try and connect to another repo to get the portion of subtree files, because they were already included in the main repo.
Let's say you already have a git repository with at least one commit. You can add another repository into this respository like this:
// MIT Licensed | |
// Author: jwilson8767 | |
/** | |
* Waits for an element satisfying selector to exist, then resolves promise with the element. | |
* Useful for resolving race conditions. | |
* | |
* @param selector | |
* @returns {Promise} | |
*/ |
<?php | |
/** | |
* This file handles the cloning of any post type. | |
*/ | |
class Clone_Posts { | |
/** | |
* Instances of child classes. | |
* |
First install Brew on your MAC
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew tap homebrew/dupes
brew tap homebrew/php
brew install php70
mcrypt
: brew install mcrypt php70-mcrypt
brew install composer