Skip to content

Instantly share code, notes, and snippets.

@mikowl
mikowl / oneliners.js
Last active February 19, 2025 05:20
👑 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);
@xiCO2k
xiCO2k / i18n.js
Last active November 21, 2021 01:52
Simple Localization Script to sue with vue3 and Laravel
import { reactive } from 'vue';
import axios from 'axios';
const reactiveMessages = reactive({});
const loaded = [];
function setI18nLanguage(locale) {
axios.defaults.headers.common['Accept-Language'] = locale;
document.querySelector('html').setAttribute('lang', locale);