Skip to content

Instantly share code, notes, and snippets.

View intermundos's full-sized avatar

Anton St. intermundos

View GitHub Profile
@mikowl
mikowl / oneliners.js
Last active June 29, 2024 17:39
👑 Awesome one-liners you might find useful while coding.
// 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);
@GhazanfarMir
GhazanfarMir / clear-images.sh
Last active June 22, 2024 11:16
Single shell script to remove all containers, images and volumes used by containers. The script first tries to stop containers if there is any running, then remove the containers, followed by images removal and finally the container volumes.
#!/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
@XoseLluis
XoseLluis / es6ProxiesAndGetTrap.js
Last active December 13, 2021 10:10
ES6 proxies and method interception, 2 different ways of setting your get trap
// 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);
},
@laziel
laziel / unlock.js
Created September 18, 2015 09:02
Unlock Web Audio in iOS 9 Safari
var ctx = null, usingWebAudio = true;
try {
if (typeof AudioContext !== 'undefined') {
ctx = new AudioContext();
} else if (typeof webkitAudioContext !== 'undefined') {
ctx = new webkitAudioContext();
} else {
usingWebAudio = false;
}
@spodlecki
spodlecki / document_with_one_inline_and_one_wrapper_ad.xml
Last active February 15, 2021 11:38
VAST 2.0 with a single wrapper
<!-- 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>
@ohanhi
ohanhi / frp.md
Last active May 6, 2024 05:17
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Editorial note

@rileypaulsen
rileypaulsen / functions.php
Created August 19, 2014 16:08
Add Advanced Custom Fields Fields to the WP REST API
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);
}