Snippets Collections
Looking for a high-performance mobile app to boost your business? Our expert mobile app development services bring your ideas to life with cutting-edge technology and seamless user experience.
🔹 iOS & Android App Development – Scalable, feature-rich apps
🔹 Custom App Solutions – Tailored to your business needs
🔹 UI/UX Design – Engaging & intuitive interfaces
🔹 Cross-Platform Development – Reach a wider audience
🔹 End-to-End Support – From ideation to deployment & maintenance
✅ Stay ahead in the digital world with our expert mobile app solutions!
📞 Call/WhatsApp - +91 7904323274
🌐 Website - https://www.beleaftechnologies.com/mobile-app-development-company
📩 DM us now to turn your vision into reality! 🚀 
Option Explicit
                      'Remember to add a reference to Microsoft Visual Basic for Applications Extensibility 
                      'Exports all VBA project components containing code to a folder in the same directory as this spreadsheet.
                      Public Sub ExportAllComponents()
                          Dim VBComp As VBIDE.VBComponent
                          Dim destDir As String, fName As String, ext As String 
                          'Create the directory where code will be created.
                          'Alternatively, you could change this so that the user is prompted
                          If ActiveWorkbook.Path = "" Then
                              MsgBox "You must first save this workbook somewhere so that it has a path.", , "Error"
                              Exit Sub
                          End If
                          destDir = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name & " Modules"
                          If Dir(destDir, vbDirectory) = vbNullString Then MkDir destDir
                          
                          'Export all non-blank components to the directory
                          For Each VBComp In ActiveWorkbook.VBProject.VBComponents
                              If VBComp.CodeModule.CountOfLines > 0 Then
                                  'Determine the standard extention of the exported file.
                                  'These can be anything, but for re-importing, should be the following:
                                  Select Case VBComp.Type
                                      Case vbext_ct_ClassModule: ext = ".cls"
                                      Case vbext_ct_Document: ext = ".cls"
                                      Case vbext_ct_StdModule: ext = ".bas"
                                      Case vbext_ct_MSForm: ext = ".frm"
                                      Case Else: ext = vbNullString
                                  End Select
                                  If ext <> vbNullString Then
                                      fName = destDir & "\" & VBComp.Name & ext
                                      'Overwrite the existing file
                                      'Alternatively, you can prompt the user before killing the file.
                                      If Dir(fName, vbNormal) <> vbNullString Then Kill (fName)
                                      VBComp.Export (fName)
                                  End If
                              End If
                          Next VBComp
                      End Sub
                      
#include <iostream>
#include <vector>
using namespace std;
 
int Fibonacci(int n, vector<int>& memoVector)
{
  if(n == 0 || n == 1)
    return 1;
    
  if(memoVector[n] != -1)
    return memoVector[n];
    
  return memoVector[n] = Fibonacci(n-1, memoVector) + Fibonacci(n-2, memoVector);
}
 
int main() 
{
  int n;
  cin >> n;
  vector<int> memoVector(n+1, -1);
  
  cout << "Ways to reach " << n << "th stair: " << Fibonacci(n, memoVector) << endl;
  
  return 0;
}
#include <iostream>
using namespace std;

int SumOfNNaturalNumbers(int n)
{
  if(n == 1)
    return 1;
    
  return (n + SumOfNNaturalNumbers(n-1));
}

int main() 
{
  int n;
  cin >> n;
  
  cout << "Sum of first " << n << " natural numbers: " << SumOfNNaturalNumbers(n) << endl;
  return 0;
}
#include <iostream>
#include <vector>
using namespace std;

int Fibonacci(int n, vector<int>& memoVector)
{
  if(n == 0 || n == 1)
    return n;
    
  if(memoVector[n] != -1)
    return memoVector[n];
    
  return memoVector[n] = Fibonacci(n-1, memoVector) + Fibonacci(n-2, memoVector);
}

