Saturday, 26 April 2025

single spa root config -index ejs laod the latest build , dynamic app urls

single spa root config -index ejs 

------------------------------------

dynamic load balancer and load the latest build to ui app

<!DOCTYPE html>

<html lang="en">

  <head>

    <meta charset="UTF-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <meta http-equiv="X-UA-Compatible" content="ie=edge" />

    <title>Single SPA root config</title>


    <script src="https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.7/runtime.min.js"></script>

    <link

      rel="preload"

      href="https://cdn.jsdelivr.net/npm/single-spa@5.9.0/lib/system/single-spa.min.js"

      as="script"

    />

    <!--

    This CSP allows any SSL-enabled host and for arbitrary eval(), but you should limit these directives further to increase your app's security.

    Learn more about CSP policies at https://content-security-policy.com/#directive

  -->

    <!--   <meta http-equiv="Content-Security-Policy" content="default-src 'self' https: localhost:*; script-src 'unsafe-inline' 'unsafe-eval' https: localhost:*; connect-src https: localhost:* ws://localhost:*; style-src 'unsafe-inline' https:; object-src 'none';"> -->

    <meta name="importmap-type" content="systemjs-importmap" />


    <!-- Add your organization's prod import map URL to this script's src  -->


    <script src="https://cdn.jsdelivr.net/npm/zone.js@0.11.3/dist/zone.min.js"></script>


    <script src="https://cdn.jsdelivr.net/npm/import-map-overrides@2.2.0/dist/import-map-overrides.js"></script>

    <% if (isLocal) { %>

    <script src="https://cdn.jsdelivr.net/npm/systemjs@6.8.3/dist/system.js"></script>

    <script src="https://cdn.jsdelivr.net/npm/systemjs@6.8.3/dist/extras/amd.js"></script>

    <% } else { %>

    <script src="https://cdn.jsdelivr.net/npm/systemjs@6.8.3/dist/system.min.js"></script>

    <script src="https://cdn.jsdelivr.net/npm/systemjs@6.8.3/dist/extras/amd.min.js"></script>

    <% } %>

  </head>

  <body>

    <noscript> You need to enable JavaScript to run this app. </noscript>

    <div id="nav-container"></div>

    <main>

      <div id="mfe1-container"></div>

      <div id="mfe2-container"></div>

    </main>

    <div id="root"></div>

    <script async>

          async function isFirstPoolUp(url) {

            try {

              const response = await fetch(url, { method: 'HEAD' });

                console.log('The URL is valid and accessible.');

                return true;

            } catch (error) {

              console.error('Error fetching the URL:', error);

              return false;

            }

          }

      let poolOne = '';

      (async () => {

      let url = '';

      let env = 'dev';

      if(window.location.hostname.includes('prod')) {

        url = "https://mfe1-godaddy-prod.com/main.js";

        env = 'prod';

      } else if(window.location.hostname.includes('test')) {

        url = "https://mfe1-godaddy-test.com/main.js";

        env = 'test';

      } else {

        url = "https://mfe1-godaddy-dev.com/main.js";

      }

      poolOne = await isFirstPoolUp(url);

      console.log(poolOne);


          // Create a dynamic import map based on window.location

          const importMap = {

            imports: {

              "single-spa": "https://cdn.jsdelivr.net/npm/single-spa@5.9.0/lib/system/single-spa.min.js",

              "@mfeappsinglespa/root-config": "/main.js",

              "react": "https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js",

              "react-dom": "https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.production.min.js",

              "@mfeappsinglespa/mfe1": env == 'prod' ? "https://mfe1-godaddy-prod.com/main.js?"+Date.now() : env == 'test' ? "https://mfe1-godaddy-test.com/main.js?"+Date.now() : "https://mfe1-godaddy-dev.com/main.js/main.js?"+Date.now(),

              "@mfeappsinglespa/mfe2": env == 'prod' ? "https://mfe2-godaddy-prod.com/main.js?"+Date.now() : env == 'test' ? "https://mfe1-godaddy-test.com/main.js?"+Date.now() : "https://mfe1-godaddy-dev.com/main.js/main.js?"+Date.now(),

            }

          };

          const importMap2 = {

              imports: {

                "single-spa": "https://cdn.jsdelivr.net/npm/single-spa@5.9.0/lib/system/single-spa.min.js",

                "@mfeappsinglespa/root-config": "/main.js",

                "react": "https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js",

                "react-dom": "https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.production.min.js",

                "@mfeappsinglespa/mfe1": env == 'prod' ? "https://mfe1-godaddy-prod2.com/main.js?"+Date.now() : env == 'test' ? "https://mfe1-godaddy-test2.com/main.js?"+Date.now() : "https://mfe1-godaddy-dev2.com/main.js/main.js?"+Date.now(),

                "@mfeappsinglespa/mfe2": env == 'prod' ? "https://mfe2-godaddy-prod2.com/main.js?"+Date.now() : env == 'test' ? "https://mfe1-godaddy-test2.com/main.js?"+Date.now() : "https://mfe1-godaddy-dev2.com/main.js/main.js?"+Date.now(),

            }

            };


          // Inject the import map into the document

          const script = document.createElement('script');

          script.type = 'systemjs-importmap';

          script.textContent = JSON.stringify(poolOne ? importMap : importMap2);

          document.head.appendChild(script);


          // Import the main module

          System.import('@mfeappsinglespa/root-config').catch(console.error);

           })();

    </script>

    <import-map-overrides-full

      show-when-local-storage="devtools"

      dev-libs

    ></import-map-overrides-full>

  </body>

</html>


React-Setting Prettier on a React Typescript project:

 Setting Prettier on a React Typescript project:

===============================================

Step 1: Create a React Project with Typescript

npx create-react-app my-app --template typescript



Step 2: Install Prettier package

npm install --save-dev --save-exact prettier




Step 3: ‘prettierrc.json’ file

Create a ‘.prettierrc.json’ file and add some prettier rules:


Example:


{

"trailingComma": "es5",

"tabWidth": 4,

"semi": false,

"singleQuote": true

}



Step 4: ‘.prettierignore’ file

Create a ‘.prettierignore ‘ file and add the follow:


node_modules

# Ignore artifacts:

build

coverage

Step 5: Running Prettier

Inside the project directory, open a terminal.


To run Prettier and format the code, just run:


npx prettier --write <targetFile>



Step 5.1: Let’s Run!

On the project that we create, let’s run prettier over the file App.tsx.


npx prettier --write src/App.tsx



npx prettier --write .  ( For all files )

Saturday, 8 February 2025

Data scientist in 2025 - guide YT

 

Reference from YouTube Channel: Sahil & Sarra

► Everything in one place: Datacamp Associate Data Scientist with Python Career Track:
https://datacamp.pxf.io/ds-track

Data Scientist Certification: https://datacamp.pxf.io/ds-cert

► In this video we covered: 1. How to actually learn Data Science? 2. What skills do you need to develop? 3. What are the best Data Science courses and Certifications? ► Links to everything discussed in the video: 1. Khan academy Linear Algebra: https://www.khanacademy.org/math/line...

2. Khan academy Calculus: https://www.khanacademy.org/math/calc...

3. Khan academy Statistics and Probability: https://www.khanacademy.org/math/stat...

4. Python: https://www.learnpython.org/

5. SQL: https://www.w3schools.com/sql/

6. Machine Learning Specialization: https://imp.i384100.net/machine-learn...

7. Kaggle: https://www.kaggle.com/


single spa root config -index ejs laod the latest build , dynamic app urls

single spa root config -index ejs  ------------------------------------ dynamic load balancer and load the latest build to ui app <!DOCTY...