Skip to content

Instantly share code, notes, and snippets.

@fortran01
fortran01 / report_summary.csv
Created October 3, 2023 17:31
Report summary CSV from ora2pg
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Total Number;Total Invalid;Total Estimated cost;Human days cost;Migration level
74;0;249.90;6 person-day(s);B-5
@fortran01
fortran01 / report.csv
Last active October 3, 2023 17:39
Sample CSV report from `docker run --name ora2pg -it --rm -v /home/ubuntu/ora2pg/config:/config -v /home/ubuntu/ora2pg/data:/data ora2pg ora2pg -t SHOW_REPORT --estimate_cost --cost_unit_value 10 --dump_as_csv -c /config/ora2pg.conf`
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 1 column, instead of 5. in line 4.
Object;Number;Invalid;Estimated cost;Comments
DATABASE LINK;0;0;0.00;Database links will be exported as SQL/MED PostgreSQL's Foreign Data Wrapper (FDW) extensions using oracle_fdw.
FUNCTION;5;0;54.60;Total size of function code: 8853 bytes.
GLOBAL TEMPORARY TABLE;0;0;0.00;Global temporary table are not supported by PostgreSQL and will not be exported. You will have to rewrite some application code to match the PostgreSQL temporary table behavior.
INDEX;8;0;1.00;0 index(es) are concerned by the export, others are automatically generated and will do so on PostgreSQL. Bitmap will be exported as btree_gin index(es). Domain index are exported as b-tree but commented to be edited to mainly use FTS. Cluster, bitmap join and IOT indexes will not be exported at all. Reverse indexes are not exported too, you may use a trigram-based index (see pg_trgm) or a reverse() function based index and search. Use 'varchar_pattern_ops', 'text_pattern_ops' or 'bpchar_pattern_ops' operators in your indexes to improve search with the
#!/bin/bash
# Install required packages
pip install pyvmomi
pip install pandas
# Create the Python script file
cat > vm_performance.py << EOL
import pandas as pd
from pyVim.connect import SmartConnectNoSSL
Yes, you can get historical CPU and memory utilization metrics for an ESXi host using vSphere. You can use the vSphere Client to visualize and set alarms on key metrics and logs from your environment[2]. Here's how to access the historical CPU and memory utilization metrics for an ESXi host:
1. Use the vSphere client to connect to a vCenter Server instance.
2. Navigate to either the Hosts And Clusters or the VMs And Templates inventory view.
3. In the inventory tree, click on the desired ESXi host.
4. Click the Performance tab, and switch to the Advanced view.
5. Click the Chart Options link.
6. In the Customize Performance Chart dialog box, select the CPU or Memory resource type and the desired time range.
7. Select the desired counters, such as CPU Usage (Average) for CPU utilization or Memory Usage (Average) for memory utilization[3].
8. Click OK to apply the chart settings and return to the Performance tab.
@fortran01
fortran01 / install_scheduled_task.sh
Last active September 22, 2023 16:43
Install machine-stats scheduled task in *nix
#!/bin/bash
# Execute the command `tidal doctor` and check for the required strings
output=$(tidal doctor)
required_strings=("Tidal Accelerator API connect OK" "Pull from registry OK" "Version is up to date" "Tidal Accelerator API connection configured OK")
for string in "${required_strings[@]}"; do
if [[ ! $output =~ $string ]]; then
echo "Error: '$string' not found in the output of 'tidal doctor'"
exit 1
@fortran01
fortran01 / update_ip.sh
Created September 22, 2023 15:06
Updates the IP in Ubuntu based on netplan
#!/bin/bash
echo "Available network interfaces:"
ip link show | awk -F: '$0 !~ "lo|vir|wl|^[^0-9]"{print $2;getline}'
read -p "Choose the network interface to modify (e.g., enp0s3): " INTERFACE
echo "Available netplan configuration files:"
ls /etc/netplan
read -p "Choose the netplan configuration file to modify (e.g., 01-netcfg.yaml): " NETPLAN_FILE
@fortran01
fortran01 / fetch_ts.py
Last active January 8, 2024 19:07
Fetch machine-stats time-series data from the Tidal platform
import json
import os
import pandas as pd
testing_flag = False # Set to True to only fetch data for the first two servers with machine stats
def list_servers_without_machine_info(df_servers):
df_servers_without_machine_info = df_servers[
df_servers['ram_allocated_gb'].isna()
| df_servers['storage_allocated_gb'].isna()
from time import sleep
import requests
import datetime
# Get the store open dates for the next n days
def get_open_dates(start_date, store_id, num_days):
url = f"https://www.kaltire.com/on/demandware.store/Sites-Kaltire-Site/default/Appointment-GetStoreOpenDatesByDate?startDate={start_date}&storeID={store_id}&numDays={num_days}&serviceId=2731"
headers = {
'authority': 'www.kaltire.com',
'accept': 'application/json, text/javascript, */*; q=0.01',
@fortran01
fortran01 / scraper.sh
Last active March 31, 2023 18:03
Scrape SickKids research site and email
(curl 'https://research4kids.research.sickkids.ca/findaclinicalresearchstudy' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Origin: https://research4kids.research.sickkids.ca' \
-H 'Referer: https://research4kids.research.sickkids.ca/findaclinicalresearchstudy' \
--data-raw 'selectedResearchTopics=&researcherId=&departmentId=&searchKeyWord=Allergy&search=Search' \
--compressed > output.html \
&& perl -i -pe 's|(?<=href=")(/[^"]+)|https://research4kids.research.sickkids.ca$1|g' output.html \
&& echo -e "To: your@email.com\nFrom: your@email.com\nSubject: Clinical Research Study Results\nMIME-Version: 1.0\nContent-Type: text/html\n\n$(cat output.html)") \
| /opt/homebrew/bin/msmtp -a gmail your@email.com

If the source computer (the one initiating the WinRM access) is not domain-joined, but the target computer is domain-joined, you can still use WinRM to access the target computer with domain credentials.

In this scenario, you need to ensure that the following configurations are in place:

  1. Make sure WinRM service is enabled and running on the target computer. On the target computer, open an elevated PowerShell prompt and run:
Enable-PSRemoting -Force