Posts

host

import pandas as pd from datetime import datetime import os # Example DataFrame df_final = pd.DataFrame({     'Name': ['Alice', 'Bob', 'Charlie'],     'Age': [25, 30, 35],     'City': ['New York', 'Los Angeles', 'Chicago'] }) # Generate today's date in 'YYYY-MM-DD' format today = datetime.now().strftime("%Y-%m-%d") # Create a dynamic filename filename = f"{today}_data.csv" # Network drive path (Windows) network_folder = r"\\network_drive\shared_folder" # Full path to save the file full_path = os.path.join(network_folder, filename) # Save DataFrame to CSV try:     df_final.to_csv(full_path, index=False)     print(f"File saved successfully to {full_path}") except Exception as e:     print(f"Error saving file: {e}")

requirement.txt

import os # Path to the directory containing the downloaded packages package_dir = '/path/to/my_packages' # List to hold the package names and versions requirements = [] # Iterate over all files in the directory for filename in os.listdir(package_dir):     # Process .whl files     if filename.endswith('.whl'):         # Split the filename by dashes and underscores to extract the package name and version         parts = filename.split('-')         package_name = parts[0]         version = parts[1]         requirements.append(f'{package_name}=={version}')     # Process .tar.gz files     elif filename.endswith('.tar.gz'):         # Remove the .tar.gz and split the filename by dashes to extract the package name and version         parts = filename.replace('.tar.gz', '').split('-')         packa...

Optimizing Tableau Dashboard Performance in Web Applications: Strategies for Caching and Faster Load Times"

  Caching a Tableau dashboard that has been rendered within an iframe is difficult, but here are some suggestions you can look into to make things better and seem like the dashboard is cached: Browser Caching Make sure the server is configured to cache Tableau dashboard resources by using appropriate cache headers for the HTML, CSS, JS, and image resources that the dashboard uses. The browser will cache all those resources after the first load, thus making load times shorter for revisits. Via a Reverse Proxy You can configure a reverse proxy in front of your Tableau server, for example, Nginx or Apache. This reverse proxy can cache the dashboard resources; thus, on subsequent hits for the same dashboard, it serves that copy from the cache without going again to Tableau for the data. This setup drastically improves load times on successive visits. Loading the Dashboard You could preload the Tableau dashboard in the background of the application flow before the user even navigates to...

T

 # List of allowed fund names keep_fund_names = ["A", "B", "C", "D"] # Filter the funds to include only the allowed names keep_fund_names = {name: id for name, id in fund_names.items() if name in keep_fund_names}

Steps to create SSH key from git bash

Generating an SSH key in OpenSSH involves a few simple steps. Here’s how you can do it: 1. Open a Terminal If you're on Linux or macOS, you can use the built-in terminal. On Windows, you can use the Command Prompt, PowerShell, or Git Bash if you have Git installed. 2. Generate the SSH Key Pair Run the following command: bash Copy code ssh-keygen -t rsa -b 4096 -C "your_email@example.com" Here’s what each option means: -t rsa : Specifies the type of key to create, in this case, RSA. -b 4096 : Specifies the number of bits in the key, 4096 bits is a good choice for strong encryption. -C "your_email@example.com" : Adds a label to the key, usually your email address. 3. Choose a File Location After running the above command, you'll be prompted to choose a location to save the key. By default, it will be saved in ~/.ssh/id_rsa (on Linux or macOS) or in C:\Users\YourUserName\.ssh\id_rsa (on Windows). Press Enter to accept the default location, or specify a diff...

p

 import requests import json from requests.auth import HTTPBasicAuth # Define the GraphQL endpoint url = 'https://graphql-demo.mead.io/' # Define user ID and password for authentication user_id = 'your_user_id' password = 'your_password' # Define the GraphQL query with date range filter query = """ {   events(filter: { startDate: { gte: "2023-01-01" }, endDate: { lte: "2023-01-31" } }) {     id     name     date     location   } } """ # Perform the query with authentication response = requests.post(url, json={'query': query}, auth=HTTPBasicAuth(user_id, password)) data = response.json() # Print the result print(json.dumps(data, indent=2))

Last 30 days

SELECT      MIN(CalendarDate) AS StartDate FROM (     SELECT          TOP 30          DATEADD(DAY, -n, CAST(GETDATE() AS DATE)) AS CalendarDate     FROM (         SELECT              ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS n         FROM              sys.objects     ) AS Numbers     WHERE          DATEPART(WEEKDAY, DATEADD(DAY, -n, CAST(GETDATE() AS DATE))) NOT IN (1, 7) -- 1 = Sunday, 7 = Saturday     ORDER BY          CalendarDate DESC ) AS Last30WorkingDays;