If you have to extend an existing object with additional property, always prefer Vue.set()
over Object.assign()
(or spread operator).
Example below explains implications for different implementations.
<?php | |
function create_ACF_meta_in_REST() { | |
$postypes_to_exclude = ['acf-field-group','acf-field']; | |
$extra_postypes_to_include = ["page"]; | |
$post_types = array_diff(get_post_types(["_builtin" => false], 'names'),$postypes_to_exclude); | |
array_push($post_types, $extra_postypes_to_include); | |
foreach ($post_types as $post_type) { | |
register_rest_field( $post_type, 'ACF', [ |
# thai_strftime() | |
# Thai date and time string formatter | |
# Formatting directives similar to datetime.strftime() | |
# | |
# จัดรูปแบบข้อความวันที่และเวลา แบบเดียวกับ datetime.strftime() | |
# โดยจะใช้ชื่อเดือนเป็นภาษาไทย และปีเป็นพุทธศักราช | |
# (ไม่รองรับปีก่อน พ.ศ. 2484 - ก่อนการเปลี่ยนวันปีใหม่ไทย) | |
# | |
# No Rights Reserved | |
# PUBLIC DOMAIN or CC0 1.0 Universal |
<?php | |
namespace App\Filter; | |
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractContextAwareFilter; | |
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface; | |
use Doctrine\ORM\QueryBuilder; | |
final class OrSearchFilter extends AbstractContextAwareFilter | |
{ |
const waitFor = (ms) => new Promise(r => setTimeout(r, ms)) | |
const asyncForEach = async (array, callback) => { | |
for (let index = 0; index < array.length; index++) { | |
await callback(array[index], index, array) | |
} | |
} | |
const start = async () => { | |
await asyncForEach([1, 2, 3], async (num) => { | |
await waitFor(50) |
/** | |
* Filters an array of objects using custom predicates. | |
* | |
* @param {Array} array: the array to filter | |
* @param {Object} filters: an object with the filter criteria | |
* @return {Array} | |
*/ | |
function filterArray(array, filters) { | |
const filterKeys = Object.keys(filters); | |
return array.filter(item => { |
This script for Google Spreadsheets allows you to generate slugs for your data such as might be used for creating unique urls.
Use it like this!
# | A | B | C |
---|---|---|---|
1 | a | b | slug |
2 | foo | baz bing | =slugify(A2:B4) |
3 | bar | BAZ | |
4 | FOO | baz-bing |