This file contains 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
const ObjectSingleton = { | |
_instance: null, | |
get instance() { | |
if (!this._instance) { | |
this._instance = { | |
singletonMethod() { | |
return 'singletonMethod'; | |
}, | |
_type: 'ObjectSingleton', |
This file contains 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 | |
/* | |
* REMOVE WORDPRESS' CRAPPY EMOJI | |
*/ | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); |
This file contains 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
# Recursively find all files of the same type in current directory | |
find . -name "*.bak" -type f | |
# Recursively find and delete all files of the same type in current directory | |
find . -name "*.bak" -type f -delete | |
# Print out a list of directories to be deleted: | |
find . -name 'node_modules' -type d -prune | |
# Delete directories from the current working directory: |
This file contains 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
export default {"type":"FeatureCollection","features":[ | |
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[74.92,37.24],[74.57,37.03],[72.56,36.82],[71.24,36.13],[71.65,35.42],[71.08,34.06],[69.91,34.04],[70.33,33.33],[69.51,33.03],[69.33,31.94],[66.72,31.21],[66.26,29.85],[62.48,29.41],[60.87,29.86],[61.85,31.02],[60.84,31.5],[60.58,33.07],[60.94,33.52],[60.51,34.14],[61.28,35.61],[62.72,35.25],[63.12,35.86],[64.5,36.28],[64.8,37.12],[66.54,37.37],[67.78,37.19],[69.32,37.12],[70.97,38.47],[71.59,37.9],[71.68,36.68],[73.31,37.46],[74.92,37.24]]]]},"properties":{"name":"Afghanistan"},"id":"AF"}, | |
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[19.44,41.02],[19.37,41.85],[19.65,42.62],[20.07,42.56],[20.59,41.88],[20.82,40.91],[20.98,40.86],[20.01,39.69],[19.29,40.42],[19.44,41.02]]]]},"properties":{"name":"Albania"},"id":"AL"}, | |
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[2.96,36.8],[8.62,36.94],[8.18,36.52],[8.25,34.64],[7.49,33.89],[9.06,32.1],[ |
This file contains 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 | |
// Pre-fills a repeater field (and its sub-fields) with default values | |
// - assuming we have a Repeater field with the key "repeater_field_123" | |
// - with the sub-fields "sub_field_1" and "sub_field_2" | |
function prefill_repeater( $field ) { | |
if ($field['value'] === false) { | |
$field['value'] = array( | |
array( |
This file contains 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
/* | |
* Fetch Worker | |
* Usage: | |
* const fetchWorker = new Worker('./fetch-worker.js'); | |
* fetchWorker.postMessage('https://some.api/with-data.json'); | |
*/ | |
self.addEventListener(‘message’, e => { | |
let url = e.data; | |
This file contains 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
const path = require('path') | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
const CleanWebpackPlugin = require('clean-webpack-plugin') | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin') | |
const devMode = process.env.NODE_ENV !== 'production' | |
const config = { | |
entry: './src/index.js', | |
output: { |
This file contains 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
/** | |
* Return the value if the conditional provided passes. | |
* | |
* @param {Boolean} conditional | |
* @param {*} template | |
*/ | |
export const when = (conditional, thing, output = null) => !!conditional ? thing : output; |
This file contains 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
@mixin breakpoint($breakpoint) { | |
@if map-has-key($breakpoints, $breakpoint) { | |
@media (min-width: #{map-get($breakpoints, $breakpoint)}) { | |
@content; | |
} | |
} @else { | |
@media (min-width: $breakpoint) { | |
@content; | |
} | |
} |
This file contains 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
/* | |
* Optimal logic to move through your array forward and backward | |
*/ | |
const arr = ['a', 'b', 'c', 'd', 'e']; | |
let currentIndex = 0; | |
function moveForward(current, array) { | |
return (current + 1) % array.length; | |
} |