Skip to content

Instantly share code, notes, and snippets.

@moe-salek
moe-salek / send_commits_messages_telegram.py
Last active May 10, 2022 08:32
Send local commits to your telegram chat/group/channel
import requests # pip install requests
import git # pip install GitPython
import datetime
_bot_token = '' # your bot token
_bot_chat_id = '' # your telegram chat id
_absolute_path_to_git_repo = '' # the absolute path to your repository dir containing .git
@moe-salek
moe-salek / install_docker_ubuntu.sh
Last active January 10, 2021 14:06
install docker and docker-compose on ubuntu
#!/bin/sh
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput sgr0)
echo "${red}Uninstalling previous verions...${reset}" &&
sudo apt-get remove docker docker-engine docker.io containerd runc -y;
echo "${red}Updating and installing Docker...${reset}" &&
sudo apt-get update &&
sudo apt-get install \
apt-transport-https \
@moe-salek
moe-salek / is_online.py
Created September 6, 2020 15:48
A small code to check if Samad (Amozesh of University of Tabriz) is online
import requests
import time
WEBSITE = "https://amozesh.tabrizu.ac.ir/"
TIMEOUT_DURATION = 45
while True:
print("Trying to connect..")
try:
@moe-salek
moe-salek / sync_with_stdio.cpp
Created October 20, 2019 06:08
std::cout performance with std::ios_base::sync_with_stdio(false)
#include <iostream>
#include <chrono>
void func(const int limit) {
for (int i = 0; i < limit; ++i) {
std::cout << "Test";
}
}
int main() {
@moe-salek
moe-salek / custom_sort.cpp
Created October 18, 2019 13:05
C++ custom compare function for std::sort()
#include <bits/stdc++.h>
template <typename T>
void print(const std::vector<std::pair<T, T>>& v) {
for (auto i : v) {
std::cout << i.first << ':' << i.second << ' ';
}
std::cout << std::endl;
}
@moe-salek
moe-salek / timing_sstream_cout.cpp
Last active June 11, 2019 00:35
Timing Challenge: cout vs cout+sstream (Functions from CodeSignal Challenge - lookAndSaySequenceNextElement)
#include <iostream>
#include <sstream>
#include <ctime>
#include <random>
void function1(const std::string &element) {
uint32_t count = 0;
std::stringstream ss;
for (uint32_t i = 0; i < element.length(); i += count) {
uint32_t index = i;
@moe-salek
moe-salek / colourize.cpp
Last active June 6, 2019 18:09
Colourize your Terminal / Command Prompt (win10 and above) with C++
#include <iostream>
#include <string>
enum Color {
Black,
Blue,
Green,
Cyan,
Red,