Skip to content

Instantly share code, notes, and snippets.

@ds1371dani
ds1371dani / crontab
Last active October 9, 2023 05:17
Crontab pattern for jalali beginning of month (expect leap years) - پترن crontab برای اولین روز ماه در تقویم جلالی
0 0 21 1 * sh ~/command.sh
0 0 21 2 * sh ~/command.sh
0 0 22 3 * sh ~/command.sh
0 0 22 4 * sh ~/command.sh
0 0 23 5 * sh ~/command.sh
0 0 23 6 * sh ~/command.sh
0 0 23 7 * sh ~/command.sh
0 0 23 8 * sh ~/command.sh
0 0 22 9 * sh ~/command.sh
0 0 22 10 * sh ~/command.sh
@ds1371dani
ds1371dani / gridify.ts
Last active September 21, 2022 03:14
Gridify query builder for typescript
import { GridifyConditionEnum, GridifyLogicalEnum, GridifyOrderEnum, FilterType, OperatorType, FiltersType } from "./types.ts";
function trimEnds(query: string): string {
let result = query;
// There should not be any starting or ending operator
if (result.startsWith(GridifyLogicalEnum.And)) result = result.slice(GridifyLogicalEnum.And.length);
if (result.startsWith(GridifyLogicalEnum.Or)) result = result.slice(GridifyLogicalEnum.Or.length);
if (result.endsWith(GridifyLogicalEnum.And)) result = result.slice(0, -GridifyLogicalEnum.And.length);
if (result.endsWith(GridifyLogicalEnum.Or)) result = result.slice(0, -GridifyLogicalEnum.Or.length);
return result;