int main() 
{
  int n;
  cin >> n;
  vector<int> memoVector(n+1, -1);
  
  cout << n << "th Fibonacci number: " << Fibonacci(n-1, memoVector) << endl;
  
  return 0;
}
//data
"locations": [
	{
	"name": "Business Academy Australia",
	"lat": -33.8688,
	"lng": 151.2093,
	"website": "https://www.businessacademyaustralia.com.au",
	"tel": "0290198888",
	"email": "info@businessacademyaustralia.com.au",
	"category": "Campus",
	"governmentService": true,
	"formattedLocality": "Sydney, NSW 2000",
	"providerId": "13579",
	"locationId": "4001",
	"registeredTrainerId": "24680",
	"isVetFeeProvider": false,
	"locationTypeId": null,
	"facilities": null,
	"service": null,
	"apprenticeshipTraineeship": true,
	"minimumFee": 1400,
	"maximumFee": 2800,
	"isVetFeeCourse": false,
	"isAvailableOnline": true,
	"isAvailablePartTime": true,
	"deliveryModes": ["In-person"]
	},
	{
	"name": "Entrepreneur Education",
	"lat": -27.4698,
	"lng": 153.0251,
	"website": "https://www.entrepreneureducation.com.au",
	"tel": "0733332222",
	"email": "info@entrepreneureducation.com.au",
	"category": "Campus",
	"governmentService": true,
	"formattedLocality": "Brisbane, QLD 4000",
	"providerId": "98765",
	"locationId": "4002",
	"registeredTrainerId": "13579",
	"isVetFeeProvider": false,
	"locationTypeId": null,
	"facilities": null,
	"service": null,
	"apprenticeshipTraineeship": true,
	"minimumFee": 3800,
	"maximumFee": 4700,
	"isVetFeeCourse": true,
	"isAvailableOnline": false,
	"isAvailablePartTime": false,
	"deliveryModes": ["Online","Hybrid"]
	},
	{
	"name": "Small Business Training Institute",
	"lat": -27.9687807,
	"lng": 153.4066696,
	"website": "https://www.sbtinstitute.com.au",
	"tel": "0388885555",
	"email": "info@sbtinstitute.com.au",
	"category": "Campus",
	"governmentService": false,
	"formattedLocality": "Melbourne, VIC 3000",
	"providerId": "54321",
	"locationId": "4003",
	"registeredTrainerId": "67890",
	"isVetFeeProvider": false,
	"locationTypeId": null,
	"facilities": null,
	"service": null,
	"apprenticeshipTraineeship": false,
	"minimumFee": 2200,
	"maximumFee": 4100,
	"isVetFeeCourse": true,
	"isAvailableOnline": true,
	"isAvailablePartTime": true,
	"deliveryModes": ["In-person"]
	},
  
  
  // using groupby to group locations based on the items in the delivery modes values
  
   	// shows array of arrays
    const getDeliveryItems = items.map((item) => item.deliveryModes);
    console.log({ getDeliveryItems });

    //flatten all the arrays combined into one array and sort each one by their name key
    const flattened = items.flatMap((item) => item.deliveryModes.map((mode) => ({ ...item, mode }))).sort((a, b) => a.name.localeCompare(b.name));

    console.log({ flattened });

    // use grouping to separate out by a new mode key
    let modesGrouped = Object.groupBy(flattened, ({ mode }) => mode);
    console.log({ modesGrouped });
	// In-person: Array(5), Online: Array(4), Hybrid: Array(1)}

    Object.keys(modesGrouped).forEach((key) => {
        // remove the mode key by returing ...rest
        modesGrouped[key] = modesGrouped[key].map(({ mode, ...rest }) => rest);
    });

    console.log({ modesGrouped }); //

   // destructuring
   const { Hybrid: hybrid, ["In-person"]: inPerson, Online: online } = modesGrouped;
   console.log({ hybrid, inPerson, online });







// another example

const apprenticeshipValues = Object.groupBy(items, ({ apprenticeshipTraineeship }) => apprenticeshipTraineeship);

        console.log(apprenticeshipValues[true]);
        console.log(apprenticeshipValues[false]);

        // // desctructuring the objects into an array
        const { true: apprenticeshipTraineeship = [],
               false: nonapprenticeshipTraineeship = [] } = apprenticeshipValues;
        
		console.log({ apprenticeshipTraineeship });
        console.log({ nonapprenticeshipTraineeship });
const items = [
    { name: "Item1", price: 450 },
    { name: "Item2", price: 1500 },
    { name: "Item3", price: 350 },
    { name: "Item4", price: 2000 },
    { name: "Item5", price: 1200 },
    { name: "Item6", price: 300 }
];

const groupedItems = items.reduce((groups, item) => {
    // Define price ranges
    let groupKey = "";
    if (item.price < 500) {
        groupKey = "Under 500";
    } else if (item.price > 1000) {
        groupKey = "Above 1000";
    }

    // Add item to appropriate group
    if (groupKey) {
        if (!groups[groupKey]) {
            groups[groupKey] = [];
        }
        groups[groupKey].push(item);
    }

    return groups;
}, {});

console.log(groupedItems);


// json
{
    "Under 500": [
        { "name": "Item1", "price": 450 },
        { "name": "Item3", "price": 350 },
        { "name": "Item6", "price": 300 }
    ],
    "Above 1000": [
        { "name": "Item2", "price": 1500 },
        { "name": "Item4", "price": 2000 },
        { "name": "Item5", "price": 1200 }
    ]
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>🔬 Aropha AI Biodegradation Prediction Platform</title>
  <style>
    /* General Styles */
    body {
      font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      margin: 0;
      padding: 0;
      background-color: #2C4555;
      color: #ffffff;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }
    
    .container {
      background: #1E2A34;
      padding: 30px;
      border-radius: 10px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
      width: 90%;
      max-width: 500px;
      text-align: center;
    }
    
    /* Logo */
    .logo {
      width: 200px;
      margin-bottom: 20px;
      margin-top: 20px;
    }
    
    /* Headings */
    h1 {
      margin-bottom: 20px;
      font-size: 24px;
      color: #ffffff;
    }
    
    /* Form Groups */
    .form-group {
      margin-bottom: 15px;
      text-align: left;
    }
    
    label {
      display: block;
      margin: 10px 0 5px;
      font-weight: bold;
      color: #ffffff;
    }
    
    /* Input Fields */
    input[type="email"],
    input[type="password"],
    input[type="file"] {
      width: 100%;
      padding: 10px;
      margin-bottom: 10px;
      border-radius: 5px;
      background: #24343D;
      color: #ffffff;
      border: none;
      outline: none;
    }
    
    input::placeholder {
      color: #b0b8bf;
    }
    
    /* Buttons */
    button,
    input[type="submit"] {
      width: 100%;
      background-color: #007BFF;
      color: #ffffff;
      border: none;
      padding: 12px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 16px;
    }
    
    button:hover,
    input[type="submit"]:hover {
      background-color: #0056b3;
    }
    
    /* Row with label + file input side by side */
    .row-flex {
      display: flex;
      align-items: center;
      gap: 0.8em;
      flex-wrap: wrap;
    }
    
    /* Message Boxes */
    #creditsBox,
    #messages {
      background: #24343D;
      padding: 15px;
      min-height: 50px;
      border: 1px solid #007BFF;
      margin-top: 15px;
      white-space: pre-wrap;
      border-radius: 5px;
      color: #ffffff;
      text-align: left; /* Align text to left */
    }

    /* Footer Styles */
    footer {
      text-align: center;
      padding: 10px;
      color: #b0b8bf;
      font-size: 14px;
    }

    footer a {
      color: #ffffff;
      text-decoration: underline;
    }
  </style>
</head>
<body>
    <div class="container">
      <img src="https://www.users.aropha.com/static/assets/img/logo-rectangular.png" alt="Aropha Logo" class="logo">
    <h1>Aropha's Biodegradation Prediction Platform</h1>
    <form id="arophaForm">
      <!-- Email -->
      <div class="form-group">
        <label for="email">Email:</label>
        <input
          type="email"
          id="email"
          name="email"
          placeholder="Enter your email"
          required
        />
      </div>

      <!-- Password -->
      <div class="form-group">
        <label for="password">Password:</label>
        <input
          type="password"
          id="password"
          name="password"
          placeholder="Enter your password"
          required
        />
      </div>

      <!-- Check Credits button -->
      <div class="form-group">
        <button id="checkCreditsBtn" type="button">
          Check Your Credits
        </button>
      </div>

      <!-- Spreadsheet (.xlsx) label next to file chooser -->
      <div class="form-group row-flex">
        <label for="spreadsheet" style="margin-bottom: 0;">
          Spreadsheet (.xlsx):
        </label>
        <input
          type="file"
          id="spreadsheet"
          name="spreadsheet"
          accept=".xlsx"
          required
        />
      </div>

      <!-- Submit Template Spreadsheet button -->
      <div class="form-group">
        <button id="submitBtn" type="submit">
          Submit Template Spreadsheet
        </button>
      </div>
    </form>

    <!-- Displays credit info from the server -->
    <div id="creditsBox"></div>

    <!-- Displays messages for final spreadsheet submission -->
    <div id="messages"></div>
  </div>

  <footer>
    <p>
      Follow us on <a href="https://www.linkedin.com/company/aropha/">LinkedIn</a> | &copy; 2025 Aropha Inc. All Rights Reserved.
    </p>
  </footer>

  <script>
    // Utility: convert ArrayBuffer to Base64
    function arrayBufferToBase64(buffer) {
      let binary = '';
      const bytes = new Uint8Array(buffer);
      for (let i = 0; i < bytes.length; i++) {
        binary += String.fromCharCode(bytes[i]);
      }
      return btoa(binary);
    }

    // 1) Check Your Credits
    document.getElementById('checkCreditsBtn').addEventListener('click', async () => {
      const creditsBox = document.getElementById('creditsBox');
      creditsBox.textContent = 'Checking credits...';

      const email = document.getElementById('email').value.trim();
      const password = document.getElementById('password').value;

      if (!email || !password) {
        creditsBox.textContent = 'Please enter Email and Password first.';
        return;
      }

      // Construct JSON payload
      const json_data = {
        email,
        password,
        filename: 'filename_blank',
        raw_data: 'blank'
      };

      try {
        const response = await fetch('https://modelserver.aropha.com/run_twin_engines', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify(json_data)
        });

        if (!response.ok) {
          try {
            const errorData = await response.json();
            console.log('Full error response:', errorData);
            if (errorData.detail) {
              creditsBox.textContent = errorData.detail;
            } else {
              creditsBox.textContent = `Error: ${JSON.stringify(errorData, null, 2)}`;
            }
          } catch (jsonError) {
            const rawError = await response.text();
            console.error('Raw error response:', rawError);
            creditsBox.textContent = `Error: Could not parse JSON. Raw response: ${rawError}`;
          }
          return;
        }

        const responseData = await response.json();
        if (typeof responseData.credits !== 'undefined') {
          creditsBox.textContent = `You have ${responseData.credits} credits remaining.`;
        } else {
          creditsBox.textContent = 'Credits info not found in server response.';
        }
      } catch (err) {
        creditsBox.textContent = 'Error: ' + err;
      }
    });

    // 2) Submit the form (spreadsheet upload)
    document.getElementById('arophaForm').addEventListener('submit', async function (event) {
      event.preventDefault(); // Prevent normal form POST

      const messagesDiv = document.getElementById('messages');
      messagesDiv.textContent = 'Preparing and uploading...';

      const email = document.getElementById('email').value.trim();
      const password = document.getElementById('password').value;
      const fileInput = document.getElementById('spreadsheet');

      if (!fileInput.files || fileInput.files.length === 0) {
        messagesDiv.textContent = 'Please select a spreadsheet file.';
        return;
      }

      const file = fileInput.files[0];
      const filename = file.name;

      // Read the file as an ArrayBuffer
      let fileBuffer;
      try {
        fileBuffer = await file.arrayBuffer();
      } catch (err) {
        messagesDiv.textContent = 'Error reading file: ' + err;
        return;
      }

      // Convert the ArrayBuffer to Base64
      const raw_data_b64 = arrayBufferToBase64(fileBuffer);

      // Construct JSON payload
      const json_data = {
        email,
        password,
        filename,
        raw_data: raw_data_b64
      };

      // POST to Aropha modelserver
      try {
        const response = await fetch('https://modelserver.aropha.com/run_twin_engines', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify(json_data)
        });
        
        if (response.status === 422) {
          const responseData = await response.json();
          if (responseData.detail) {
            messagesDiv.textContent = responseData.detail;
          } else {
            messagesDiv.textContent = JSON.stringify(responseData, null, 2);
          }
          if (responseData['flag data']) {
            const flagBase64 = responseData['flag data'];
            const byteChars = atob(flagBase64);
            const byteNumbers = new Array(byteChars.length);
            for (let i = 0; i < byteChars.length; i++) {
              byteNumbers[i] = byteChars.charCodeAt(i);
            }
            const byteArray = new Uint8Array(byteNumbers);
            const blob = new Blob([byteArray], { type: 'application/gzip' });
  
            const now = new Date();
            const currentDate = now.toISOString().split('T')[0];
            const currentTime = now.toTimeString().split(' ')[0].replace(/:/g, '-');
            const templateFileName = filename.replace(/\.[^/.]+$/, '');
            const dynamicFileName = `flag_notes_${templateFileName}_${currentDate}_${currentTime}.gz`;
  
            const downloadUrl = URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = downloadUrl;
            link.download = dynamicFileName;
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
            URL.revokeObjectURL(downloadUrl);
          }
          return;
        } else if (!response.ok) {
          try {
            const errorData = await response.json();
            console.log('Full error response:', errorData);
            if (errorData.detail) {
              messagesDiv.textContent = errorData.detail;
            } else {
              messagesDiv.textContent = `Error: ${JSON.stringify(errorData, null, 2)}`;
            }
          } catch (jsonError) {
            const rawError = await response.text();
            console.error('Raw error response:', rawError);
            messagesDiv.textContent = `Error: Could not parse JSON. Raw response: ${rawError}`;
          }
          return;
        }
  
        if (response.status === 200) {
          const message = await response.json();
          messagesDiv.textContent = message.detail;
        }
  
      } catch (err) {
        messagesDiv.textContent = 'Error submitting data: ' + err;
      }
    });
  </script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>🔬 Aropha AI Biodegradation Prediction Platform</title>
  <style>
    /* General Styles */
    body {
      font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      margin: 0;
      padding: 0;
      background-color: #2C4555; /* Matching background */
      color: #ffffff;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }

    .container {
      background: #1E2A34;
      padding: 30px;
      border-radius: 10px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
      width: 90%;
      max-width: 400px;
      text-align: center;
    }

    /* Logo */
    .logo {
      width: 200px;
      margin-bottom: 20px;
    }

    h2 {
      margin-bottom: 20px;
      font-size: 24px;
      color: #ffffff;
    }

    label {
      display: block;
      margin: 10px 0 5px;
      text-align: left;
      font-weight: bold;
      color: #ffffff;
    }

    input {
      width: 100%;
      padding: 10px;
      margin-bottom: 10px;
      border: 1px solid #ccc;
      border-radius: 5px;
      background: #24343D;
      color: #ffffff;
      border: none;
      outline: none;
    }

    input::placeholder {
      color: #b0b8bf;
    }

    .error {
      color: red;
      font-size: 14px;
      display: none;
    }

    button[type="submit"] {
      width: 100%;
      background-color: #007BFF;
      color: white;
      border: none;
      padding: 12px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 16px;
    }

    button[type="submit"]:hover {
      background-color: #0056b3;
    }

    /* Modal Styles */
    .modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.6);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 1000;
    }

    .modal-content {
      background: #1E2A34;
      padding: 20px;
      border-radius: 8px;
      max-width: 500px;
      width: 90%;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
      text-align: center;
      color: #ffffff;
    }

    .close-button {
      margin-top: 20px;
      padding: 10px 20px;
      border: none;
      background: #007BFF;
      color: white;
      border-radius: 5px;
      cursor: pointer;
    }

    .close-button:hover {
      background: #0056b3;
    }

    /* Additional Info */
    .info {
      text-align: center;
      margin-top: 20px;
      font-size: 14px;
      color: #b0b8bf;
    }

    .info a {
      color: #007BFF;
      text-decoration: none;
    }

    .info a:hover {
      text-decoration: underline;
    }

    /* Footer Styles */
    footer {
      text-align: center;
      padding: 10px;
      color: #b0b8bf;
      font-size: 14px;
    }

    footer a {
      color: #ffffff;
      text-decoration: underline;
    }
  </style>
