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
sudo -i | |
service mysql stop | |
killall -KILL mysql mysqld_safe mysqld | |
apt-get --yes purge mysql* | |
apt-get --yes autoremove --purge | |
apt-get autoclean | |
deluser --remove-home mysql | |
delgroup mysql | |
rm -rf /etc/apparmor.d/abstractions/mysql /etc/apparmor.d/cache/usr.sbin.mysqld /etc/mysql /var/lib/mysql /var/log/mysql* /var/log/upstart/mysql.log* /var/run/mysqld ~/.mysql_history | |
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-* |
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
#!/bin/bash | |
# Check if the user provided a port number | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <PORT>" | |
exit 1 | |
fi | |
# Extract the port number from the first argument | |
PORT=$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
<!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", |
NewerOlder