Monday, December 28, 2020

setup mysql on ubuntu 20

 1.login to mysql using sudo when fresh install

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

For mysql 8.0
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';

Saturday, November 21, 2020

Sunday, November 1, 2020

How to shutdown mongo server from mongoclient

 please use below commands for mongo shutdown from mongo client:

use admin
db.shutdownServer()

Wednesday, October 14, 2020

Sunday, October 11, 2020

How to run long running program in Mac Laptop

 Use caffeinate tool. just enter and dont press Ctr-C

How to create composite key in mongodb

 Please use below as reference to create composite key:

db.coll.createIndex({'k1':1,'k2':1},{unique:true});

{

"createdCollectionAutomatically" : false,

"numIndexesBefore" : 1,

"numIndexesAfter" : 2,

"ok" : 1

}

Saturday, October 10, 2020

Python Regex - Find pattern between two blocks

 Examples:

(?<=<h4>).*(?=</h4>)

<h4>Act of attainder</h4>


match inner most multi groups:

(?<=<div class=\"wordbox)(?:(?!</h5></div></div>).)*

Monday, August 17, 2020

ShabdKhoj (शब्दखोज) - New Brand for Hindi English Dictionary by HinKhoj.com

 I have my roots always connected with HinKhoj.com. Happy to announce that HinKhoj.com has launched a new brand for its English Hindi Dictionary as "SHABD - KHOJ (शब्द खोज) " Please visit ShabdKhoj at https://dict.hinkhoj.com 

Sunday, August 2, 2020

How to properly install Python using brew

Make sure you issue below command so pip is integrated
brew postinstall python3

Friday, July 24, 2020

brew install old versions

cd to Homebrew's formula directory
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
2) Find desired commit (version 63 for icu4c) to checkout
git log --follow icu4c.rb
3) Checkout to a new branch
git checkout -b icu4c-63 e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7
4) Reinstall the library with the new version
brew reinstall ./icu4c.rb
5) Switch to the reinstalled version

Thursday, July 23, 2020

How to install PHP55 on Mac using brew

How to install PHP55 on Mac using brew

brew tap jdpedrie/php55
$ brew install php@5.5

brew tap exolnet/homebrew-deprecated

old version of openssl 
brew install rbenv/tap/openssl@1.0 [didnot work]

brew reinstall --build-from-source https://raw.githubusercontent.com/JParkinson1991/homebrew-deprecated/79d817a7ef794234d5276df0487a9d037b7b7bba/Formula/php@5.6.rb --with-openssl-1.1-patch 

https://getgrav.org/blog/macos-catalina-apache-multiple-php-versions

Monday, April 27, 2020

Monday, April 6, 2020

Getting started with Flask

pip3 install flask
pip3 install flask-cors

from flask import Flask
from flask import request
app = Flask(__name__)
CORS(app)

@app.route('/')
def hello_world():
   return "Welcome to api"

if __name__ == '__main__':
   app.run(debug=True,port=1090)



Sunday, February 23, 2020

How to use regex in PHP Mongo query

use MongoRegex class.

$query = array(    'English' => new MongoRegex('/'.$search_word.'/i'));
//var_dump($query);

$result = $collection->find($query)->limit(100);

using python gspread to read google sheets

https://github.com/burnash/gspread

#!/usr/bin/python# -*- coding: utf-8 -*-import gspread
from oauth2client.service_account import ServiceAccountCredentials
# use creds to create a client to interact with the Google Drive APIscope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('key.json', scope)
client = gspread.authorize(creds)
gss = client.open_by_url("url of sheet")

#list_of_hashes = sheet.get_all_records()#print(len(list_of_hashes))#print(list_of_hashes)

Thursday, January 9, 2020

How to count words in sentence in excel file

Use below formula for it:

=IF(LEN(TRIM(A4))=0,0,LEN(TRIM(A4))-LEN(SUBSTITUTE(A4," ",""))+1)