by Ossi Hanhinen, @ohanhi
with the support of Futurice 💚.
Licensed under CC BY 4.0.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf | |
// Remove any duplicates from an array of primitives. | |
const unique = [...new Set(arr)] | |
// Sleep in async functions. Use: await sleep(2000). | |
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
// or | |
const sleep = util.promisify(setTimeout); |
#!/bin/bash | |
########################################### | |
# | |
# Simple Shell script to clean/remove all container/images | |
# | |
# The script will | |
# - first stop all running containers (if any), | |
# - remove containers | |
# - remove images | |
# - remove volumes |
// http://deploytonenyures.blogspot.fr/2015/11/es6-proxies-part-ii.html | |
//to run it in node.js 4 it should be just this flag: --harmony_proxies | |
//but does not seem to work, so run it in Firefox | |
var cat = { | |
name: "Kitty", | |
method1: function(msg){ | |
console.log("cat: " + this.name + ", method1 invoked with msg: " + msg); | |
this.method2(msg); | |
}, |
var ctx = null, usingWebAudio = true; | |
try { | |
if (typeof AudioContext !== 'undefined') { | |
ctx = new AudioContext(); | |
} else if (typeof webkitAudioContext !== 'undefined') { | |
ctx = new webkitAudioContext(); | |
} else { | |
usingWebAudio = false; | |
} |
<!-- VAST document with one InLine ad and one Wrapper ad--> | |
<VAST version="2.0"> | |
<Ad id="601364"> | |
<InLine> | |
<AdSystem>Acudeo Compatible</AdSystem> | |
<AdTitle>VAST 2.0 Instream Test 1</AdTitle> | |
<Description>VAST 2.0 Instream Test 1</Description> | |
<Error>http://myErrorURL/error</Error> | |
<Impression> |
function wp_api_encode_acf($data,$post,$context){ | |
$data['meta'] = array_merge($data['meta'],get_fields($post['ID'])); | |
return $data; | |
} | |
if( function_exists('get_fields') ){ | |
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3); | |
} |