Skip to content

Instantly share code, notes, and snippets.

View samyarkd's full-sized avatar
💪
Monk Mode

Samyar samyarkd

💪
Monk Mode
View GitHub Profile
@samyarkd
samyarkd / gist:a490d50c74e7f353650e54fca479a430
Created May 9, 2024 11:05
Run this code with Bun it will throw an error but with node it will work without any issues
import { UTApi } from "uploadthing/server";
export const utapi = new UTApi();
/**
* Uploads an image from the given URL.
*
* @param {string} url - The URL of the image to be uploaded
* @return {Promise<any>} A Promise that resolves with the result of the upload process
*/
async function uploadImageByUrl(url: string) {
{-
TASK 3 - Find and replace binary substring
Binary string is represented as a cell linked list: string splitted to chunks,
first chunk stored to the root cell, next one to the cell in ref and so on;
each cell can have only one ref.
Write the method that find and replaces one flags in the binary string
with another value. Flags and values can be can be of any length, but
strictly up to 128 bits. The method must replace every flag it finds.
Flag and the value to be replaced is guaranteed to be greater than 0.
Lets give a simple example. We have the target flag 101110101 and the value
@samyarkd
samyarkd / gist:9b4b3cd3ff5e655c6b0141da6b113a09
Created April 5, 2023 18:49
I wan to make a pagination in grammy but idk how, the bellow code is incomplete im looking for a way to store the skip variable to be accessible to all the buttons or do you know any other way of implementing pagination using grammy and prisma
const take = 5
const transactions = new Menu<CustomContext>('transactions', {
onMenuOutdated: (ctx) => ctx.deleteMessage(),
})
// Prev btn
.text(
(ctx) => {
const skip = ctx.msg.text.startsWith('skip-') ? Number(ctx.msg.text.split('-')[1]) : 0
if (skip === 0) {
return '🚫'
import BasicTextEditor from '@/components/manageTemplates/BasicTextEditor'
import { useContractCategories } from '@/hooks/queries/admin'
import { useUpdateTemplate } from '@/hooks/queries/contracts'
import { useGetTemplate } from '@/hooks/queries/contracts/useGetTemplate'
import useBreadCrumbsTitle from '@/hooks/store/useBreadCrumbsTitle'
import LANG from '@/lang'
import AppLayout from '@/layout/Layout'
import { ContractTemplateData } from '@/types/contracts'
import {
categoryFormRule,