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
export function declination(num, titles) { | |
const cases = [2, 0, 1, 1, 1, 2]; | |
return titles[(num % 100 > 4 && num % 100 < 20) | |
? 2 | |
: cases[(num % 10 < 5) ? num % 10 : 5] | |
]; | |
} | |
declination(1, ['яблоко', 'яблока', 'яблок']); // яблоко | |
declination(2, ['яблоко', 'яблока', 'яблок']); // яблока |
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
/** | |
* Dependencies | |
* moment | |
* ramda | |
*/ | |
/** | |
* | |
* @param {string} date | |
* @param {Object} options |
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
$('#mse2_results .mse2-row').sort(function(a,b) { | |
function getViews(el) { | |
return Number($(el).find('table tr:last td').text().trim().match(/\d+$/ig)[0]) | |
} | |
return getViews(b) - getViews(a); | |
}).appendTo('#mse2_results'); |
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
// breakpoints from bootstrap 4 | |
$grid-breakpoints: ( | |
xs: 0, | |
sm: 576px, | |
md: 768px, | |
lg: 992px, | |
xl: 1200px | |
) !default; | |
@mixin breakpoint($point) { |
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
tplink archer t4u driver | |
https://askubuntu.com/questions/802205/how-to-install-tp-link-archer-t4u-driver |
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
interface CalendarDay { | |
label: number; | |
timestamp: number; | |
isCurrentMonth: boolean; | |
} | |
type CalendarWeek = CalendarDay[]; | |
type Calendar = CalendarWeek[]; | |
/** | |
* @example |
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 obj = { | |
a: { | |
b: { | |
c: [1, 2, 3] | |
}, | |
d: '', | |
f: true, | |
}, | |
g: { | |
h: 2, |
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
// copy from https://github.com/microsoft/TypeScript/issues/13298#issuecomment-513813788 | |
type Overwrite<T, S extends any> = {[P in keyof T]: S[P]}; | |
type TupleUnshift<T extends any[], X> = T extends any ? ((x: X, ...t: T) => void) extends (...t: infer R) => void ? R : never : never; | |
type TuplePush<T extends any[], X> = T extends any | |
? Overwrite<TupleUnshift<T, any>, T & {[x: string]: X}> | |
: never; |
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
import { | |
createRef, | |
useCallback, | |
useRef, | |
RefObject, | |
} from 'react'; | |
type RefsMap<T> = Partial<Record<string, RefObject<T>>>; | |
type LinkRef<T> = (key: string) => RefObject<T>; |
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
let scrollWidth: null | number = null; | |
export const getScrollWidth = (): number => { | |
if (scrollWidth !== null) { | |
return scrollWidth; | |
} | |
const el = document.createElement('div'); | |
el.style.position = 'fixed'; | |
el.style.zIndex = '-1'; |
OlderNewer