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
// https://stackoverflow.com/questions/51403615/spread-syntax-ecmascript | |
const callAll = (...fns) => (...args) => fns.forEach(fn => fn?.(...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
import React from 'react'; | |
export const useModal = () => { | |
const [data, setData] = React.useState({}); | |
const [activeModal, setActiveModal] = React.useState(''); | |
const handleModalOpen = React.useCallback( | |
({ type, index, dataSource }) => (e) => { | |
setData(dataSource); | |
setActiveModal(type); | |
}, |
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
function index(obj,is, value) { | |
if (typeof is == 'string') | |
return index(obj,is.split('.'), value); | |
else if (is.length==1 && value!==undefined) | |
return obj[is[0]] = value; | |
else if (is.length==0) | |
return obj; | |
else | |
return index(obj[is[0]],is.slice(1), value); | |
} |
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
/** | |
* Helper to produce an array of enum values. | |
* @param enumeration Enumeration object. | |
*/ | |
export function enumToArray<T, G extends keyof T = keyof T>(enumeration: T): T[G][] { | |
const enumVals = Object.values(enumeration); | |
return enumVals.slice(enumVals.length / 2, enumVals.length) as T[G][]; | |
} |
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
/** | |
* | |
* @param map Map data | |
* @param searchValue value | |
*/ | |
export function getByValue(map: any[], searchValue: any): any { | |
for (const [key, value] of map.entries()) { | |
if (value === searchValue) return key; | |
} | |
} |
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
function shift_f5_hard_reload() { | |
let evt = new KeyboardEvent("keydown", { | |
shiftKey: true, | |
key: "f5", | |
keyCode: 116 | |
}); | |
document.dispatchEvent(evt); | |
} |
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
function isOverflowingElement(element) { | |
return (element.scrollWidth > element.offsetWidth); | |
} |
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
server { | |
listen *:80; | |
server_name example.com *.example.com; | |
set $subdomain ""; | |
if ($host ~ ^(.*)\.example\.com$) { | |
set $subdomain $1; | |
} | |
location / { |
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
version: "3.3" | |
services: | |
################################################ | |
#### Traefik Proxy Setup ##### | |
############################################### | |
traefik: | |
image: traefik:v2.0 | |
restart: always |
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
version: "3.3" | |
services: | |
traefik: | |
image: traefik | |
restart: always | |
container_name: traefik | |
ports: | |
- 80:80 | |
- 443:443 |