Monday, February 28, 2022

AWS fixing database errors

This is a good link that is explaining how to do this

 https://aws.amazon.com/premiumsupport/knowledge-center/lightsail-wordpress-fix-database-errors/


Open ssh terminal
vi wp-config.php

Make sure it has the below details

define('WP_ALLOW_REPAIR', true);
define('DB_HOST', '127.0.0.1');
define('DB_NAME','bitnami_wordpress');
define('DB_USER','user');
define('DB_PASSWORD','29wbpY4HjUOu')

Save it by ESC + wq!

Now run mysite.in/wp-admin/maint/repair.php
Or try launching mysite.in/wp-admin

If still does not work, try to connect to the db manually from the terminal by the below command

sudo mysql 'bitnami_wordpress' -h 'localhost' -u 'user' -p
29wbpY4HjUOu

Now if this gives the below error, such as socket error.

In that case, restart  the running services in bitnami

sudo /opt/bitnami/ctlscript.sh status
sudo /opt/bitnami/ctlscript.sh restart
sudo /opt/bitnami/ctlscript.sh status


Now if this does not work,

Reboot the server as well from lightsail console.

If the site does not come up still, we nee to remove the plugins. This can be done by removing the plugins from the file system which is at this path 

/bitnami/wordpress/wp-content/plugins

Github authenticating with Personal Access Token


Creating a token

Verify your email address, if it hasn't been verified yet.


In the upper-right corner of any page, click your profile photo, then click Settings.

In the left sidebar, click  Developer settings.


In the left sidebar, click Personal access tokens.

Click Generate new token.

Give your token a descriptive name.

To give your token an expiration, select the Expiration drop-down menu, then click a default or use the calendar picker.

Select the scopes, or permissions, you'd like to grant this token. To use your token to access repositories from the command line, select repo.

Click Generate token.

To use your token to authenticate to an organization that uses SAML single sign-on, authorize the token. For more information, see "Authorizing a personal access token for use with SAML single sign-on" in the GitHub Enterprise Cloud documentation.


Using a token on the command line

Once you have a token, you can enter it instead of your password when performing Git operations over HTTPS.


For example, on the command line you would enter the following:


$ git clone https://github.com/username/repo.git

Username: your_username

Password: your_token

Personal access tokens can only be used for HTTPS Git operations. If your repository uses an SSH remote URL, you will need to switch the remote from SSH to HTTPS.


If you are not prompted for your username and password, your credentials may be cached on your computer. You can update your credentials in the Keychain to replace your old password with the token.


Instead of manually entering your PAT for every HTTPS Git operation, you can cache your PAT with a Git client. Git will temporarily store your credentials in memory until an expiry interval has passed. You can also store the token in a plain text file that Git can read before every request. For more information, see "Caching your GitHub credentials in Git."

references:

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

Saturday, February 26, 2022

What are firebase dynamic links?

 Dynamic Links are deep links into an app that work whether or not users have installed the app yet. When users open a Dynamic Link into an app that is not installed, the app's Play Store page opens, where users can install the app. After users install and open the app, the app displays the deep-linked content.? 


references:

https://support.google.com/firebase/answer/6397032?hl=en#:~:text=Dynamic%20Links%20are%20deep%20links,displays%20the%20deep%2Dlinked%20content.

Saturday, February 19, 2022

RazorPay providing callback url

When integrating with checkout.js, you can also pass a callback_url for redirection-based flow. If popup creation fails for some reason, we will redirect the browser to external page (bank/3D secure page) for customers to fill in OTP/PIN. At the end of the payment, we will return the control back to the callback_url previously created by you on which the payment results will be submitted.

If you reuse your web integration of Razorpay Checkout inside a webview on Android or iOS, the checkout form may not open. However, in certain scenarios, you want to reuse the web integration in a mobile app, you can do so by passing the callback_url along with other checkout options to process the desired payment.

https://razorpay.com/docs/payment-gateway/web-integration/webapp/

Friday, February 18, 2022

pandas isnull and isna are the same?


 Pandas is a two-dimensional data structure that allows you to store data in rows and columns format. It also provides a lot of API methods that can be used for easier data analysis. Two such methods are isna() and isnull()


Both isna() and isnull() functions are used to find the missing values in the pandas dataframe.


isnull() and isna() literally does the same things. isnull() is just an alias of the isna() method as shown in pandas source code.


Missing values are used to denote the values which are null or do not have any actual values. You can use the pd.NaT, np.NaN or None to denote the missing values in the dataframe.


