Skip to content

Instantly share code, notes, and snippets.

View AyemunHossain's full-sized avatar
🔥
Learning WebRTC, ReactJS

Ayemun Hossain AyemunHossain

🔥
Learning WebRTC, ReactJS
View GitHub Profile
@AyemunHossain
AyemunHossain / csvToReadmeQuestionAnswer.py
Created February 19, 2024 11:07
Convert CSV file to Githubreadme question answer pattern
import csv
# Read the CSV file
def read_csv(file_path):
rows = []
with open(file_path, newline='', encoding='utf-8') as csvfile:
reader = csv.reader(csvfile)
header = next(reader) # Skip header
for row in reader:
rows.append(row)
@AyemunHossain
AyemunHossain / shuffleCSV.py
Created February 15, 2024 08:11
Shuffle a csv file rows
import csv
import random
def clean_csv(input_file, output_file):
# Open the input CSV file for reading
with open(input_file, 'r', newline='') as csvfile:
reader = csv.reader(csvfile)
# Read all rows except the header
rows = list(reader)[1:]
@AyemunHossain
AyemunHossain / cheatsheet-elasticsearch.md
Last active October 10, 2023 09:03 — forked from ruanbekker/cheatsheet-elasticsearch.md
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@AyemunHossain
AyemunHossain / file-upload-to-s3.js
Created September 14, 2023 11:30
Get all files form a directory and upload them s3
const directoryPath = __dirname;
const fs = require('fs');
const path = require('path');
const AWS = require('aws-sdk');
AWS.config.update({
endpoint: new AWS.Endpoint("**********************"),
accessKeyId: "**********************",
secretAccessKey: "********************",
});
const s3 = new AWS.S3();
@AyemunHossain
AyemunHossain / allCountryWithShortNameAndFullName.txt
Created September 14, 2023 05:28
All Country with short and full name
{
"ad": "Andorra",
"ae": "United Arab Emirates",
"af": "Afghanistan",
"ag": "Antigua and Barbuda",
"ai": "Anguilla",
"al": "Albania",
"am": "Armenia",
"ao": "Angola",
"aq": "Antarctica",
@AyemunHossain
AyemunHossain / changeFileName.js
Created September 14, 2023 05:25
Change file name in Nodejs
const fs = require('fs');
const path = require('path');
const directoryPath = __dirname;
// Read the contents of the directory
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error('Error reading directory:', err);
return;
}
@AyemunHossain
AyemunHossain / github-cli.sh
Created August 27, 2023 11:02
Github cli install and login
# Install github cli
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
# Login with github cli
@AyemunHossain
AyemunHossain / modifiedBinarySearch.js
Last active July 12, 2023 16:56
Modified Binary Search Implementation
//The main concept of this modified binary search is: Normal bianary searh but we understand that not alwasy the element
//we want will be in the data set, so we keep calm and return the lower closest element of that searching element.
const modifiedBinarySearch = (arr, left, right, element) => {
if (left > right) {
return left - 1;
}
let mid = Math.floor((right + left) / 2);
if (arr[mid] == element) return mid;
@AyemunHossain
AyemunHossain / index.html
Created July 5, 2023 05:36
Interactive Messaging Component
<div class='c-interaction'>
<button aria-label="Toggle more options." class='c-interaction__toggle c-interaction__button'><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus"><path d="M12 5v14M5 12h14"/></svg></button>
<label class='vh' for='message'>Message:</label>
<input class='c-interaction__input' type='text' id='messsage' placeholder='Message'>
<div class='c-interaction__menu'>
<ul>
<li><button aria-label="Record a Video." class='c-interaction__button'><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video"><path d="M23 7l-7 5 7 5V7z"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg></button></li>
<li><button aria-label="Take a Picture." class='c-interaction__button'><svg xmlns="http://www.w3.org/2
@AyemunHossain
AyemunHossain / medianOfTwoSortedArray.js
Created June 12, 2023 10:46
Median of two sorted arrays of same size
function getMedian(arr1, arr2, n)
{
var i = 0;
var j = 0;
var median1 = -1, median2 = -1;
var count;
for(count=0; count<=n; count++){
//This case only true when all of the arr2 elements is less than arr1 all elements
if(j===n){