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
| # Supports `YAML` files | |
| syntax "YAML" "\.ya?ml$" | |
| header "^(---|===)" "%YAML" | |
| ## Keys | |
| color magenta "^\s*[\$A-Za-z0-9_-]+\:" | |
| color brightmagenta "^\s*@[\$A-Za-z0-9_-]+\:" | |
| ## Values | |
| color white ":\s.+$" |
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 const isEqual = (a, b) => { | |
| if (typeof a !== "object" && typeof b !== "object") { | |
| return Object.is(a, b); | |
| } | |
| // Хотя null — примитивный тип в JavaScript, из-за некоторых | |
| // исторических особенностей тип null — object, поэтому нам требуется | |
| // дополнительная обработка для null. | |
| if (a === null && b === null) { | |
| return true; | |
| } |
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 const isEmpty = (value) => { | |
| return ( | |
| value === undefined || | |
| value === null || | |
| (typeof value === "object" && Object.keys(value).length === 0) || | |
| (typeof value === "string" && value.trim().length === 0) | |
| // уберите trim, если строка из одних пробелов для вас не пустая | |
| ); | |
| }; |
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
| alias ll='ls -alFh --color=auto --group-directories-first' |
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
| #!/usr/local/bin/bash | |
| SESSION_NAME="aster_env" | |
| # Проверяем и завершаем существующую сессию если есть | |
| if tmux has-session -t "$SESSION_NAME" >/dev/null 2>&1; then | |
| echo "Обнаружена существующая сессия '$SESSION_NAME' - завершаем..." | |
| tmux kill-session -t "$SESSION_NAME" | |
| fi |
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
| 1. cd /usr/local/etc/rc.d | |
| ln -s openvpn openvpn_voip | |
| 2. /etc/rc.conf | |
| openvpn_enable="YES" | |
| openvpn_configfile="/usr/local/etc/openvpn/openvpn.conf" | |
| openvpn_voip_enable="YES" | |
| openvpn_voip_configfile="/usr/local/etc/openvpn/gw.conf" | |
| 3.service openvpn restart |
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 LOCALE_MAP: Record<string, string> = { | |
| RUB: 'ru-RU', | |
| USD: 'en-US', | |
| EUR: 'de-DE', | |
| }; | |
| export function formatCurrency(amount: number, currencyCode: string): string { | |
| const locale = LOCALE_MAP[currencyCode] || 'ru-RU'; | |
| const formattedAmount = new Intl.NumberFormat(locale, { |
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 const convertToISO = (date: string, time: string, zone: string): string => { | |
| const [day, month, year] = date.split('.').map(Number); | |
| const [hour, minute] = time.split(':').map(Number); | |
| const dateTime = DateTime.fromObject({ year, month, day, hour, minute }, { zone }); | |
| const utcDateTime = dateTime.toUTC(); | |
| return utcDateTime.toISO(); | |
| }; |
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
| type ObjectWithNewProp<T, K extends string, V> = T & {[NK in K]: V}; | |
| export class ObjectManipulator<T> { | |
| constructor(protected obj: T) {} | |
| public set<K extends string, V>(key: K, value: V): ObjectManipulator<ObjectWithNewProp<T, K, V>> { | |
| return new ObjectManipulator({...this.obj, [key]: value} as ObjectWithNewProp<T, K, V>); | |
| } | |
| public get<K extends keyof T>(key: K): T[K] { |
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 toFunctional<T extends Function>(func: T): Function { | |
| const fullArgCount = func.length; | |
| function createSubFunction(curriedArgs: unknown[]) { | |
| return function(this: unknown) { | |
| const newCurriedArguments = curriedArgs.concat(Array.from(arguments)); | |
| if (newCurriedArguments.length > fullArgCount) { | |
| throw new Error('Too many arguments'); | |
| } | |
| if (newCurriedArguments.length === fullArgCount) { | |
| return func.apply(this, newCurriedArguments); |
NewerOlder