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 { Bot, Context } from "grammy"; | |
export const bot = new Bot<Context>(process.env.TELEGRAM_BOT_TOKEN ?? ""); |
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
const toBase64 = (file) => new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.readAsDataURL(file); | |
reader.onload = (e) => resolve(e.target.result); | |
reader.onerror = (err) => reject(err); | |
}); | |
const compressBase64 = (src, quality = 0.5) => new Promise((resolve) => { | |
const img = new Image(); | |
img.src = src; |
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
// I'm using deno | |
import "https://deno.land/std@0.178.0/dotenv/load.ts"; | |
import { green } from "https://deno.land/std@0.178.0/fmt/colors.ts"; | |
import { itemsMenu } from './menus/example.menu.ts'; | |
const grammy = new Bot<GrammyContext>(Deno.env.get("BOT_TOKEN")||""); // replace `BOT_TOKEN` inside `.env` file with your own telegram bot's token | |
// attaching the menu to bot to get it to work if not we'll get the following errors inside the terminal | |
// `Error: Cannot send menu 'bot-items-menu'! Did you forget to use bot.use() for it?` |
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
#!/bin/sh | |
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON | |
# string. We can hack out the forwarded hostname by extracting the next | |
# `*.ngrok.io` string from the JSON | |
# | |
# Brittle as all get out--YMMV. If you're still reading, usage is: | |
# | |
# $ ./ngrok_hostname.sh <proto> <addr> | |
# |
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
>>> TURBOREPO | |
Welcome, let's convert your project. | |
? Where is the root of your repo? . | |
? Convert from yarn workspaces to: pnpm workspaces | |
Converting project from yarn to pnpm. |
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
FROM gitpod/workspace-full | |
RUN curl -fsSL https://deno.land/x/install/install.sh | sh | |
RUN /home/gitpod/.deno/bin/deno completions bash > /home/gitpod/.bashrc.d/90-deno && \ | |
echo 'export DENO_INSTALL="/home/gitpod/.deno"' >> /home/gitpod/.bashrc.d/90-deno && \ | |
echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /home/gitpod/.bashrc.d/90-deno |
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
Certainly! Here's a TypeScript function that takes a text string as input and returns an array of code snippets found within code blocks wrapped in triple backticks(```) or `<code>`: | |
```typescript | |
function extractCodeSnippets(text: string): string[] { | |
const codeSnippets: string[] = []; | |
const regex = /```([\s\S]*?)```|<code>([\s\S]*?)<\/code>/g; | |
let match; | |
while ((match = regex.exec(text)) !== null) { | |
const codeSnippet = match[1] || match[2]; |
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
Certainly! Here's a TypeScript function that takes a text as input and returns an array of code snippets found within multiple lines code blocks wrapped in triple backticks (```) or `<code>` tags with language tags: | |
```typescript | |
function extractCodeSnippets(text: string): { language: string, code: string }[] { | |
const codeBlockRegex = /```(\w+)\n([\s\S]*?)```|<code(?:\s+class="language-(\w+)")?>([\s\S]*?)<\/code>/g; | |
const codeSnippets: { language: string, code: string }[] = []; | |
let match; | |
while ((match = codeBlockRegex.exec(text)) !== null) { | |
const [, language1, code1, language2, code2] = match; |
NewerOlder