const groupBy = key => array =>
array.reduce((objectsByKeyValue, obj) => {
const value = obj[key];
objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
return objectsByKeyValue;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if(!function_exists('wc_get_products')) { | |
| return; | |
| } | |
| $paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1; | |
| $ordering = WC()->query->get_catalog_ordering_args(); | |
| $ordering['orderby'] = array_shift(explode(' ', $ordering['orderby'])); | |
| $ordering['orderby'] = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ul class="products"> | |
| <?php | |
| $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'camisa' ); | |
| $loop = new WP_Query( $args ); | |
| while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?> | |
| <h2>Shoes</h2> | |
| <li class="product"> | |
| <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> | |
| <?php | |
| woocommerce_show_product_sale_flash( $post, $product ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <ruleset name="phpmd.xml" | |
| xmlns="http://pmd.sf.net/ruleset/1.0.0" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" | |
| xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> | |
| <description>PHPMD Ruleset for a WordPress Theme</description> | |
| <rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" /> | |
| <rule ref="rulesets/cleancode.xml/ElseExpression" /> | |
| <rule ref="rulesets/cleancode.xml/StaticAccess" /> |
download and install Solr from http://lucene.apache.org/solr/.
you can access Solr admin from your browser: http://localhost:8983/solr/
use the port number used in installation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken | |
| * It was requested to be introduced at as part of the jsonwebtoken library, | |
| * since we feel it does not add too much value but it will add code to mantain | |
| * we won't include it. | |
| * | |
| * I create this gist just to help those who want to auto-refresh JWTs. | |
| */ | |
| const jwt = require('jsonwebtoken'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <ruleset> | |
| <description>Custom ruleset for Behance code standards</description> | |
| <!-- Rues are imported individually to allow for easy configuration --> | |
| <!-- Property names and values can be found here: http://phpmd.org/rules/index.html --> | |
| <rule ref="rulesets/codesize.xml/ExcessiveMethodLength"> | |
| <properties> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Existence of Composition class requires that an external object of | |
| * class B is passed in on construction | |
| * | |
| * UML Explanation - The object at this role contains the object at the opposite role. | |
| * | |
| * Alternatively stated, an object of class Composition cannot be created without | |
| * an object of class B (in this case through dependency injection) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ./__mocks__/localStorage.js | |
| let mockStorage = {}; | |
| module.exports = window.localStorage = { | |
| setItem: (key, val) => Object.assign(mockStorage, {[key]: val}), | |
| getItem: (key) => mockStorage[key], | |
| clear: () => mockStorage = {} | |
| }; |
NewerOlder
