Skip to content

Instantly share code, notes, and snippets.

View Borda's full-sized avatar
👻
OSS Shepherd

Jirka Borovec Borda

👻
OSS Shepherd
View GitHub Profile
@Borda
Borda / archive-repos.sh
Created May 12, 2026 09:04
Takes one or more CSV files as positional arguments, extracts repo slugs from the first column, deduplicates across all inputs, and archives each via gh repo archive --yes. Runs in dry-run mode by default — set APPLY=1 to actually archive, since GitHub's API has no bulk un-archive operation. Each archive attempt is logged to archive-log.csv with…
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# archive-repos.sh
#
# Archive GitHub repos listed in one or more CSV files. Reads the first
# column (repo slug) of each CSV, deduplicates across files, and calls
# `gh repo archive --yes` on each.
#
# Defaults to DRY RUN — prints what would happen but doesn't touch anything.
# Set APPLY=1 to actually archive. Note: GitHub's API does NOT support
@Borda
Borda / list-inactive-repos.sh
Last active May 12, 2026 14:01
Scans an org or user account for repositories with no push activity since a configurable cutoff date (default: Jan 1 2025), producing a triage-ready CSV of archival candidates. It uses a single gh repo list call to fetch pushedAt for all non-archived repos, computes days since last push, and sorts the output from least stale to most stale so you…
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# list-inactive.sh
#
# Find repos in an org/user account with no push activity since a cutoff date,
# so they're candidates for archiving.
#
# Uses the pushedAt field from a single GitHub API call — fast (one request),
# no per-repo lookup. Computes days since last push and sorts the output
# from least stale (recent) to most stale (oldest).
@Borda
Borda / list-clean-fork-repos.sh
Last active May 12, 2026 14:02
Scans an org or user account for forked repositories that have never diverged from their upstream, making them obvious candidates for archival. For each fork it fetches the upstream and compares default branches via the GitHub compare API; anything with ahead_by == 0 is written to clean-forks.csv. The script is resilient to per-repo API failures…
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# list-clean-forks.sh
#
# Find forks in an org/user account that never diverged from their upstream,
# so they're safe to archive or delete.
#
# For each non-archived fork, compares the fork's default branch against the
# upstream's default branch via the GitHub compare API. A fork is "clean" if
# ahead_by == 0 — i.e., zero commits on top of upstream.
@Borda
Borda / test.py
Created July 29, 2024 23:15
Image classification - StanfordCars
import glob
import torch
import scipy
import random
import matplotlib.pyplot as plt
from PIL import Image
from torchvision import transforms
from train import LitClassification, ClassificationData
# load test association to the numerical labels
@Borda
Borda / face_detection.py
Last active July 30, 2024 06:23
Object detection - WIDERFace
import torch
import torch.optim as optim
from torch.utils.data import DataLoader
from torchvision import models, datasets, ops
from torchvision.transforms import v2 as transforms
import pytorch_lightning as pl
# Step 1a: Define the transform
transform = transforms.Compose([
@Borda
Borda / ci-update-submodules.yml
Last active October 30, 2023 15:12
Automated git-submodule updates via PR
name: Update git submodules
on:
pull_request:
branches: ["main"]
paths:
- ".github/workflows/ci-update-submodules.yml"
schedule:
# on Sundays
- cron: "0 0 * * 0"
@Borda
Borda / failing-build.yml
Last active September 20, 2023 09:08
blog_retry-failed-checks
name: Sample build
on:
- push
- pull_request
- workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
@Borda
Borda / blog_predict-plant.py
Created September 13, 2021 12:04
Simple Submitting Kernel to Kaggle Competition
preds = []
# move model to GPU for faster inference and set evaluation
model.cuda().eval()
for imgs, names in dm.test_dataloader():
# for the prediction we do not need gradients
with torch.no_grad():
onehots = model(imgs.cuda()).cpu()
# aggregate particular preditions
for oh, name in zip(onehots, names):
lbs = dm.onehot_to_labels(oh)
@Borda
Borda / blog_run-plant-from-package.py
Created September 4, 2021 19:18
Converting Kaggle Training Notebooks to Shareable Code
from pytorch_lightning import Trainer
from kaggle_plantpatho.data import PlantPathologyDM
from kaggle_plantpatho.models import LitResnet, MultiPlantPathology
# create DataModule with training/validation split
dm = PlantPathologyDM(batch_size=98)
# initialize ResNet50 network
net = LitResnet(arch='resnet50', num_classes=dm.num_classes)
# initialize PL module with ResNet50
model = MultiPlantPathology(model=net, lr=6e-4)
fig = plt.figure(figsize=(3, 7))
for imgs, lbs in dm.val_dataloader():
# some stats about the batch - label distribution
print(f'batch labels: {torch.sum(lbs, axis=0)}')
print(f'image size: {imgs[0].shape}')
# similar as above show just first images from the batch
for i in range(3):
ax = fig.add_subplot(3, 1, i + 1, xticks=[], yticks=[])
ax.imshow(np.rollaxis(imgs[i].numpy(), 0, 3))
ax.set_title(lbs[i])