Skip to content

Instantly share code, notes, and snippets.

View arsalanses's full-sized avatar
🧠
lets play chess

Arsalan Sefidgar arsalanses

🧠
lets play chess
View GitHub Profile
@arsalanses
arsalanses / addressPhone.cpp
Created September 1, 2018 07:13
simple address Phone in C++
#include <iostream>
#include <string>
using namespace std;
int counter = 0;
void insert(string names[], string phoneNumbers[], string name, string number) {
names[counter] = name;
phoneNumbers[counter] = number;
counter += 1;
; Sum of the members of a array
; Author: Arsalan sefidgar
STACK_SEG segment para stack 'stack'
db 64 dup('stack ')
STACK_SEG ends
DATA_SEG segment para 'data'
array db 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
sum db 0
#include <iostream>
#include <conio.h>
using namespace std;
// Mohit
int circumference(int length, int width) {
return (length + width) * 2;
}
// Masahat
@arsalanses
arsalanses / mesh.py
Created January 4, 2021 09:11
You’re trying to build an IoT mesh network.
# You’re trying to build an IoT mesh network.
# Signals can only travel the maximum of 5 units.
# You’re given coordinates for the switch, the light, and the mesh hubs (which capture and forward signals).
# Return true if the switch can successfully toggle the light.
# Example:
# let network = { switch: [0,1], hub: [[2,1], [2,5]], light: [1,6] }
# $ canToggle(network)
# $ true
@arsalanses
arsalanses / question-19.m
Last active December 30, 2021 08:36
Matlab: Return number with max sum of elements
close all;
clear;
clc;
size = input('Enter size: ');
numbers = zeros(2, size);
result = [0, 0];
for i = 1:size
@arsalanses
arsalanses / ngrok-telegram.sh
Created April 9, 2022 21:22
A bash script to start HTop in background, and send Ngrok URL to a Telegram Bot automatically
#!/usr/bin/bash
# install tmux ttyd curl torsocks jq ngrok htop
tmux new -d -s ttyd './ttyd.x86_64 -p 8080 -m 1 -R htop'
tmux split-window -h
tmux send-keys "./ngrok-stable-linux-amd64/ngrok http 8080 -region=ap" C-m
sleep 3
TELEGRAM_TOKEN="" # fill here
TELEGRAM_ID="" # fill here
@arsalanses
arsalanses / ssh.sh
Created September 28, 2022 20:01
ssh internal & external server
ssh -qCL 8080:localhost:8080 root@iran-bridge-ip-address -t ssh -qCND localhost:8080 root@free-world-ip-address
@arsalanses
arsalanses / uni_bot.py
Last active October 29, 2022 08:47
Telegram bot that reads list of jalali dates from csv formatted file and send msg on those dates
import jdatetime
import requests
import schedule
import time
import csv
GROUP_ID = ''
BOT_TOKEN = ''
BASE_URL = f'https://api.telegram.org/bot{BOT_TOKEN}/sendMessage?chat_id={GROUP_ID}&text='
@arsalanses
arsalanses / docker-bot.py
Last active October 30, 2022 12:10
Telegram Bot for checking docker status and alert if a container is not up
import requests
import subprocess
GROUP_ID = ''
BOT_TOKEN = ''
BASE_URL = f'https://api.telegram.org/bot{BOT_TOKEN}/sendMessage?chat_id={GROUP_ID}&text='
docker_ps = "echo -n <password> | sudo docker ps --format '{{.Status}}' | awk '{print $1}'"
docker_stats = "sudo docker stats --all --no-stream --format 'table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}'"
import json
import csv
import os
EXCLUDE_FILES = ["json.zip", "main.py", "results.csv"]
PATH = "/"
KEY_WORD = "go2tr"
counter = 0
with open("results.csv", 'w') as result_file: