Skip to content

Instantly share code, notes, and snippets.

View jeremyben's full-sized avatar
🐔
NaN hopefully.

Jeremy Bensimon jeremyben

🐔
NaN hopefully.
  • France
View GitHub Profile
// https://www.typescriptlang.org/docs/handbook/advanced-types.html
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
/**
* Enlève les clés K de T (plus précis que le Omit natif).
*/
type OmitStrict<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
/**
* Récupère la version promisifiée d'une fonction.
/**
* Use with await to have synchrone delay
*/
const delay = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms))
/**
* Retry a promise a number of times if it failed
*/
async function retry<T>(promise: Promise<T>, maxRetries: number, delayBetweenRetriesMs: number = 0) {
let res: T
@jeremyben
jeremyben / generators.scss
Last active October 8, 2019 08:36
Size Generators (margin, padding, font-size) #scss #stylus
// Generate class helpers for size properties such as margin, padding, font-size
// Usage :
// @include marginer(5, 60, 5)
// .mt5 will then add margin-top:5px to the element,
// and so on for each side, from 5px to 60px with a 5px step.
@mixin marginer($min, $max, $step) {
.mt#{$min} {margin-top: $min*1px}
.mb#{$min} {margin-bottom: $min*1px}
.ml#{$min} {margin-left: $min*1px}