My Elasticsearch cheatsheet with example usage via rest api (still a work-in-progress)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ad": "Andorra", | |
"ae": "United Arab Emirates", | |
"af": "Afghanistan", | |
"ag": "Antigua and Barbuda", | |
"ai": "Anguilla", | |
"al": "Albania", | |
"am": "Armenia", | |
"ao": "Angola", | |
"aq": "Antarctica", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ |
NewerOlder