This file contains hidden or 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
sudo sh -c 'truncate -s 0 $(docker system info | grep "Docker Root Dir" | cut -d ":" -f2 | cut -d " " -f2-)/containers/*/*-json.log'; |
This file contains hidden or 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
{ | |
"snippet-rf": { | |
"prefix": "rf", | |
"body": [ | |
"import React from 'react';", | |
"import s from './${TM_FILENAME_BASE}.module.css'", | |
"", | |
"", | |
"interface ${TM_FILENAME_BASE}Props {", | |
" // TODO", |
This file contains hidden or 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 uniqueBy = (items: any[]) => (key: string) => | |
[...new Map(items.map(item => [item[key], item])).values()] | |
// OR | |
const unique = [...new Map(items.map(item => [item[key], item])).values()]; |
This file contains hidden or 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
// \p{L} for any text character | |
// \d for any digit | |
// /u for unicode | |
const replaced = url.replace(/[^\p{L}\d]/gimu, '') |
This file contains hidden or 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 timezone: string = Intl.DateTimeFormat().resolvedOptions().timeZone; // Gives "Indian/Mauritius" | |
const timezoneDelayInMinutes: number = new Date().getTimezoneOffset(); // -240 because of GMT+4 |
This file contains hidden or 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
// shuffle an array | |
const shuffle = (array: any[]) => array.sort(() => 0.5 - Math.random()); |
This file contains hidden or 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 puppeteer = require('puppeteer'); | |
const assert = require('assert'); | |
const BASEURL="https://www.something.com" | |
(async () => { | |
const browser = await puppeteer.launch({ | |
headless: process.env.CI === 'true', | |
slowMo: 20, | |
devtools: process.env.CI !== 'true', | |
args: [ |
This file contains hidden or 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
// full article https://medium.com/@martinratinaud/typescript-conditional-types-the-simple-example-8c971c04b6bc | |
// playground https://www.typescriptlang.org/play/#code/PTAEDEFcBttBDATgFwJYGNoFNQHsB2oAFssgA4DOAXCALZYAmqktAdOrrcAAK1Jr5E8AfEgNgyAJ5ksFdIlRlkAWg74maAvGjKpMirqJZlFVLTLZlWAB7xzlgBzoAnAHYAjOgAMAFgBGAGx+6ABQIXo4AJIAKtI4ALygAOTQkgroFEmgAD7JFBaoyEkA3OFxoJEUADJpGBQA8ogAygXIADzRAHygidGgNshY6hTJqemZoAD8oAAKiJyoFFhtAERjdSvdVKAr+dCFK6UhahTIoABmkPjoPaAAFBHbMXEAlE-VtRmNLfvtzzLdeLdADeIVA4NAqHO9wiPXiiRSn0yL1AoIh6NAiCwyEgiEIcwWS1YWIouGgADcsHdEeMki9SuiAL5giFYnF4vKtEohZlAA | |
type IType = 'lyrics' | 'split'; | |
type IsLyricsOrSplit<T> = T extends 'lyrics' ? Promise<"lyrics"> : "split"; | |
const func = (type: IType): IsLyricsOrSplit<IType> => { | |
if (type === 'lyrics') { | |
return Promise.resolve('lyrics'); | |
} |
This file contains hidden or 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
// ==UserScript== | |
// @name Google eyes-catching-design remover | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Will put a lower opacity on the url because since last update, it is too eye-catching for me | |
// @author Martin Ratinaud <[email protected]> | |
// @include /^https?://.*\.google\..*/*/ | |
// @grant none | |
// ==/UserScript== |