Skip to content

Instantly share code, notes, and snippets.

View byevhen2's full-sized avatar

Biliavskyi Yevhen byevhen2

View GitHub Profile
@byevhen2
byevhen2 / PHP 7: New Features.md
Last active February 22, 2022 21:01
PHP: New Features

PHP 7.0

All features.

  • Scalar type declarations: function f(int ...$args) (bool, int, float and string, in addition to array, callable, self, parent and interface/class name).
  • Return type declarations: function f(): bool.
  • Constant arrays using define(): define('MY_CONSTANT', [ ... ]).
  • Integer division with intdiv(): var_dump(intdiv(8, 3)); // int(3).
  • Spaceship operator: $a <=> $b → {-1, 0, 1} (less, equal, bigger).
  • Null coalescing operator:
@byevhen2
byevhen2 / apiRequest.js
Last active October 6, 2022 15:58 — forked from phpbits/apiRequest.js
Using wp.apiRequest to access custom endpoints.
// See: wp-includes/js/api-request.js
// Returns a jqXHR object. See: https://api.jquery.com/jQuery.ajax/#jqXHR
wp.apiRequest({path: '/namespace/vendor/v1/config'})
.then(configOptions => console.log(configOptions));
// jqXHR object has method then(), but does not have methods catch() or
// finally(). Use fail() or always() instead
wp.apiRequest({path: '/namespace/vendor/v1/config'})
.done(configOptions => console.log(configOptions))
@byevhen2
byevhen2 / Build both .js and .min.js with webpack.md
Last active October 22, 2022 11:58
How to build both minified and uncompressed bundle with Webpack

Q: How to build both minified and uncompressed bundle with Webpack?

A1: Use plugin UglifyJsPlugin (before webpack 4)

let webpack = require("webpack");

module.exports = {
    entry: {
        'bundle': './entry.js',
 'bundle.min': './entry.js'
@byevhen2
byevhen2 / less-is-more.md
Last active December 4, 2018 19:00 — forked from carlosschults/less-is-more.md
Less Is More

Less is more


NOTE: This gist is a translation from an article by Marcos Douglas. Here is the original version, in Brazilian Portuguese: http://objectpascalprogramming.com/posts/menos-e-mais/.


Have you ever wondered what would be the ideal quantity of arguments in a method? And how about the number of methods on an interface or class? And how many classes would you put inside a single unity?