https://www.stackvidhya.com/pandas-isna-vs-isnull/#:~:text=Both%20isna()%20and%20isnull,values%20in%20the%20pandas%20dataframe.&text=isnull()%20is%20just%20an,not%20have%20any%20actual%20values.


Saturday, February 12, 2022

Pandas cheat sheet


references:

https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf

Python adding two dataframes having same columns matching values of a particular column

 df1:
        t1  a         b
    0   USD 2,877   -2,418
    1   CNH 600     -593
    2   AUD 756     -106
    3   JPY 113     -173
    4   XAG 8          0

df2:
    t2  a        b
0   CNH 64      -44
1   USD 756     -774
2   JPY 1,127   -2,574
3   TWO 56      -58
4   TWD 38      -231

print (df1.set_index('t1').add(df2.set_index('t2'), fill_value=0)
          .reset_index()
          .rename(columns={'index':'t'}))

     t       a       b
0  AUD   756.0  -106.0
1  CNH   664.0  -637.0
2  JPY  1240.0 -2747.0
3  TWD    38.0  -231.0
4  TWO    56.0   -58.0
5  USD  3633.0 -3192.0
6  XAG     8.0     0.0

references:

 https://stackoverflow.com/questions/39010614/pandas-adding-two-dataframes-on-the-common-columns

Chatbot using Rasa


references:

https://www.geeksforgeeks.org/chatbots-using-python-and-rasa/#:~:text=Rasa%20is%20a%20tool%20to,model%20and%20add%20custom%20actions.

Tuesday, February 8, 2022

Numpy dimension, shape, axeses

First:

By convention, in Python world, the shortcut for numpy is np, so:


In [1]: import numpy as np


In [2]: a = np.array([[1,2],[3,4]])


Second:

In Numpy, dimension, axis/axes, shape are related and sometimes similar concepts:


dimension

In Mathematics/Physics, dimension or dimensionality is informally defined as the minimum number of coordinates needed to specify any point within a space. But in Numpy, according to the numpy doc, it's the same as axis/axes:


In Numpy dimensions are called axes. The number of axes is rank.


In [3]: a.ndim  # num of dimensions/axes, *Mathematics definition of dimension*

Out[3]: 2


axis/axes

the nth coordinate to index an array in Numpy. And multidimensional arrays can have one index per axis.


In [4]: a[1,0]  # to index `a`, we specific 1 at the first axis and 0 at the second axis.

Out[4]: 3  # which results in 3 (locate at the row 1 and column 0, 0-based index)


First:

By convention, in Python world, the shortcut for numpy is np, so:


In [1]: import numpy as np


In [2]: a = np.array([[1,2],[3,4]])

Second:

In Numpy, dimension, axis/axes, shape are related and sometimes similar concepts:


dimension

In Mathematics/Physics, dimension or dimensionality is informally defined as the minimum number of coordinates needed to specify any point within a space. But in Numpy, according to the numpy doc, it's the same as axis/axes:


In Numpy dimensions are called axes. The number of axes is rank.


In [3]: a.ndim  # num of dimensions/axes, *Mathematics definition of dimension*

Out[3]: 2

axis/axes

the nth coordinate to index an array in Numpy. And multidimensional arrays can have one index per axis.


In [4]: a[1,0]  # to index `a`, we specific 1 at the first axis and 0 at the second axis.

Out[4]: 3  # which results in 3 (locate at the row 1 and column 0, 0-based index)

shape

describes how many data (or the range) along each available axis.


In [5]: a.shape

Out[5]: (2, 2)  # both the first and second axis have 2 (columns/rows/pages/blocks/...) data




import numpy as np   

>>> np.shape(a)

(2,2)


Also works if the input is not a numpy array but a list of lists



>>> a = [[1,2],[1,2]]

>>> np.shape(a)

(2,2)


Or a tuple of tuples


>>> a = ((1,2),(1,2))

>>> np.shape(a)

(2,2)


np.shape first turns its argument into an array if it doesn't have the shape attribute, That's why it works on the list and tuple examples. 



References:

https://stackoverflow.com/questions/3061761/numpy-array-dimensions

numpy cheatsheet

 https://cheatography.com/mdesai96/cheat-sheets/numpy-cheat-sheet/

Why Numpy arrays are faster

 Numpy arrays are densely packed arrays of homogeneous type. Python lists, by contrast, are arrays of pointers to objects, even when all of them are of the same type. So, you get the benefits of locality of reference.


