Skip to content

Instantly share code, notes, and snippets.

@recalde
recalde / perf-test.sh
Created April 9, 2025 15:19
perf-test.sh
#!/bin/bash
set -e
echo "[Startup] Measuring host compute power..."
# CPU Test
START=$(date +%s%N)
for i in {1..100000}; do echo "$i" | sha256sum > /dev/null; done
END=$(date +%s%N)
CPU_MS=$(( (END - START) / 1000000 ))
@recalde
recalde / cert-check.py
Last active April 4, 2025 11:37
Certificate Check
import ssl
import socket
import requests
from urllib.parse import urljoin
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from bs4 import BeautifulSoup
import hashlib
def fetch_ssl_chain(domain, port=443):
@recalde
recalde / clean-pom.sh
Last active April 1, 2025 14:45
Clean Maven POM XML Files
#!/bin/bash
set -e
MAVEN_VERSION=3.9.6
MAVEN_DIR="$HOME/.maven/apache-maven-$MAVEN_VERSION"
MAVEN_BIN="$MAVEN_DIR/bin/mvn"
echo "=== Checking Java ==="
if ! command -v java >/dev/null 2>&1; then
@recalde
recalde / query.sql
Last active March 28, 2025 17:38
Table looping query
-- Create a temporary table with a JSON column for grouping variables.
CREATE TEMP TABLE temp_counts (
group_vars json, -- holds grouping variables (e.g., calc_date, formatted_date, etc.)
count_result integer
) ON COMMIT DROP;
DO $$
DECLARE
begin_date date := '2023-01-01'; -- Replace with your desired begin date.
end_date date := '2023-01-10'; -- Replace with your desired end date.
@recalde
recalde / Route.cs
Last active January 13, 2025 14:44
k8s model for OpenShift route
using k8s;
using k8s.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace OpenShiftModels
{
public class Route : IKubernetesObject<V1ObjectMeta>, ISpec<RouteSpec>
{
[JsonProperty("apiVersion")]
import tkinter as tk
from tkinter import filedialog, messagebox
import simplekml
def add_coordinate():
if len(coordinates) < 10:
lat = lat_entry.get()
lon = lon_entry.get()
diameter = diameter_entry.get()
import psycopg2
import pandas as pd
from psycopg2 import sql
from concurrent.futures import ThreadPoolExecutor, as_completed
import threading
# Database connection details
DB_CONFIG = {
"host": "localhost",
"dbname": "your_database",
@recalde
recalde / KubernetesPodLogFileWriterService.cs
Created November 14, 2024 03:47
Kubernetes Pod Log Watcher
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
public class KubernetesPodLogFileWriterService : IHostedService, IDisposable
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using k8s;
using k8s.Models;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
public class KubernetesPodWatcherService : BackgroundService
@recalde
recalde / Program.cs
Created November 14, 2024 03:19
OpenShift OAuth
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(options =>
{
options.Authority = "https://<openshift-auth-server>";