Skip to content

Instantly share code, notes, and snippets.

View Maxim-Kolmogorov's full-sized avatar
☺️
I love my job

Maxim Kolmogorov Maxim-Kolmogorov

☺️
I love my job
View GitHub Profile
@Maxim-Kolmogorov
Maxim-Kolmogorov / mask.kt
Last active October 18, 2024 08:36
Phone mask for Android Jetpack Compose
package my.app.android
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.input.OffsetMapping
import androidx.compose.ui.text.input.TransformedText
import androidx.compose.ui.text.input.VisualTransformation
import kotlin.math.absoluteValue
class MaskVisualTransformation(private val mask: String): VisualTransformation {
private val specialSymbolsIndices = mask.indices.filter { mask[it] != '#' }
@Maxim-Kolmogorov
Maxim-Kolmogorov / docker-compose.yml
Created January 30, 2024 08:15
SSL, Nuxt 3, Nginx, Docker
version: "3.3"
# Указываем раздел со связанными сервисами
services:
nginx:
depends_on:
- nuxt
image: nginx:latest
labels:
proxy_nginx: "Для SSL"
@Maxim-Kolmogorov
Maxim-Kolmogorov / sendEmail.ts
Created January 24, 2024 07:54
Send Email with Nodemailer.
import nodemailer from 'nodemailer'
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'pass'
}
})
@Maxim-Kolmogorov
Maxim-Kolmogorov / joke.get.ts
Created December 15, 2023 09:19
Telegram Bot (part 2)
import axios from 'axios'
import token from '~/bot/token'
import { parse } from 'node-html-parser'
export default eventHandler(async () => {
const reqResult = await axios
.get('https://baneks.ru/random')
.then((res) => {
if (!res.data) { return null }
@Maxim-Kolmogorov
Maxim-Kolmogorov / bot.get.ts
Last active December 15, 2023 10:24
Telegram Bot (part 1)
import axios from 'axios'
export default eventHandler(async () => {
const reqResult = await axios
.get(`https://api.telegram.org/bot@token@/getUpdates`)
.then((res) => {
if (!res.data) { return [] }
return res.data.result
})
@Maxim-Kolmogorov
Maxim-Kolmogorov / Dockerfile
Created December 10, 2023 18:24
Nuxt 3 Docker example
FROM node:18.16.0
ENV APP_ROOT /web
WORKDIR ${APP_ROOT}
ADD . ${APP_ROOT}
RUN npm ci
RUN npm run build
@Maxim-Kolmogorov
Maxim-Kolmogorov / mask.swift
Last active August 27, 2023 17:57
Phone input mask on swift.
extension String {
func formatUserInput(pattern: String) -> String {
var inputCollection = Array(self)
var resultCollection: Array<Character> = []
for i in 0 ..< pattern.count {
let patternCharIndex = String.Index(utf16Offset: i, in: pattern)
let patternChar = pattern[patternCharIndex]
guard let nextInputChar = inputCollection.first else { break }
@Maxim-Kolmogorov
Maxim-Kolmogorov / index.html
Created January 9, 2023 13:10
CSS dark mode support.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
header {
display: flex;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript" src="qrcode.min.js"></script>
</head>
<body>
@Maxim-Kolmogorov
Maxim-Kolmogorov / index.js
Created November 29, 2022 13:29
Parser example (for article).
const axios = require('axios')
const cheerio = require('cheerio')
async function start() {
const url = 'https://example.com/'
const result = await axios.get(url)
const $ = cheerio.load(result.data)
const title = $.html($('h1'))
console.log(title)