Also, many Numpy operations are implemented in C, avoiding the general cost of loops in Python, pointer indirection and per-element dynamic type checking. The speed boost depends on which operations you're performing, but a few orders of magnitude isn't uncommon in number crunching programs.

Saturday, February 5, 2022

WhatsApp Business API

The WhatsApp Business API is a fast, secure, and reliable way for businesses to reach their customers all over the world


The WhatsApp Business API client supports a subset of the features provided by the WhatsApp applications you already know from Android, iOS, and the web, including end-to-end encryption. The difference is that this application can be deployed on a server, providing a local API that allows you to programmatically send and receive messages and integrate this workflow with your own systems (e.g., CRMs, contact center platforms, etc.).


Please note that if you use anything other than the official WhatsApp Business API or other official WhatsApp tools, we reserve the right to limit or remove your access to WhatsApp as this violates our policies. Please do not use any non-WhatsApp authorized third-party tools to communicate on WhatsApp.


Business Solution Providers

If you are looking to get started with the WhatsApp Business API right away, we have partnered with a group of third-party business solution providers (BSPs) that can help you with setup and integration. Browse the Partner Directory to find the partners that suit your needs.


How It Works


The first step for businesses to communicate with customers on WhatsApp is to create a WhatsApp business account and set up a line of credit. This business account will allow people to easily identify your business and find out more information such as your address, hours of operation, website, and description. Through your account in the Facebook Business Manager you will have the ability to create message templates for sending notifications to customers at scale.


WhatsApp message templates and media message templates are specific message formats that businesses use to send out notifications or customer care messages to people that have opted in to notifications. Messages can include appointment reminders, shipping information, issue resolution and payment updates. These are the preferred method of reaching customers.


Other types of messages such as text and media, must be sent within a 24-hour window of a message from a customer.



references:

https://developers.facebook.com/docs/whatsapp

Thursday, February 3, 2022

What is SQuAD

 The Stanford Question Answering Dataset (SQuAD) is a set of question and answer pairs that present a strong challenge for NLP models. Whether you’re just interested in learning about a popular NLP dataset or planning to use it in one of your projects, here are all the basics you should know.


What task does SQuAD present? As implied by its name, SQuAD focuses on the task of question answering. It tests a model’s ability to read a passage of text and then answer questions about it (flashback to reading comprehension on the SAT). It’s a relatively straightforward task; here’s an example that the dataset’s creators gave:


How was SQuAD created? To compile SQuAD, the creators sampled 536 from the top 10,000 Wikipedia articles. From each of these sampled articles, they extracted a total of 23,215 individual paragraphs (making sure to filter for paragraphs that were too small). They split the dataset by articles such that 80% of articles went into the training set, 10% into a development set, and 10% into a testing set.


Annotating SQuAD. The most important part of creating a dataset — annotating it — was done by Mechanical Turk workers. Classic! I’m seeing Mechanical Turk making a cameo in a lot of these NLP papers. These workers were selected only if they had a history of high quality work (as measured by the HIT approval rate). For each selected paragraph, the workers were asked to come up with and answer 5 questions on the content of the paragraph. They were provided a text field to type their question, and they could highlight the answers in the paragraph. The creators of SQuAD made sure that the questions that the workers came up with were in their own words, even disabling the copy-paste functionality. Noooooo! Not my copy-paste tools!



References:

https://towardsdatascience.com/the-quick-guide-to-squad-cae08047ebee#:~:text=Oct%208%2C%202020%C2%B74%20min,the%20basics%20you%20should%20know.

What is BERT

BERT (Bidirectional Encoder Representations from Transformers) is a recent paper published by researchers at Google AI Language. It has caused a stir in the Machine Learning community by presenting state-of-the-art results in a wide variety of NLP tasks, including Question Answering (SQuAD v1.1), Natural Language Inference (MNLI), and others.

BERT’s key technical innovation is applying the bidirectional training of Transformer, a popular attention model, to language modelling. This is in contrast to previous efforts which looked at a text sequence either from left to right or combined left-to-right and right-to-left training. The paper’s results show that a language model which is bidirectionally trained can have a deeper sense of language context and flow than single-direction language models. In the paper, the researchers detail a novel technique named Masked LM (MLM) which allows bidirectional training in models in which it was previously impossible.

References:

https://towardsdatascience.com/bert-explained-state-of-the-art-language-model-for-nlp-f8b21a9b6270