Posts

SSL verified certificate error when "from langchain_community.llms import Ollama"

I received below error when running the code " from langchain_community.llms import Ollama " in Python in Mac. [nltk_data] Error loading stopwords: <urlopen error [SSL: [nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed: [nltk_data]     unable to get local issuer certificate (_ssl.c:1122)> To resolve the issue, just running below code firstly before the import. import nltk import ssl try: _create_unverified_https_context = ssl._create_unverified_context except AttributeError: pass else: ssl._create_default_https_context = _create_unverified_https_context nltk.download()

Resolve the "scrollToView" not working in safari issue.

The   scrollToView   not working in safari, so replace it with   window.scroolto   which works in both Safari and Chrome browsers. For example, the code in TypeScript: window.scrollTo( 0, XXX (* element's  . offsetTop position );

How to print image to PDF using pdfmake

Recently I was required to print web page contents to PDF file and the web page contains JPEG and SVG format images. I used JavaScript library PDFmake (http://pdfmake.org/) to print webpage to PDF in front-end.   To print image to PDF,  if it's JPEG or PNG format then you need to get its Data URL, and it's its SVG then just get its text content. I used below functions to get image values.   Function to get DataURL of image  const  readAsDataURL =  async  (url) => {      const  response =  await  fetch(url);      const  blob =  await  response.blob();      return   new   Promise ((resolve, reject) => {          let  fileReader =  new   FileReader ();         fileReader.onload =  function  () {              return  resolve(fileReader.result);         };         fileReader.readAsDataURL(blob);     }); };     Function to get SVG text content. const  readAsText =  async  (url) => {      const  response =  await  fetch(url);      const  text =  await  response.text();      r

Login to SharePoint Online site using Azur Activity Directory App

Image
Error: Due to a configuration change made by your administrator, or because you moved to a new location, you must enroll in multi-factor authentication to access Resolution If you do face this, check the conditional access locations in Azure AD and check if your AAD admin can clear the flag. Disable MFA for the account or configure conditional access to give access to "Global Admin" role. Refer to https://cloudblue.freshdesk.com/support/solutions/articles/44001883537--office-365-error-due-to-a-configuration-change-made-by-your-administrator-or-because-you-moved-to https://docs.microsoft.com/en-us/azure/active-directory/conditional-access/location-condition Refer to https://chuvash.eu/2020/06/05/deploying-spfx-using-office-365-cli-custom-aad-app-and-azure-pipelines/ “AADSTS7000218: The request body must contain the following parameter: ‘client_assertion’ or ‘client_secret’

Be aware of the case sensitive "Redirect URL" in Azure Active Directory App settings

When you create a new App in Azure Active Directory App settings, and then setup the "Authentication"->"Add platform" such as ("Web") -> add a redirect URL. Now go back to your client side applications either Web or mobile app, and then add the call back URL to the configuration settings. If you add the URL is  upper or lower case different from the one in App settings, then you will receive the error "Incorrect URL" from Azure, and so make sure enter the URL as same as the settings in Azure. 

Setup Azure Pipeine for SharePoint SPFx

I followed this article https://www.youtube.com/watch?v=8gQFUQzDzSs to setup the Azure pipeline for packaging and deploying SPFx to SharePoint Online. My Repos name contains space between words. When the pipeline executes the "gulp bundle" step,  there is error message from webpack that unable to find some css resources. I did some research in the Internet and fount out that webpack behaviors different in windows and Linux. The above video used the linux platform but I work on windows PC to build and package the SPFx. So once I change the platform to windows with the line of code " vmImage :  'windows-latest' ", the "gulp bundle" step passing the CSS error! However, it always shows error "exited with code 1" at the end and caused the pipeline failure. To resolve this issue, I refer to this https://www.eliostruyf.com/how-to-let-the-warnings-not-fail-the-sharepoint-framework-build-process/ and then added following code to gulpfile.js //