Skip to content

Instantly share code, notes, and snippets.

View sar-joshi's full-sized avatar

Sar J sar-joshi

View GitHub Profile
// Create an object to store all index information
var clusterIndexes = {};
db.getMongo().getDBs().databases.forEach(function(database) {
if (database.name !== 'admin' && database.name !== 'local' && database.name !== 'config') {
clusterIndexes[database.name] = {};
var dbs = db.getSiblingDB(database.name);
dbs.getCollectionNames().forEach(function(collName) {
clusterIndexes[database.name][collName] = db.getCollection(collName).getIndexes();
print("Database,Collection,Index Name,Is Unique,Is Sparse,TTL (seconds),Fields");
db.getMongo().getDBs().databases.forEach(function(database) {
// print("\nDatabase:", database.name);
if (database.name !== 'admin' && database.name !== 'local' && database.name !== 'config') {
var dbs = db.getSiblingDB(database.name);
dbs.getCollectionNames().forEach(function(collName) {
// print("\collName:", collName);

Check index usage statistics

-- Check index usage statistics --
SELECT 
    schemaname, 
    relname AS table_name, 
    indexrelname AS index_name, 
    idx_scan AS number_of_scans,
    idx_tup_read AS tuples_read,
    idx_tup_fetch AS tuples_fetched
@sar-joshi
sar-joshi / linux-commands.md
Last active September 4, 2024 01:15
Useful Linux Commands

Cron

  • Status: sudo systemctl status cron
  • Restart: sudo /etc/init.d/cron restart
  • Stop: sudo /etc/init.d/cron stop
  • Edit CronJobs: sudo vi /etc/crontab

System Status

  • Top 10 process: ps aux --sort=-%cpu | head -n 10
  • One-time snapshot of CPU usage: ps aux | sort -nrk 3,3 | head -n 5
  • Live status of a process: top -p
@sar-joshi
sar-joshi / typescript-node-clean-arch.md
Created July 9, 2021 05:20
Typescript & Node.js Clean Architecture

Typescript & Node.js Clean Architecture

Project Structure

.
└── src
    ├── app                         → Application services layer
    │   └── usecase                 → Application business rules
 ├── domain → Enterprise core business layer such as domain model objects (Aggregates, Entities, Value Objects) and repository interfaces
@sar-joshi
sar-joshi / tabliss.json
Created April 10, 2021 23:31
Chrome's Tabliss Settings
{"backgrounds":[{"active":true,"display":{"blur":0,"luminosity":-0.6},"id":"8b0af48b-41e8-454a-95bd-49e4d0d564be","key":"background/unsplash"}],"widgets":[{"active":true,"display":{"fontSize":40,"position":"middleCentre"},"id":"8ea891f7-5c83-4ea5-b072-b18eb6e3af7f","key":"widget/search"},{"active":true,"display":{"fontSize":14,"position":"topCentre"},"id":"3c61f87c-6166-4f74-9167-7302989b4f5f","key":"widget/time"},{"active":true,"display":{"position":"topCentre"},"id":"3390cd5f-5683-4a50-8433-38de44414bdb","key":"widget/weather"},{"active":true,"display":{"fontSize":10,"position":"bottomCentre"},"id":"222c9632-971d-40d3-a34b-e48c1ed85764","key":"widget/quote"},{"active":true,"display":{"fontSize":12,"position":"middleCentre"},"id":"9a590210-089d-4520-b3ea-5f6d54663e48","key":"widget/links"}],"data":{"222c9632-971d-40d3-a34b-e48c1ed85764":{"category":"developerexcuses"},"3390cd5f-5683-4a50-8433-38de44414bdb":{"latitude":-33.8548157,"longitude":151.2164539,"showDetails":false,"units":"auto"},"3c61f87c-6166-4f74
@sar-joshi
sar-joshi / way_to_manage_python_version.md
Created January 27, 2021 22:49
Ways to manage python version and use venv on them.

First way: My personal peference:

pyenv to manage my python version.

pyenv install 3.7.3
pyenv local 3.7.3

Check your python version:

@sar-joshi
sar-joshi / Activate Office 2019 for macOS VoL.md
Created January 18, 2021 20:40 — forked from zthxxx/Activate Office 2019 for macOS VoL.md
crack activate office on mac with license file

Activate MS Office 2019/2016 for macOS - Microsoft_Office_2019_VL_Serializer

Office 2019 above

2019-06-03

Note that Office2019 DO NOT support activate via simple copy/paste plist license file which is the simplest way to activate Office 2016. Fortunately, you can also use the VL Serializer tool, just install Office 2019 and Serializer, then run Serializer to activate.

Ref

@sar-joshi
sar-joshi / get_keywords_freq_chart.py
Last active September 29, 2020 08:57
Count Keywords Frequency and Generate Chart with 'pdftotext' and 'matplotlib'
"""
You need to install poppler for pdftotext (for macOS)
> brew install pkg-config poppler
@JOSHI, Sarthak
PyPi: https://pypi.org/project/pdftotext/
"""
import os
@sar-joshi
sar-joshi / count_keywords_frequency.py
Last active September 29, 2020 08:08
Count Keywords and Display Frequency Bar Chart
"""
You need to install poppler for pdftotext (for macOS)
> brew install pkg-config poppler
@JOSHI, Sarthak
PyPi: https://pypi.org/project/pdftotext/
"""
import os