</head>
<body>

  <div class="container">
    <img src="https://www.users.aropha.com/static/assets/img/logo-rectangular.png" alt="Aropha Logo" class="logo">
    <h2>Create an Account</h2>
    <form id="signup-form">
      <label for="first_name">First Name</label>
      <input type="text" id="first_name" name="first_name" placeholder="Optional">

      <label for="last_name">Last Name</label>
      <input type="text" id="last_name" name="last_name" placeholder="Optional">

      <label for="email">Email</label>
      <input type="email" id="email" name="email" required>

      <label for="password">Password</label>
      <input type="password" id="password" name="password" required>

      <label for="confirm_password">Re-enter Password</label>
      <input type="password" id="confirm_password" name="confirm_password" required>
      <p class="error" id="error-message">Passwords do not match.</p>

      <button type="submit">Sign Up</button>
    </form>
    <!-- Additional Info for Password Reset -->
    <div class="info">
      <p>
        Forgot your password? Reset it <a href="https://www.users.aropha.com/login.html" target="_blank">here</a>.
      </p>
    </div>
  </div>

  <!-- Modal for displaying messages from your endpoint -->
  <div id="messageModal" class="modal">
    <div class="modal-content">
      <p id="modalMessage"></p>
      <button class="close-button" id="closeModal">Close</button>
    </div>
  </div>

  <footer>
    <p>
      Follow us on <a href="https://www.linkedin.com/company/aropha/">LinkedIn</a> | &copy; 2025 Aropha Inc. All Rights Reserved.
    </p>
  </footer>

  <script>
    document.getElementById("signup-form").addEventListener("submit", function(event) {
    event.preventDefault(); // Prevent default form submission

    var password = document.getElementById("password").value;
    var confirmPassword = document.getElementById("confirm_password").value;
    var errorMessage = document.getElementById("error-message");

    if (password !== confirmPassword) {
        errorMessage.style.display = "block";
        return;
    } else {
        errorMessage.style.display = "none";
    }

    let formData = new FormData(document.getElementById("signup-form"));

    fetch('https://modelserver.aropha.com/register', {
        method: 'POST',
        body: formData
    })
    .then(async response => {
        let responseData;
        try {
            responseData = await response.json(); // Try parsing as JSON
        } catch (error) {
            responseData = await response.text(); // Fallback for non-JSON responses
        }

        console.log("Server response:", responseData); // Debugging log

        let message = "";
        if (typeof responseData === "object") {
            message = responseData.detail || responseData.message || JSON.stringify(responseData, null, 2);
        } else {
            message = responseData;
        }

        document.getElementById("modalMessage").textContent = message;
        document.getElementById("messageModal").style.display = "flex";
    })
    .catch(error => {
        console.error("Fetch error:", error);
        document.getElementById("modalMessage").textContent = "An error occurred. Please try again.";
        document.getElementById("messageModal").style.display = "flex";
    });
});

