Skip to content

Instantly share code, notes, and snippets.

View snehankekre's full-sized avatar

Snehan Kekre snehankekre

View GitHub Profile
@snehankekre
snehankekre / ocr.swift
Last active November 4, 2026 10:57
OCR a PDF on a Mac with Apple's Vision framework in 20 lines of Swift. No build step, and nothing leaves the machine. MIT.
// OCR a PDF on this Mac with Apple's Vision framework; nothing leaves the machine. Prints text page by page.
// Usage: swift ocr.swift <file.pdf>
// Copyright (c) 2026 Snehan Kekre. SPDX-License-Identifier: MIT
import PDFKit
import Vision
guard CommandLine.arguments.count == 2 else { fputs("Usage: swift ocr.swift <file.pdf>\n", stderr); exit(2) }
guard let doc = PDFDocument(url: URL(fileURLWithPath: CommandLine.arguments[1])) else { fputs("Can't open \(CommandLine.arguments[1]) as a PDF\n", stderr); exit(1) }
for i in 0..<doc.pageCount {
guard let page = doc.page(at: i) else { continue }
@snehankekre
snehankekre / st_local_storage.py
Last active March 6, 2026 18:55 — forked from sfc-gh-jcarroll/st_local_storage.py
Local storage access in Streamlit - st_local_storage
# NOTE: This feature uses browser local storage! AKA it stores data on a viewer's
# machine. This may have privacy and compliance implications for your app. Be sure
# to take that into account with any usage.
import json
import time
import uuid
from typing import Any, Optional
from streamlit.time_util import time_to_seconds
@snehankekre
snehankekre / vid2gif.sh
Created May 11, 2022 18:13
Video to GIF
#!/bin/sh
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
palette="/tmp/palette.png"
filters="fps=15,scale=1000:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
set.seed(42)
##############
# QUESTION 1 #
##############
library(tidyverse)
# Generating 998 observations
@snehankekre
snehankekre / CS112_3.1_gelmanhillsimulation.R
Created September 23, 2019 23:36
CS112_3.1_gelmanhillsimulation.R
library(arm)
library(Matching)
library("ggplot2")
data(lalonde)
ggplot(lalonde, aes(x=age, y=re78)) +
geom_point(color='#2980B9', size = 4) +
geom_smooth(method=lm, color='#2C3E50')
@snehankekre
snehankekre / CS112_Assignment_1.ipynb
Created September 22, 2019 13:27
CS112_Assignment_1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am snehankekre on github.
  • I am snehankekre (https://keybase.io/snehankekre) on keybase.
  • I have a public key whose fingerprint is 2701 FD9B 6033 44D8 512E 77E2 0B90 03A2 7A54 CB3E

To claim this, I am signing this object: