Skip to content

Instantly share code, notes, and snippets.

View prashanthmadi's full-sized avatar

Prashanth Madi prashanthmadi

View GitHub Profile
const { MongoClient } = require("mongodb");
var ReadPreference = require('mongodb').ReadPreference
// Replace the following with your MongoDB deployment's connection
// string.
const uri =
"mongodb://prmongotest:XSXz98HsbkOGyQN1SNnjilJKf5eDWDMXpJIvus8441jiiROq1WO86P84enVHw2izDtRTVndUev2l6hDX4VW6Tw==@prmongotest.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@prmongotest@";
const client = new MongoClient(uri, { monitorCommands:true });
// Replace <event name> with the name of the event you are subscribing to.
const eventName = "commandStarted";
const { MongoClient } = require("mongodb");
var ReadPreference = require('mongodb').ReadPreference
// Replace the following with your MongoDB deployment's connection
// string.
const uri =
"mongodb://cosmomongo13:==@cosmomongo13.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@cosmomongo13@";
const client = new MongoClient(uri, { monitorCommands:true });
// Replace <event name> with the name of the event you are subscribing to.
const eventName = "commandStarted";
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
FirstName LastName Phone Email DiscountCode
Roberto Tamburello 555.123.4567 RTamburello@contoso.com 10
Janice Galvin 555.123.4568 JGalvin@contoso.com.co 5
Shakti Menon 555.123.4570 SMenon@contoso.net 50
Zheng Mu 555.123.4569 ZMu@contoso.net 40
var MongoClient = require('mongodb').MongoClient
var ReadPreference = require('mongodb').ReadPreference
, assert = require('assert');
var Logger = require('mongodb').Logger;
// Connection URL - Paste your db account connection string from Azure portal
var url = 'mongodb://prmultireadmongo:xxxx==@prmultireadmongo.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@prmultireadmongo@';
// readTargetRegion - this will be used to read From while using Tags
var readFromRegion = "East US";
@prashanthmadi
prashanthmadi / update_offer_cosmos_sqlapi.js
Last active May 12, 2020 19:16
updates offer in Cosmos DB SQL API
var _ = require('lodash');
const { CosmosClient } = require("@azure/cosmos");
const endpoint = "https://cosmosdbtestpr.documents.azure.com:443/";
const key = "xxxx==";
const client = new CosmosClient({ endpoint, key });
const databaseName = "testdb2";
const db = null;
const initialOffer = 1000;
const finalOffer = 600;
@prashanthmadi
prashanthmadi / recursive_listing.py
Created March 11, 2020 16:05
Databricks Recursive listing
import boto3
s3 = boto3.client('s3')
bucket = 'databricks-datasets-virginia'
prefix = 'airlines/'
objects = s3.list_objects_v2(Bucket=bucket, Prefix=prefix, Delimiter = "/")
files = []
for obj in objects['Contents']:
files.append(obj)
while objects['IsTruncated']:
continuation_key = objects['NextContinuationToken']
#!/bin/bash
# This script adds the logrotate policy for .out files to ensure the logs are compressed, rotated and eventually removed from the VM
sudo echo "HealingService action to configure logrotate policy initiated." | logger
path="/etc/logrotate.d"
sudo mkdir -p $path
cat > /tmp/logrotate-policy <<EOF
/var/log/ambari-agent/ambari-agent.out
/var/log/ambari-metrics-collector/*.out
/var/log/ambari-metrics-grafana/grafana.out
/var/log/ambari-metrics-monitor/ambari-metrics-monitor.out
from datetime import timedelta
import pandas
from azure.kusto.data.exceptions import KustoServiceError
from azure.kusto.data.helpers import dataframe_from_result_table
from azure.kusto.data.request import (ClientRequestProperties, KustoClient,
KustoConnectionStringBuilder)
from azure.kusto.ingest import (BlobDescriptor, DataFormat, FileDescriptor,
IngestionMappingType, IngestionProperties,
KustoIngestClient, KustoStreamingIngestClient,
@prashanthmadi
prashanthmadi / azure_func_req.js
Created June 9, 2019 21:13
Azure Function app with request inside async function
const request = require("request-promise");
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
var options = {
uri: 'https://prashanthmadi.github.io/2018/10/10/django-sendgrid.html'
};
var result1 = await request(options);
@prashanthmadi
prashanthmadi / install_anaconda_new_python_hdi.sh
Created May 14, 2019 03:49
install newer version of python in anaconda for HDInsight
/usr/bin/anaconda/bin/conda create --prefix /usr/bin/anaconda/envs/py37 python=3.7