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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" | |
integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" | |
crossorigin="anonymous" referrerpolicy="no-referrer" /> |
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
sudo apt install curl | |
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash | |
source ~/.bashrc | |
nvm install 16.19.0 |
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
1. Install dependencies: | |
npm install express socket.io redis | |
2. Nodejs Code: | |
const express = require('express'); | |
const http = require('http'); | |
const socketIo = require('socket.io'); | |
const redis = require('redis'); |
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 |
NewerOlder