// Close modal
document.getElementById("closeModal").addEventListener("click", function() {
    document.getElementById("messageModal").style.display = "none";
});

  </script>
</body>
</html>
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":star: What's on in Melbourne this week! :star:"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n\n Hey Melbourne, happy Monday! Please see below for what's on this week. "
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Xero Café :coffee:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n :new-thing: *This week we are offering:* \n\n *_Insert Sweet Treats_* \n\n *Weekly Café Special*: *_Insert Coffee Special_*"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": " Wednesday, 25th September :calendar-date-25:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n\n:lunch: *Lunch*: From *12pm* in the L3 kitchen + Wominjeka breakout space!"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Thursday, 26th September :calendar-date-26:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":breakfast: *Breakfast*: Provided by *Kartel Catering* from *8:30am - 10:30am* in the Wominjeka Breakout Space."
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "Stay tuned to this channel, and make sure you're subscribed to the <https://calendar.google.com/calendar/u/0?cid=Y19xczkyMjk5ZGlsODJzMjA4aGt1b3RnM2t1MEBncm91cC5jYWxlbmRhci5nb29nbGUuY29t|*Melbourne Social Calendar*> :party-wx:"
			}
		}
	]
}
#include <iostream>
using namespace std;

int main() 
{
    
    int arr[]={1,2,3,4,5,6};
    for (int i = 0; i < 6; i++) {
        if (arr[i]%2==0){
          arr[i]=arr[i]+10;
        }
        else arr[i]=arr[i]*2;
         cout<<arr[i]<<" ";
    }
    
    return 0;
}
=DATEVALUE(CONCATENATE(RIGHT(AL9,4),"-",SUBSTITUTE(SUBSTITUTE(AL9,RIGHT(AL9,5),""),"/","-")))
public with sharing class DependentPicklistController {

    public static Map<String, DependentPicklistWrapper> getDependentPicklistValuesFiltered(String dependentField, List<String> keys) {
        Map<String, DependentPicklistWrapper> dependentPicklistValues = getDependentPicklistValues(dependentField);

        for (String currentKey : dependentPicklistValues.keySet()) {
            if (!keys.contains(currentKey)) {
                dependentPicklistValues.remove(currentKey);
            }
        }

        return dependentPicklistValues;
    }

    public static Map<String, DependentPicklistWrapper> getDependentPicklistValues(String dependentPickListField) {
        List<String> splitString = dependentPickListField.split('\\.');
        Schema.SobjectField dependentField = Schema.getGlobalDescribe().get(splitString[0]).getDescribe().fields.getMap().get(splitString[1]);
        Map<String, DependentPicklistWrapper> dependentPicklistValues = new Map<String, DependentPicklistWrapper>();
        Schema.DescribeFieldResult dependentFieldResult = dependentField.getDescribe();
        Schema.sObjectField controllerField = dependentFieldResult.getController();

        Schema.DescribeFieldResult controllerFieldResult = controllerField.getDescribe();
        List<Schema.PicklistEntry> controllerValues = (controllerFieldResult.getType() == Schema.DisplayType.Boolean ? null : controllerFieldResult.getPicklistValues());

        String base64map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

        for (Schema.PicklistEntry entry : dependentFieldResult.getPicklistValues()) {
            if (entry.isActive() && String.isNotEmpty(String.valueOf(((Map<String, Object>) JSON.deserializeUntyped(JSON.serialize(entry))).get('validFor')))) {
                List<String> base64chars = String.valueOf(((Map<String, Object>) JSON.deserializeUntyped(JSON.serialize(entry))).get('validFor')).split('');
                for (Integer i = 0; i < (controllerValues != null ? controllerValues.size() : 2); i++) {
                    Schema.PicklistEntry controllerValue = (Schema.PicklistEntry) (controllerValues == null
                        ? (Object) (i == 1)
                        : (Object) (controllerValues[i].isActive() ? controllerValues[i] : null));

                    Integer bitIndex = i / 6;
                    if (bitIndex > base64chars.size() - 1) {
                        break;
                    }
                    Integer bitShift = 5 - Math.mod(i, 6);
                    if (controllerValue == null || (base64map.indexOf(base64chars[bitIndex]) & (1 << bitShift)) == 0) {
                        continue;
                    }
                    String apiName = controllerValue.getValue();
                    if (!dependentPicklistValues.containsKey(apiName)) {
                        dependentPicklistValues.put(apiName, new DependentPicklistWrapper(new LabelValueWrapper(controllerValue.getLabel(), apiName)));
                    }
                    dependentPicklistValues.get(apiName).addPicklistEntry(new LabelValueWrapper(entry.getLabel(), entry.getValue()));
                }
            }
        }
        return dependentPicklistValues;
    }

    public class LabelValueWrapper {
        @AuraEnabled
        public String label { get; set; }
        @AuraEnabled
        public String value { get; set; }

        public LabelValueWrapper(String label, String value) {
            this.label = label;
            this.value = value;
        }
    }

    public class DependentPicklistWrapper {
        @AuraEnabled
        public List<LabelValueWrapper> dependentPicklist;
        @AuraEnabled
        public LabelValueWrapper entry;

        public DependentPicklistWrapper(LabelValueWrapper entry) {
            this.dependentPicklist = new List<LabelValueWrapper>();
            this.entry = entry;
        }

        public void addPicklistEntry(LabelValueWrapper picklistEntry) {
            this.dependentPicklist.add(picklistEntry);
        }
    }
}
1) React Toast
for toast notififcation

