Skip to content

Instantly share code, notes, and snippets.

View armanokka's full-sized avatar

Arman Toreniyazov armanokka

View GitHub Profile
@armanokka
armanokka / app.py
Created June 4, 2022 20:50
Translo API Python library
#[Main file]
import requests
class PyTranslate:
"Main class"
def __init__(self, token: str):
":token: token from Translo API (https://rapidapi.com/armangokka/api/translo)"
self.token = token
self.url = "https://translo.p.rapidapi.com/api/v3/"
@armanokka
armanokka / main.go
Created October 28, 2022 20:59
strings.Replace with skipping feature. Golang
// https://go.dev/play/p/0CHrCSOkdbD
func replace(s, old, new string, count, skip int) string {
var startIdx int
for i := 0; i < skip; i++ {
idx := strings.Index(s[startIdx:], old)
if idx == -1 {
return s
}
@armanokka
armanokka / main.go
Created November 29, 2022 05:54
Apply entities HTML | Convert telegram entities to HTML | Golang
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"unicode/utf16"
"golang.org/x/text/unicode/norm"
)
func indexDelim(text []uint16, limit int, delims string) (offset int) {
if len(text) < limit {
return len(text)
} else if len(text) > limit {