Skip to content

Instantly share code, notes, and snippets.

View ksikka's full-sized avatar

Karan Sikka ksikka

View GitHub Profile
@ksikka
ksikka / RANDOM_PDF
Last active June 11, 2025 07:11
Open a random PDF to a random page
Uses `evince` as PDF viewer (gnome in linux), you will need to change it for mac.
# 1. Install Python dependencies:
pip install:
* PyPDF2
* pandas
# 2. Generate the CSV of PDF files and their page counts.
@ksikka
ksikka / predict_frames.py
Last active December 10, 2024 19:00
a little utility to predict a folder of frames
import argparse
import os
import typing
from pathlib import Path
_default_annotation_likelihood_threshold = 0.9
def main():
parser = argparse.ArgumentParser(
@ksikka
ksikka / gist:51c5eb8a1b0ed060cc079cb4afe9a260
Last active October 7, 2024 20:56
out: master, 1 process
(lp) ksikka@DESKTOP-KF26FAO:~/lightning-pose$ time python scripts/train_hydra.py
[2024-10-07 16:56:08,660][HYDRA] /home/ksikka/miniconda3/envs/lp/lib/python3.10/site-packages/hydra/_internal/hydra.py:119: UserWarning: Future Hydra versions will no longer change working directory at job runtime by default.
See https://hydra.cc/docs/1.2/upgrades/1.1_to_1.2/changes_to_job_working_dir/ for more information.
ret = run_job(
Our Hydra config file:
--------------------
data parameters
--------------------
image_resize_dims: {'width': 256, 'height': 256}
@ksikka
ksikka / DfsReference.swift
Last active May 1, 2018 03:44
Reference implementation against which to test a homework problem. Obfuscated and misleading so there's no use in trying to understand how it works.
// This is NOT recursive dfs, but the answer should be the same.
// Use it to test if your code is working, by comparing our function's output with
// this function's output.
func dfsReferenceImplementation(at: Node, to: Node) -> [Node] {
var y: [Int: Node] = [Int: Node]()
var x: [(Node, Node)] = []
x.append((at, at))
while x.count > 0 {
let (n1, n2) = x.removeFirst()
y[n1.id] = n2
@ksikka
ksikka / build.html
Last active April 24, 2018 13:07
Tool for building a graph on top of an image. http://ctrl-c.club/~ksikka/graphbuilder.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Graph builder</title>
<style>
.arena {
position: relative;
}
//
// Try running in http://online.swiftplayground.run/
//
import Foundation
// Given a Person class (struct is like class with some differences you can read about).
struct Person: Equatable {
var id: Int
var favoriteColor: String
// soln 1: scan from left to right, and keep track of whether or not it's xybalanced so far
public boolean xyBalance(String str) {
boolean isXyBalanced = true;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == 'x') isXyBalanced = false;
if (str.charAt(i) == 'y') isXyBalanced = true;
}
return isXyBalanced;
}
function parseHistoryDate(rawString) {
var dtstr = rawString.replace('HST','UTC-1000').replace('HDT','UTC-900').replace('AST',"UTC-400");
const dt = new Date(dtstr);
if (!isFinite(dt)) throw new Error('assertion error');
var m;
var tzoffsets = {
'AST': -4,
'EST': -5,
func parseNodesPhase1(_ rawNodes: [[Double]]) -> [Node] {
var nodes: [Node] = []
for rn in rawNodes {
nodes.append(Node(id: Int(rn[0]), x: rn[1], y:rn[2]))
}
return nodes
}
class Node {
let id: Int
let x: Double
let y: Double
var neighbors: [Node] = []
init(id: Int, x: Double, y: Double) {
self.id = id
self.x = x
self.y = y