2) React Spring (it is a cool lib) - https://react-spring.dev/
for animation --- npm i @react-spring/web

3) react-transition-group
for tailwind transition 

4) clsx + tailwindmerge = cn
for conditional class
  ------------------------------
  import clsx, { ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...classes: ClassValue[]) {
  return twMerge(clsx(...classes));
}
===================================

5) cva 
class-variant-authority

6) shadcn
component library

7) floating-ui - https://floating-ui.com/
for floating tooltip. I think it was previously called popper.js
npm install @floating-ui/react

8) DOMPurify - npm i dompurify
Dompurify is a JavaScript library that provides a fast and secure way to purify HTML content.
It is specially designed to prevent Cross-Site Scripting (XSS) attacks by eliminating any potentially harmful scripts from user input.
Dompurify accomplishes this by parsing the HTML and DOM elements, filtering out unsafe tags and attributes, and ensuring that only safe content is concluded on the web page.

9) TipTap - https://tiptap.dev/docs - look for Editor 
npm install @tiptap/react @tiptap/pm @tiptap/starter-kit
Tiptap lets you create a fully customizable rich text editor using modular building blocks. It offers a range of open-source and Pro extensions, allowing you to configure every part of the editor with a few lines of code. The API lets you customize and extend editor functionality.

10) React Hook Form - https://www.react-hook-form.com/
npm install react-hook-form

11) react-responsive - npm i react-responsive
for useMediaQuery

12) millionjs millionlint

13) open editor - https://github.com/zjxxxxxxxxx/open-editor
npm i @open-editor/vite -D

14) React Scan - https://react-scan.com/monitoring
npm i react-scan

15) usehooks-ts - usehooks-ts.com
npm I usehooks-ts

16) https://react-select.com/home#getting-started
npm i --save react-select

17) @open-editor/vite - https://npm.io/package/@open-editor/vite
for locating the code in vscode via browser

18) https://headlessui.com/
for accordians and popovers
function app() {
    const message = "Hello from App!";
    
    // Function that will use `this` correctly
    function showMessage() {
        console.log(this.message);
    }
    
    const button = document.querySelector("button");
    
    // Bind `this` inside the event listener to the `app` function
    button.addEventListener("click", showMessage.bind({ message }));
}

// Initialize the app
app();
 const overlayDivStyles = {
                    backgroundColor: "red",
                    width: "100%",
                    height: "100%",
                    display: "flex",
                    justifyContent: "center",
                    position: "absolute",
                    zIndex: 2,
                };

  const domOverlay = document.createElement("div");
  domOverlay.classList.add("map-overlay");
  domOverlay.innerHTML = `<h4>No locations exist with these current filters<h3>`;
  //assign my styles to the overlay Div
  Object.assign(domOverlay.style, overlayDivStyles);
System.debug('Teste');
function getComponentConnections(componentName=''){
    if(!componentName){return};
    var currentPage=window.cells.PageManager.TemplateManager.selected;
    const component=[...window.cells.TemplateManager.templates[currentPage].childNodes].find((e)=>e.localName===componentName);
    window.$00=component;
    const componentConnections=component.cellsConnections;
    console.log('mine ',component,' connections:',componentConnections)
}
/* ====== create node.js server with core 'http' module ====== */
// dependencies
const http = require("http");

// PORT
const PORT = 3000;

// server create
const server = http.createServer((req, res) => {
   if (req.url === "/") {
      res.write("This is home page.");
      res.end();
   } else if (req.url === "/about" && req.method === "GET") {
      res.write("This is about page.");
      res.end();
   } else {
      res.write("Not Found!");
      res.end();
   }
});

// server listen port
server.listen(PORT);

console.log(`Server is running on PORT: ${PORT}`);

/* ========== *** ========== */

/* ====== create node.js server with express.js framework ====== */
// dependencies
const express = require("express");

const app = express();

app.get("/", (req, res) => {
   res.send("This is home page.");
});

app.post("/", (req, res) => {
   res.send("This is home page with post request.");
});

// PORT
const PORT = 3000;

app.listen(PORT, () => {
   console.log(`Server is running on PORT: ${PORT}`);
});


// ======== Instructions ========
// save this as index.js
// you have to download and install node.js on your machine
// open terminal or command prompt
// type node index.js
// find your server at http://localhost:3000
position: absolute;
top: 50%;
right: 80px;
transform: translateY(-50%);
position: absolute;
top: 50%;
right: 80px;
transform: translateY(-50%);
<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-">

        <title>Sign Up</title>

        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

    </head>
8
    <body>

        <div class="container">

            <div class="row">

                <div class="col-md-">
12
                    <h2>Register</h2>

                    <p>Please fill this form to create an account.</p>

                    <form action="" method="post">

                        <div class="form-group">

                            <label>Full Name</label>

                            <input type="text" name="name" class="form-control" required>

                        </div>    

                        <div class="form-group">

                            <label>Email Address</label>

                            <input type="email" name="email" class="form-control" required />

                        </div>    

                        <div class="form-group">

                            <label>Password</label>

                            <input type="password" name="password" class="form-control" required>

                        </div>

                        <div class="form-group">

                            <label>Confirm Password</label>

                            <input type="password" name="confirm_password" class="form-control" required>

                        </div>

                        <div class="form-group">

                            <input type="submit" name="submit" class="btn btn-primary" value="Submit">

                        </div>

                        <p>Already have an account? <a href="login.php">Login here</a>.</p>

                    </form>

                </div>

            </div>

        </div>    

    </body>

</html>
width: 7px;
height: 12px;
background-image: url(../images/btn-arrow.svg);
background-size: contain;
.woocommerce .products .product {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: ;
}

.woocommerce .products .product a img {
    width: 100%; /* Ensures all images fill the container */
    height: 230px; /* Fixed height for consistency */
    object-fit: contain; /* Ensures the whole image fits without cropping */
    transition: transform 0.3s ease-in-out;
}

/* Zoom-out effect like Rehub theme */
.woocommerce .products .product:hover a img {
    transform: scale(0.9); /* Adjust zoom-out effect */
    opacity: 0.9; /* Optional: Slight transparency effect */
}


function memoize(fn) {
  const cache = new Map();
  return (...args) => {
    const key = JSON.stringify(args);
    if (cache.has(key)) return cache.get(key);
    const result = fn(...args);
    cache.set(key, result);
    return result;
  };
}

// Example: Expensive Fibonacci Calculation
const fibonacci = memoize((n) => (n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2)));
#include <iostream>
using namespace std;

int main() {
    // Write C++ code here
    int n;
    cout<<"enter a number :"<<endl;
    cin>>n;
    int arr[n];
    for(int i=1;i<=n;i++){
        arr[i-1]=i*i;
    }
    for(int i=0;i<n;i++){
        cout<<arr[i]<<" ";
    }
    return 0;
}
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;

int main() {
    // Write C++ code here
    int arr[] ={1,2,3,4,5};
    int n= sizeof(arr)/4;
int mn = arr[0];
    
     for(int i=0;i<n;i++){
    mn = min(arr[0],mn);
    }
    cout<<mn;
   

    return 0;
}
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;

int main() {
    // Write C++ code here
    int arr[] ={1,2,3,4,5};
    int n= sizeof(arr)/4;
int mx = arr[0];
    
     for(int i=0;i<n;i++){
        // if(arr[i]>mx) mx=arr[i];
      mx= max(arr[i],mx);
    }
    cout<<mx;
   

    return 0;
}
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;

int main() {
    // Write C++ code here
    int arr[] ={1,2,3,4,5};
    int n= sizeof(arr)/4;
  int sum=0;
    
     for(int i=0;i<n;i++){
        sum += arr[i];
    }
    cout<<sum;
   

    return 0;
}
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;
void change(int arr[]){
    arr[4]=0;
}

int main() {
    // Write C++ code here
    int arr[5] ={1,2,3,4,5};
  
    
     for(int i=0;i<=4;i++){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
    
    change(arr);
    
      for(int i=0;i<=4;i++){
        cout<<arr[i]<<" ";
    }
    

    return 0;
}
def process_masks(input_directory):
    """
    Processes all masks in a directory to calculate the percentage of masks 
    with a bounding box to total image area ratio >= 20%, considering only masks
    that have at least 5 unique structures (values > 0).
    
    :param input_directory: Path to the directory containing PNG mask files.
    :return: Percentage of masks passing the filter and total processed count.
    """
    total_valid_masks = 0  # Total masks with at least 5 structures
    passed_masks = 0       # Masks passing the area ratio filter

    for filename in os.listdir(input_directory):
        if filename.endswith(".png"):
            filepath = os.path.join(input_directory, filename)

            # Open the image and convert it to numpy array
            mask = Image.open(filepath)
            mask_array = np.array(mask)

            # Get unique structure IDs excluding the background (0)
            unique_structures = set(mask_array.flatten()) - {0}

            # Check if the mask has at least 5 structures
            if len(unique_structures) >= 5:
                total_valid_masks += 1

                # Find all non-background pixels (non-zero)
                structure_pixels = np.argwhere(mask_array > 0)

                if structure_pixels.size > 0:
                    # Calculate the bounding box for all structures
                    y_min, x_min = structure_pixels.min(axis=0)
                    y_max, x_max = structure_pixels.max(axis=0)

                    # Compute the area of the bounding box
                    bounding_box_area = (x_max - x_min + 1) * (y_max - y_min + 1)

                    # Compute the total area of the image
                    total_area = mask_array.shape[0] * mask_array.shape[1]

                    # Calculate the ratio in percentage
                    ratio = (bounding_box_area / total_area) * 100

                    # Check if the mask passes the filter
                    if ratio >= 17:
                        passed_masks += 1

    # Calculate the percentage of masks passing the filter
    passed_percentage = (passed_masks / total_valid_masks) * 100 if total_valid_masks > 0 else 0

    return passed_percentage, total_valid_masks

# Example usage
input_directory = "./app/mask_prediction"  # Replace with the path to your masks directory
passed_percentage, total_valid_masks = process_masks(input_directory)

print(f"Total masks with at least 5 structures: {total_valid_masks}")
print(f"Percentage of masks passing the filter: {passed_percentage:.2f}%")
star

Tue Feb 11 2025 06:29:47 GMT+0000 (Coordinated Universal Time) https://beleaftechnologies.com/mobile-app-development-company

@kavyamagi #mobileappdevelopmemnt #appdevelopment

star

Tue Feb 11 2025 06:25:25 GMT+0000 (Coordinated Universal Time) https://www.experts-exchange.com/articles/1457/Automate-Exporting-all-Components-in-an-Excel-Project.html

@acassell

star

Tue Feb 11 2025 06:21:35 GMT+0000 (Coordinated Universal Time)

@Rohan@99

star

Tue Feb 11 2025 06:15:41 GMT+0000 (Coordinated Universal Time) https://www.addustechnologies.com/bet365-clone-script

@Seraphina

star

Tue Feb 11 2025 05:59:15 GMT+0000 (Coordinated Universal Time) https://beleaftechnologies.com/crypto-otc-trading-platform-development

@smithtaylor #crypto #trading #development

star

Tue Feb 11 2025 05:29:40 GMT+0000 (Coordinated Universal Time)

@erika

star

Tue Feb 11 2025 05:26:37 GMT+0000 (Coordinated Universal Time)

@Rohan@99

star

Tue Feb 11 2025 05:19:35 GMT+0000 (Coordinated Universal Time)

@Rohan@99

star

Tue Feb 11 2025 04:11:51 GMT+0000 (Coordinated Universal Time)

@davidmchale #grouping #reduce #groupby()

star

Tue Feb 11 2025 03:36:13 GMT+0000 (Coordinated Universal Time)

@davidmchale #grouping #reduce

star

Tue Feb 11 2025 01:08:40 GMT+0000 (Coordinated Universal Time)

@emma1314

star

Tue Feb 11 2025 01:08:07 GMT+0000 (Coordinated Universal Time)

@emma1314

star

Mon Feb 10 2025 23:09:34 GMT+0000 (Coordinated Universal Time)

@FOHWellington

star

Mon Feb 10 2025 16:37:31 GMT+0000 (Coordinated Universal Time) https://www.mongodb.com/try/download/community

@TuckSmith541

star

Mon Feb 10 2025 14:17:12 GMT+0000 (Coordinated Universal Time)

@erika

star

Mon Feb 10 2025 13:48:57 GMT+0000 (Coordinated Universal Time)

@erika

star

Mon Feb 10 2025 13:44:58 GMT+0000 (Coordinated Universal Time)

@erika

star

Mon Feb 10 2025 13:25:39 GMT+0000 (Coordinated Universal Time) https://code.yandex-team.ru/a8e372db-beb5-4959-b040-fe59c8fe6a79

@mark522

star

Mon Feb 10 2025 13:05:55 GMT+0000 (Coordinated Universal Time)

@macie3k #apex #salesforce

star

Mon Feb 10 2025 12:56:24 GMT+0000 (Coordinated Universal Time)

@StephenThevar #react.js

star

Mon Feb 10 2025 11:34:49 GMT+0000 (Coordinated Universal Time) undefined

@alexrw

star

Mon Feb 10 2025 11:34:33 GMT+0000 (Coordinated Universal Time)

@alexrw

star

Mon Feb 10 2025 10:22:21 GMT+0000 (Coordinated Universal Time) https://beleaftechnologies.com/centralized-cryptocurrency-exchange-development

@kavyamagi

star

Mon Feb 10 2025 02:49:32 GMT+0000 (Coordinated Universal Time)

@davidmchale

star

Sun Feb 09 2025 23:30:48 GMT+0000 (Coordinated Universal Time)

@davidmchale #styles #div #object

star

Sun Feb 09 2025 22:50:55 GMT+0000 (Coordinated Universal Time)

@yanBraga

star

Sun Feb 09 2025 21:08:38 GMT+0000 (Coordinated Universal Time)

@jjesal

star

Sun Feb 09 2025 10:36:24 GMT+0000 (Coordinated Universal Time)

@erika

star

Sun Feb 09 2025 08:35:48 GMT+0000 (Coordinated Universal Time) https://adultiptv.net/

@edzukation

star

Sun Feb 09 2025 07:46:24 GMT+0000 (Coordinated Universal Time) https://github.com/vercel/ai-chatbot

@TuckSmith541

star

Sun Feb 09 2025 06:24:31 GMT+0000 (Coordinated Universal Time) https://www.google.com/search?q

@alively78 #javascript

star

Sun Feb 09 2025 05:23:32 GMT+0000 (Coordinated Universal Time)

@erika

star

Sun Feb 09 2025 05:19:54 GMT+0000 (Coordinated Universal Time)

@erika

star

Sun Feb 09 2025 05:18:51 GMT+0000 (Coordinated Universal Time) https://dzone.com/articles/ceate-a-login-system-using-html-php-and-mysql

@isaac #undefined

star

Sun Feb 09 2025 05:07:51 GMT+0000 (Coordinated Universal Time)

@erika

star

Sun Feb 09 2025 05:04:43 GMT+0000 (Coordinated Universal Time)

@erika

star

Sun Feb 09 2025 02:17:48 GMT+0000 (Coordinated Universal Time)

@abdoamr

star

Sat Feb 08 2025 22:13:10 GMT+0000 (Coordinated Universal Time)

@Promakers2611

star

Sat Feb 08 2025 22:09:30 GMT+0000 (Coordinated Universal Time)

@kanatov

star

Sat Feb 08 2025 19:41:16 GMT+0000 (Coordinated Universal Time)

@meherbansingh

star

Sat Feb 08 2025 19:20:55 GMT+0000 (Coordinated Universal Time)

@meherbansingh

star

Sat Feb 08 2025 19:13:23 GMT+0000 (Coordinated Universal Time)

@meherbansingh

star

Sat Feb 08 2025 18:52:38 GMT+0000 (Coordinated Universal Time)

@meherbansingh

star

Sat Feb 08 2025 18:43:26 GMT+0000 (Coordinated Universal Time)

@meherbansingh

star

Sat Feb 08 2025 16:12:42 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/extension/initializing?newuser

@leafaith2009

star

Sat Feb 08 2025 14:03:42 GMT+0000 (Coordinated Universal Time)

@mateusz021202

star

Sat Feb 08 2025 12:11:42 GMT+0000 (Coordinated Universal Time)

@erika

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension