Skip to content

Instantly share code, notes, and snippets.

View kamath's full-sized avatar
😳
swaggerific

Anirudh Kamath kamath

😳
swaggerific
View GitHub Profile
@ttomasz
ttomasz / google_sheets_example.py
Created May 24, 2023 19:16
Query Google Spreadsheet directly using Duckdb and Fabduckdb extension
import duckdb
import fabduckdb
import gspread
import pandas as pd
def read_gsheet(service_account_json_path: str, gsheets_url: str, worksheet_name: str) -> pd.DataFrame:
gc = gspread.service_account(filename=service_account_json_path, scopes=gspread.auth.READONLY_SCOPES)
gsheet = gc.open_by_url(gsheets_url)
data = gsheet.worksheet(worksheet_name).get_all_records()
@kamath
kamath / .vimrc
Created September 2, 2021 17:45
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdtree'
call plug#end()
let g:airline_powerline_fonts = 1
set rtp+=/usr/local/opt/fzf
let g:NERDTreeDirArrowExpandable = '▸'
@zhanwenchen
zhanwenchen / Install NVIDIA Driver and CUDA.md
Last active March 13, 2024 23:42 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA CUDA 9.0 on Ubuntu 16.04.4 LTS
@urschrei
urschrei / minimum_polygon_distance.md
Last active November 29, 2021 22:18
An algorithm for determining the minimum distance between two non-convex polygons

Adapted from https://www.quora.com/How-do-you-compute-the-distance-between-two-non-convex-polygons-in-linear-time/answer/Tom-Dreyfus

Calculating the Minimum Distance Between Two Non-Convex Polygons

See Amato, Nancy M (1994) for details of the difference between separation (sigma: σ) and closest visible vertex (CVV).

Refer to P and Q as the two polygons with n and m vertices, respectively.
For the purposes of this discussion, a key insight is that it is enough to find the closest edge to each vertex in order to compute the minimum separation between P and Q.
This means iterating over all vertices, and finding a nearest neighbour. Thus, a time complexity in O((m + n) * log(m * n)) should be expected.