Skip to content

Instantly share code, notes, and snippets.

View m4hi2's full-sized avatar
❄️
Chill

Mahir Labib Chowdhury m4hi2

❄️
Chill
View GitHub Profile
@m4hi2
m4hi2 / get_next_tag.bash
Created February 26, 2025 19:36
get_next_tag
# Gets the next tag of the given branch
get_next_tag()
{
latestTag=$(git describe --tags $(git rev-list --tags="$1-*" --max-count=1))
tagC=$(git rev-parse $latestTag)
head=$(git rev-parse HEAD)
if [ "$tagC" == "$head" ]; then
return 1
@m4hi2
m4hi2 / bit counter
Created October 4, 2022 04:30
bit counter example from EPI book
def count_bits(x):
num_bits = 0
while x:
num_bits += x & 1
x = x >> 1
return num_bits
for i in range(10):
def get_sum_of_individual_digits(n: int, total: int = 0) -> int:
if n == 0:
# print(total)
return total
digit = n % 10
total = total + digit
return get_sum_of_individual_digits(n // 10, total)
def get_sum_of_individual_digits(n: int, total: int = 0) -> int:
if n == 0:
# print(total)
return total
else:
digit = n % 10
total = total + digit
return get_sum_of_individual_digits(n // 10, total)
import datetime
import scrapy
import re
from pathlib import Path
from urllib.parse import unquote
RE_URL = r"<loc>(https://\D+)</loc>"
RE_PATH = r"/([^a-z | /]+)" # The last part of the URL
def sum(array):
sum = 0
for i in array:
sum += i
return sum
class Matrix():
def __init__(self):
self.row = 0
self.array = [[0]*6 for i in range(6)]
int mid = 0;
int mn = 0;
int mx = 0;
int totalAnalogPinInUse = 9; //Please specify the total number of pins you used for the IR array
void setup() {
//put other setups
//calibrating the sensors
for(int i = 0; i<5000; i++){
@m4hi2
m4hi2 / driving_duration.py
Last active October 5, 2017 22:44
Reads space separated origin & destination from the STDIN and returns driving duration.
import requests
api_key = "ADD YOUR OWN API KEY"
def get_duration(source, destination, key):
query_url = "https://maps.googleapis.com/maps/api/distancematrix/json"
try:
data = requests.get(query_url, params={
"destinations": destination,
#include <stdio.h>
int main() {
float A,B,med;
scanf("%f %f",&A,&B);
med=((A*3.5)+(B*7.5))/(3.5+7.5);
#include <stdio.h>
int main() {
float a,b,c,med;
scanf("%f%f%f", &a, &b, &c);
med = ((a*2) + (b*3)+(c*5)) / (2+3+5);
printf("MEDIA = %.1f\n", med);