Skip to content

Instantly share code, notes, and snippets.

View manjeshpv's full-sized avatar
🇮🇳
in India

Manjesh V manjeshpv

🇮🇳
in India
  • LEADSchool.in
  • Bangalore
View GitHub Profile
const axios = require('axios');
const fs = require('fs');
const process = async () => {
const response = await axios.get('https://goo.gl/maps/29XfoqKK5s7UdaSy8');
const expression = /window.APP_INITIALIZATION_STATE=\[\[\[\d+.\d+,(\d+.\d+),(\d+.\d+)/
const [,lat, long] = response.data.match(expression)[0].split('[[[')[1].split(',')
console.log({ lat, long})
return { lat, long};
@manjeshpv
manjeshpv / minio-function-ocr.js
Created June 1, 2021 02:58
Cloud Function to Extract Text from Image - works in server hosted
/**
* sudo yum install tesseract-ocr
*
npm init
npm i express node-tesseract-ocr
MINIO_FOLDER=/mnt/data node function-ocr.js
MINIO_FOLDER=/mnt/data pm2 start function-ocr.js --name
*
curl http://localhost:9001/functions/ocr?object=bucket/image.jpg
curl http://minio.domain.com/functions/ocr?object=bucket/image.jpg
var cur = db.getCollection('students').getIndexes();
for(var index1 in cur){
var next = cur[index1];
if(next["name"] == '_id_') {
continue;
}
var unique = next["unique"] ? true : false;
print("try{ db.getCollection(\"students\").createIndex("+JSON.stringify(next["key"])+",{unique:"+unique+"},{background:1})}catch(e){print(e)}");
}
@manjeshpv
manjeshpv / debug-runtime-dynamic-example.js
Last active February 23, 2021 05:59
Without Restart Dynamically enable/disable debug in runtime via API [NOT IDEAL if u running pm2 cluster mode]
const debug = require('debug');
const log = debug('namespace1')
const express = require('express');
const app = express();
app.get('/', (req, res) => {
log('Homepage loading')
res.json({ title: 'Homepage' });
})
@manjeshpv
manjeshpv / 3pdb.sql
Created November 29, 2019 09:42 — forked from simonhearne/3pdb.sql
This file has been truncated, but you can view the full file.
INSERT IGNORE INTO thirdpartydb.group (name) VALUES ('Advertising'),
('Other'),
('Dynamic Content'),
('User Interaction'),
('Content Provision'),
('Analytics'),
('Financial Services'),
('Hosted Media'),
('Fraud & Security'),
('Social Media'),
@manjeshpv
manjeshpv / pm2-graceful-reload.sh
Created September 28, 2019 02:04
PM2 Graceful Reload - Halt Release if errors in code
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m' # No Color
printf "I ${RED}love${NC} Github\n "
# Assumption: PM2 running in cluster mode with atleast 2 instances, Instance ID's: 1, 2 name: api
echo -e "\n\n1. #################### Reseting Restart counters in PM2"
pm2 reset api
PID=1
@manjeshpv
manjeshpv / frontend
Created May 8, 2019 08:57
nginx config for angular-fullstack
# cache directive for all static apps
index index.html;
# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|eot|otf|woff|woff2|ttf|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
const { MongoMemoryServer } = require('mongodb-memory-server');
console.log(MongoMemoryServer)
const mongod = new MongoMemoryServer();
const x = async() => {
const uri = await mongod.getConnectionString();
const port = await mongod.getPort();
const dbPath = await mongod.getDbPath();
const dbName = await mongod.getDbName();
// some code
// ... where you may use `uri` for as a connection string for mongodb or mongoose
@manjeshpv
manjeshpv / scrap.md
Created March 27, 2019 07:24
Google Play Reviews Scrape
@manjeshpv
manjeshpv / gst.js
Created March 12, 2019 06:38
GST Calculation
const total_amount = 379;
const base_amount = total_amount / 1.12;
console.log('base_amount', base_amount);
const percentage = 6;
const factor = percentage/100;
console.log('factor', factor);
const sgst = Math.ceil(base_amount*factor*100)/100;
const cgst = sgst;