Skip to content

Instantly share code, notes, and snippets.

View jac18281828's full-sized avatar
🦌

John Cairns jac18281828

🦌
View GitHub Profile
@jac18281828
jac18281828 / parquet_schema.py
Created November 25, 2025 17:26
dump a parquet file and try to interpret its schema
#!/usr/bin/env python3
"""
parquet_schema.py — Quick column (schema) lister for Parquet files or partitioned folders.
Usage:
python parquet_schema.py /path/to/file.parquet
python parquet_schema.py /path/to/folder # infers dataset schema across files
python parquet_schema.py /path --raw # print raw Arrow schema
python parquet_schema.py /path --json # JSON output
@jac18281828
jac18281828 / find_longest_gap.py
Created November 18, 2025 23:56
find time gap in log files
#!/usr/bin/env python3
import argparse
import re
from datetime import datetime
# Regex to strip ANSI escape sequences (colors, cursor moves, etc.)
ANSI_ESCAPE_RE = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
# Timestamp format for lines like:
# 2025-11-18T21:52:39.117949Z
@jac18281828
jac18281828 / set_mtime_to_creation.sh
Created October 17, 2025 01:36
set mtime to creation time for photos
#!/bin/bash
# set_mtime_to_creation.sh
# Sets each file's modification time to its creation time (macOS / BSD)
shopt -s nullglob
for file in *; do
# Skip directories
if [ -d "$file" ]; then
continue
@jac18281828
jac18281828 / aurora.ts
Created July 17, 2025 15:48
Create Aurora Postgress Serverless Instance
# Define Aurora Serverless v2 PostgreSQL cluster
self.aurora_cluster = rds.DatabaseCluster(
self,
"AuroraServerlessCluster",
engine=rds.DatabaseClusterEngine.aurora_postgres(version=rds.AuroraPostgresEngineVersion.VER_16_6),
writer=rds.ClusterInstance.provisioned(
"writer", instance_type=ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.LARGE)
),
serverless_v2_min_capacity=0, # allow auto pause
serverless_v2_max_capacity=8,
@jac18281828
jac18281828 / acmteam.py
Created May 21, 2025 19:11
hackerrank acmTeam
from typing import List, Tuple
def bitstrToInt(bs: str) -> int:
"""Convert bitstring bs to an integer"""
return int(bs, 2)
def countBits(d: int) -> int:
"""Count the bits in d and return that value"""
@jac18281828
jac18281828 / timeinwords.py
Created May 21, 2025 16:37
hacker rank timeInWords
class TimeInWordsError(Exception):
pass
def numberToString(d: int) -> str:
"""Number to string"""
number_look = {
1: "one",
2: "two",
@jac18281828
jac18281828 / queensattackii.ts
Created May 20, 2025 19:47
queens attack hackerrank
const MOVES = [[1, 1], [1, 0], [1, -1], [0, 1], [0, -1], [-1, 1], [-1, 0], [-1, -1]]
function queensAttack(n: number, k: number, r_q: number, c_q: number, obstacles: number[][]): number {
// Write your code here
let spaces = 0
const obstacleSet = new Set(obstacles.map(o => `${o[0]},${o[1]}`))
const isvalidpos = (r: number, c: number) => {
return r > 0 && r <= n && c > 0 && c <= n
@jac18281828
jac18281828 / birds.ts
Created May 20, 2025 19:10
Migratory Birds Hackerrank
function migratoryBirds(arr: number[]): number {
// Write your code here
let birdCount: { [key: number]: number} = {}
let maxId = 0
let maxIdCount = 0
arr.forEach(bid => {
if (birdCount[bid] !== undefined) {
birdCount[bid]++
@jac18281828
jac18281828 / eightqueen.py
Created May 12, 2025 23:01
eight queens problem hacker rank
from typing import Tuple
class InvalidGame(Exception):
def __init__(self, message):
super().__init__(message)
class Board:
"""N x N chessboard"""
@jac18281828
jac18281828 / mergelists.py
Last active May 12, 2025 02:17
Hackerrank Merged two sorted linked lists
import sys
class SinglyLinkedListNode:
def __init__(self, node_data):
self.data = node_data
self.next = None
class SinglyLinkedList: