0x05baa67af0201cf90f07237b4fcd77ff375a391f705d31a007802a92c480a950
This file contains 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
# This is just a note to self | |
git rebase --onto <base-branch> <current-branch>~ <current-branch> | |
# e.g. git rebase --onto master feature/something~ feature/something | |
# it's important here to use branch name and not other commit id. | |
# Can't use "HEAD" instead of "feature/something" ¯\_(ツ)_/¯ |
This file contains 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
# This is just a note to self | |
git rebase --onto <base-branch> <current-branch>~ <current-branch> | |
# e.g. git rebase --onto master feature/something~ feature/something | |
# it's important here to use branch name and not other commit id. | |
# Can't use "HEAD" instead of "feature/something" ¯\_(ツ)_/¯ |
This file contains 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
/** | |
* Considering that each html input | |
* has a "name" attribute and proper | |
* validation attributes (type, pattern, required, etc) | |
* we collect "validity" states of invalid inputs | |
* and the "validationMessage" provided by the browsers | |
*/ | |
const errors = Array.from(form.elements) | |
.filter((el) => el.hasAttribute('name')) | |
.reduce((acc, el) => { |
This file contains 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
export function sequentialPolling({ | |
taskFn, | |
interval = 1000, | |
}: { | |
taskFn: () => Promise<any>; | |
interval?: number; | |
}) { | |
let isActive = true; | |
let timeoutId: number | undefined; | |
let rejector: Function | undefined; |
Source: https://stackoverflow.com/a/6127884/3523645
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
Problem: If pull-request are merged into the main branch using a "squash" strategy and then the remote branches are removed,
This file contains 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
function normalizedIncludes(str1: string, str2: string) { | |
/** | |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize | |
* | |
* https://stackoverflow.com/a/37511463/3523645 | |
*/ | |
const diacriticsRange = /[\u0300-\u036f]/g; | |
const str1Normalized = str1.normalize('NFD').replace(diacriticsRange, ''); | |
const str2Normalized = str2.normalize('NFD').replace(diacriticsRange, ''); | |
return str1Normalized.includes(str2Normalized); |
This file contains 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
class Toaster { | |
constructor() { | |
this.listeners = []; | |
this.id = 0; | |
} | |
subscribe(listener) { | |
this.listeners.push(listener); | |
return () => { | |
this.listeners = this.listeners.filter(l => l !== listener); |
This file contains 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
<!-- | |
A tabindex="-1" allows an element to receive programmatic focus. | |
This is useful a modal dialog window: when opened, focus should be set to the dialog so a screen reader | |
will begin reading and the keyboard will be able to navigate within the dialog. | |
Because the dialog (probably a <div> element) is not focusable by default, assigning it tabindex="-1" | |
allows scripting to set focus to it when it is presented | |
Resources: | |
https://www.w3.org/WAI/GL/wiki/Using_ARIA_role%3Ddialog_to_implement_a_modal_dialog_box#Note_on_focus_management | |
https://webaim.org/techniques/keyboard/tabindex |
This file contains 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
function isBrowserIE() { | |
const ie11Re = /Trident.*rv:11/; | |
const edgeRe = /Edge\//; | |
const ua = navigator.userAgent; | |
return ie11Re.test(ua) || edgeRe.test(ua); | |
} |