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
/** @see https://discord.com/channels/612400042900193311/612406252164612129/869681421567000608 **/ | |
export async function queryPaginate<T>( | |
model: ModelType<T>, | |
pageNum = 1, | |
filter: MongooseFilterQuery<DocumentType<T>>, | |
populate?: string[], | |
): Promise<IPaginatedData<T[]>> { | |
const [docs, total] = await Promise.all([ | |
model | |
.find(filter) |
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
import { extendTheme } from "@chakra-ui/react"; | |
import { mode } from "@chakra-ui/theme-tools"; | |
// Currently a bug with theme.config typings for initialColorMode. Workaround. | |
interface ThemeConfig { | |
useSystemColorMode?: boolean; | |
initialColorMode: "light" | "dark"; | |
} |
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
import { Node, nodeInputRule } from "@tiptap/core"; | |
import { mergeAttributes } from "@tiptap/react"; | |
import { uploadImagePlugin, UploadFn } from "./upload_image"; | |
/** | |
* Tiptap Extension to upload images | |
* @see https://gist.github.com/slava-vishnyakov/16076dff1a77ddaca93c4bccd4ec4521#gistcomment-3744392 | |
* @since 7th July 2021 | |
* |
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
HOW TO UNBLOCK ANIMEPAHE (JUST IN CASE) AND OTHER BLOCKED SITES | |
## Introduction | |
Whenever you open a website, your device will send DNS request, most internet connection uses ISP's DNS servers by default, so basically your ISP and possibly government could know what sites you access. | |
This is basically how site blocking works. | |
Many ISPs have a blocklist on their DNS servers, if your device sends DNS request of a domain that is in their blocklist, they will block it. | |
Fortunately there are many ways to bypass it, one of them is by changing DNS on our devices, but if you are using a traditional way like by using 8.8.8.8 and 8.8.4.4, ISP could still sniff and intercept the DNS request because it's un-encrypted. |
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
// current code | |
const arrs = [ | |
{ | |
comments: 'asd', | |
movement: 'Back Squat', | |
userID: 'wDHZv3OL55SIymHkhMUejNleNkx1', | |
weight: '330', | |
}, | |
{ |
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
import { Composer, MiddlewareFn } from "telegraf" | |
import { logAction } from "app/core/helpers/logAction" | |
import { BotContext } from "types" | |
import { report } from "../helpers" | |
import { withoutKeys } from "app/core/helpers/misc" | |
import { Message } from "typegram" | |
// @see https://github.com/TGxTG/TOUGAO/blob/master/src/model/Message.js#L86 |
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
// ref https://flaviocopes.com/javascript-regular-expressions | |
const re=/(?<code>(c|g)_\w+)(.)(?<to>to)(.)(?<id>id\d+)/ | |
console.log(re.exec("c_84www to id890890")) // returns ["c_84www to id890890", "c_84www", "c", " ", "to", " ", "id890890", index: 0, input: "c_84www to id890890", groups: {code: "c_84www", to: "to", id: "id890890"}] |
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
import { Context, Telegraf } from 'telegraf' | |
import { PrismaClient } from '@prisma/client' | |
import { session } from 'utils/telegraf-session-prisma' // path to session module | |
const prisma = new PrismaClient() | |
interface SessionData { | |
messageCount: number | |
// ... more session data go here |
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
import { parameterize } from "inflected" | |
import { nanoid } from "nanoid" | |
export function toSlug(slug: string) { | |
slug = parameterize(slug) | |
const nano = nanoid(4) | |
// https://stackoverflow.com/a/16577007/3342703 | |
const id = nano.toLowerCase().replace(/[-_]/g, "") | |
return `${slug.replace("_", "")}-${id}` | |
} |
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 custom pagination helper that | |
* works with prisma 2 | |
* @author @_waptik | |
*/ | |
import db from "db" // xutom prisma wrapper by blitz-js | |
interface Paginate { | |
name: string |