Skip to content

Instantly share code, notes, and snippets.

View alex-alekseichuk's full-sized avatar
🏠
Working from home

Alex Alekseichuk alex-alekseichuk

🏠
Working from home
View GitHub Profile
@alex-alekseichuk
alex-alekseichuk / telegram.js
Created April 18, 2024 13:28
Send message and post (photo with title/link and text) to telegram channel from telegram bot.
// Send message and post (photo with title/link and text)
// to telegram channel
// from TG bot
//
// It requires 2 ENV variables:
// TELEGRAM_BOT_TOKEN
// TELEGRAM_CHANNEL_ID
//
// You can get TELEGRAM_CHANNEL_ID:
// curl -s "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getChat?chat_id=@<CHANNEL_USERNAME>" | jq .result.id
@alex-alekseichuk
alex-alekseichuk / button-example.html
Created April 17, 2024 07:08
Center the text vertically inside Bootstrap's link as a button
<a class="btn btn-primary d-flex align-items-center" role="button" href="#">Label</a>
@alex-alekseichuk
alex-alekseichuk / ComplexComponent.tsx
Created April 8, 2024 13:56
Example of React class and function component
import React, { Component } from 'react';
class ComplexComponent extends Component {
constructor(props) {
super(props);
this.state = {
count: 0,
name: 'React Component',
isLoading: true,
};
@alex-alekseichuk
alex-alekseichuk / decode-message.rb
Created February 1, 2024 13:37
Luxoft Test task
#
# If you are reading this message you definitely know what binary code is about.
# Take a chance and win a certificate for free training-course at Luxoft Training to upgrade your skills in the IT subject you are interested in
#
bin_code = "0100100101100110001000000111100101101111011101010010000001100001011100100110010100100000011100100110010101100001011001000110100101101110011001110010000001110100011010000110100101110011001000000110110101100101011100110111001101100001011001110110010100100000011110010110111101110101001000000110010001100101011001100110100101101110011010010111010001100101011011000111100100100000011010110110111001101111011101110010000001110111011010000110000101110100001000000110001001101001011011100110000101110010011110010010000001100011011011110110010001100101001000000110100101110011001000000110000101100010011011110111010101110100001011100000110100001010010101000110000101101011011001010010000001100001001000000110001101101000011000010110111001100011011001010010000001100001011011100110010000100
@alex-alekseichuk
alex-alekseichuk / img-object-fit-contain.html
Created January 25, 2024 06:49
Resize (fit) picture in terms for outer div container.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.container {
width: 300px;
height: 200px;
border: 1px solid #ccc;
@alex-alekseichuk
alex-alekseichuk / add-fill-not-null-column.sql
Created January 24, 2024 18:58
Postgresql script to add not-null column to existing table.
ALTER TABLE "topic_properties" ADD COLUMN "orderId" INTEGER NULL;
DO $$
DECLARE
topic topics%ROWTYPE;
topic_property topic_properties%ROWTYPE;
query TEXT;
counter INT;
BEGIN
FOR topic IN SELECT * FROM topics
@alex-alekseichuk
alex-alekseichuk / search-box.tsx
Created January 8, 2024 17:37
Correct label behaviour in MUI TextFiled with start adornment.
const [shrink, setShrink] = useState(false);
return (
<TextField
sx={{
'& .MuiInputLabel-root:not(.MuiInputLabel-shrink)': {
transform: "translate(41px, 17px)"
}
}}
onFocus={() => setShrink(true)}
@alex-alekseichuk
alex-alekseichuk / title.css
Created January 2, 2024 15:59
One line and 2 lines titles
.one-line {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.two-lines {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
@alex-alekseichuk
alex-alekseichuk / slow-cat.js
Created August 2, 2023 16:43
Slow analog of cat tool for pure visual effect in console.
'use strict';
import stream from 'node:stream';
import timers from 'node:timers/promises';
const createSlowStream = delay => {
const options = {
async transform(chunk, encoding, next) {
for (const char of chunk.toString()) {
this.push(char);
@alex-alekseichuk
alex-alekseichuk / test_smtp.sh
Created June 6, 2023 10:04
Send test email directly to SMTP server.
#!/bin/bash
# SMTP server details
smtp_server="localhost"
smtp_port="1025"
# Sender and recipient details
from_address="alex@localhost"
to_address="alex@localhost"