Skip to content

Instantly share code, notes, and snippets.

View abidkhan484's full-sized avatar
🎯
Focusing

AbId KhAn abidkhan484

🎯
Focusing
View GitHub Profile
@abidkhan484
abidkhan484 / prime_check_multi_process.py
Last active December 18, 2023 10:09
Prime check using multithreaded
#! /usr/bin/python3
import concurrent.futures
from math import floor, sqrt
import time
def is_prime(number: int) -> bool:
if not (number & 1): return 0
iteration = floor(sqrt(number)) + 1
@abidkhan484
abidkhan484 / prime_check_single_threaded.py
Last active December 18, 2023 10:06
Prime check using single threaded
#! /usr/bin/python3
from math import floor, sqrt
import time
def is_prime(number: int) -> bool:
if not (number & 1): return 0
iteration = floor(sqrt(number)) + 1
for i in range(3, iteration, 2):
@abidkhan484
abidkhan484 / NodeMCU_MQTT_SmartHome
Created January 7, 2023 02:30
IoT Based Home Automation System
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
// Relays
#define RelayPin1 D5 // D5
#define RelayPin2 D2 // D2
#define RelayPin3 D0 // D0
#define RelayPin4 D6 // D6
@abidkhan484
abidkhan484 / day3_different_approach.py
Last active March 27, 2020 09:17
Advent Of Code: 2019; Problem Statement: https://adventofcode.com/2019/day/3
#! /usr/bin/python
# Too Much Time Consuming For Big Size Input
# Because of for 31st line condition
# As List takes O(n) time with "in" operator
# Dictionary can be used instead of "direction_list" List
# As Dictionary takes O(1) time to check
#!/usr/bin/python3
input_string = "abcabcbb"
starting_idx = 0; max_length = 0; length = 0
i,j=0,0
for i in range(len(input_string)):
for j in range(i-1, starting_idx-1, -1):
if (input_string[j] == input_string[i]):
starting_idx = j + 1
length = i - j
@abidkhan484
abidkhan484 / repair_wrong_extension_image.php
Created December 26, 2019 09:48
Repair wrong extension image in PHP
<?php
/**
* php-imagick is required : sudo apt-get install php-imagick
*
*/
$file = "Pic/003960.jpg"; // tif file named in jpg extension
// $file = "Pic/003958.jpg"; // orgnial jpg format
@abidkhan484
abidkhan484 / python_script_for_ssh_login.py
Created December 26, 2019 06:17
Python script for SSH login
#!/usr/bin/python
from pexpect import pxssh
s = pxssh.pxssh()
hostname = ''
username = ''
password = ''
if not s.login (hostname, username, password):
d = {
(1, 1): (0, -1),
(1, -1): (0, 1),
(-1, 1): (-1, 0),
(-1, -1): (1, 0)
}
def getFirstPosition(n):
pass
from math import floor
from math import sqrt
def getPrimeNum(num):
mylist = [1] * num
mylist[0], mylist[1], mylist[2] = 0, 0, 1
for i in range(4, num, 2):
mylist[i] = 0
s = ['Happy', 'birthday', 'to', 'you', 'Happy', 'birthday', 'to', 'you', 'Happy', 'birthday', 'to', 'Rujia', 'Happy', 'birthday', 'to', 'you']
member = int(input().strip())
arr = [input().strip().capitalize() for i in range(member)]
j,p = 0,0
if member < 16:
iterate = 16
else:
iterate = member