Skip to content

Instantly share code, notes, and snippets.

View MakStashkevich's full-sized avatar
🍀
believe on the best

Maksim Stashkevich MakStashkevich

🍀
believe on the best
View GitHub Profile
@MakStashkevich
MakStashkevich / es5.js
Created January 29, 2023 17:08 — forked from danieliser/es5.js
Convert Hex Color to rgba with opacity
/**
* ECMA2015
*/
function convertHex(hexCode, opacity = 1){
var hex = hexCode.replace('#', '');
if (hex.length === 3) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
@MakStashkevich
MakStashkevich / -first-last-names.md
Created January 29, 2023 10:03 — forked from elifiner/-first-last-names.md
List of first names and last names for random data generation

First and last names

This gist has two files in it: first-names.txt and last-names.txt, each with 4096 names taken from some unnamed database.

Useful for generating mock data for testing or for opfuscating production data for testing.

See https://stackoverflow.com/a/50242368/15109 for some thoughts about data obfuscation.

@MakStashkevich
MakStashkevich / mysql-docker.sh
Created January 19, 2023 17:51 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@MakStashkevich
MakStashkevich / __root_folder.md
Created January 3, 2023 10:39
Dynamic header title & meta tags on NextJs 13
app/
- head.tsx
- layout.tsx
- page.tsx
- blog/[slug]/page.tsx
@MakStashkevich
MakStashkevich / android_version_model.py
Created December 9, 2022 15:00 — forked from srs81/android_version_model.py
From useragent => find Android version, model, device (tablet/phone)
#
# Given a useragent string, return these results:
# Android version, device model name, type (tablet/phone)
#
import re
def android_details (useragent):
result = {}
result["aVersion"] = "Other"
result["amake"] = "Other"
@MakStashkevich
MakStashkevich / gist:edea6936c34d9a5f6e11610332a0e5d8
Created August 31, 2022 12:25 — forked from 1900/gist:3719878
send email in Python via SMTPLIB
import smtplib
import sys
import email.mime.text
mail_username='gmailUser@gmail.com'
mail_password='password'
from_addr = mail_username
to_addrs=('gmailUser@gmail.com')
HOST = 'smtp.gmail.com'
PORT = 25
@MakStashkevich
MakStashkevich / gist:1febdfaf40e11f88ce346491196b29bd
Created August 31, 2022 12:23 — forked from tejastank/gist:3096755
Python smtp email smtplib
import smtplib
to = '22.22@22.com'
gmail_user = '22222@gmail.com'
gmail_pwd = '22222'
smtpserver = smtplib.SMTP("smtp.gmail.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(gmail_user, gmail_pwd)
@MakStashkevich
MakStashkevich / telegram_web_app_bot_validate_hash.php
Created May 12, 2022 16:21
Telegram Web App Bot (Validate hash) on PHP
<?php
$bot_token = '0123456789:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$data_check_string = 'XXX'; // get from Telegram.WebAppData
$data_check_arr = explode('&', rawurldecode($data_check_string));
$needle = 'hash=';
$check_hash = FALSE;
foreach($data_check_arr AS &$val){
@MakStashkevich
MakStashkevich / telegram_web_app_bot_validate_hash.js
Last active November 30, 2024 09:37
Telegram Web App Bot (Validate hash function) on Javascript (JS or NodeJs)
// Bot token
const bot_token = '0123456789:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
// https://core.telegram.org/bots/webapps#validating-data-received-via-the-web-app
function isValidHash() {
// Parse query data
const parsedData = Telegram.Utils.urlParseQueryString(Telegram.WebApp.initData)
// Get Telegram hash
const hash = parsedData.hash
@MakStashkevich
MakStashkevich / ThreadPool.py
Created March 27, 2022 07:56 — forked from JevinJ/ThreadPool.py
An Interruptible/Pausable thread pool in python, KeyboardInterrupt will stop the pool, KeyboardInterrupt can be caught to start the pool where it left off.
import queue
import threading
import os
import time
import signal
class Worker(threading.Thread):
def __init__(self, tasks, results):
super().__init__()
self.tasks = tasks