Skip to content

Instantly share code, notes, and snippets.

@yig
yig / sig2text.py
Last active May 2, 2024 05:00
Converts a PDF file assumed to be a two-column ACM or CGF article to text. Ignores reviewer red numbering.
'''
# Author: Yotam Gingold <yotam@yotamgingold.com>
# License: CC0
# URL: <https://gist.github.com/yig/d55eba6221997d12d94fe6976a357edd>
## About
Converts a PDF file assumed to be a two-column ACM article to text. Ignores reviewer red numbering.
## Install
@yig
yig / JavaScript reference.md
Last active April 21, 2024 23:36
An overview of JavaScript best practices. Geared towards someone with a C/C++/Java/Python background.

JavaScript reference for non-JavaScript programmers

Author: Yotam Gingold
License: Public Domain (CC0)

This document is intended as a reference or introduction to JavaScript for someone familiar with a language like C/C++/Java or Python. It follows best practices and gathers the scattered wisdom from matny stackoverflow questions and in-depth JavaScript essays. It relies on no external libraries.

@yig
yig / parametric_shape.py
Created April 11, 2024 16:03
A port of "Retrieval on Parametric Shape Collections" [Schulz et al. 2017]'s public code release to Python.
# A port of "Retrieval on Parametric Shape Collections" [Schulz et al. 2017]'s public code release to Python.
# Project website: <https://people.csail.mit.edu/aschulz/paramShapeRetrieval/index.html>
# This code was created by manually correcting the output of ChatGPT.
import numpy as np
class ParametricShape:
EPSILON_CONST = 1e-7
def __init__(self, filename=None, nParameters=None, defaultParameters=None, triangles=None,
@yig
yig / update_mactex.md
Created August 9, 2018 21:23
Instructions for updating MacTeX's BasicTeX every year

Once you get the dreaded error message that tlmgr won't install any new packages, it's time to upgrade to the latest texlive.

  1. Save list of currently installed packages:

     tlmgr list --only-installed > previously_installed_texlive_packages.txt
    
  2. Download and install the latest BasicTex.pkg: http://www.tug.org/mactex/

  3. Save list of default packages:

@yig
yig / lch_histo.py
Last active March 26, 2024 13:50
Make an Lch histogram from an image. Try `lch_histo.py --wheel` and then `lch_histo.py --histofancy image.png wheel.png`.
#!/usr/bin/env python3
'''
Author: Yotam Gingold <yotam (strudel) yotamgingold.com>
License: Public Domain [CC0](http://creativecommons.org/publicdomain/zero/1.0/)
On GitHub as a gist: https://gist.github.com/yig/2de8f832b96f6ddffd788bb9c3e72ccf
'''
## pip install scikit-image drawsvg
@yig
yig / wrapfigure_without_whitespace.tex
Created May 17, 2016 04:39
Eliminate white space around wrapfigure environments in LaTeX.
%% The typical answer for how to eliminate white space in wrapfigure doesn't work for me (I'm using a SIGGRAPH style sheet):
%% http://tex.stackexchange.com/questions/111393/too-much-space-around-wrap-figure
%% Instead, let's just offset the image.
%% The horizontal white space is \columnsep and the vertical white space is \intextsep.
%% Subtract them from the column width and offset the image accordingly.
%% How to move an image:
%% http://tex.stackexchange.com/questions/107340/how-to-shift-graphics-adjust-placement-of-figure-with-includegraphics
\begin{wrapfigure}[11]{R}{1in - .75\columnsep}
%\centering
\vspace{-\intextsep}
@yig
yig / autonirf.py
Last active January 30, 2024 04:28
Download 2023 data from the Indian Ministry of Education (MoE) National Institute Ranking Framework (NIRF) for all categories
## All the categories on <https://www.nirfindia.org/2023/Ranking.html>
## pip install requests beautifulsoup4
## Author: Yotam Gingold <yotam@yotamgingold.com>
## License: CC0
## URL: <https://gist.github.com/yig/bc29935d22845dc02bf5000bcf18ba25>
# from pathlib import Path
import csv
import os
@yig
yig / feedgen.py
Last active December 20, 2023 03:12
Create a valid podcast RSS feed from a base URL and a list of files.
#!/usr/bin/env python3
'''
Author: Yotam Gingold <yotam (strudel) yotamgingold.com>
License: Public Domain [CC0](http://creativecommons.org/publicdomain/zero/1.0/)
On GitHub as a gist: https://gist.github.com/yig/4784a86c1343d2bed789dd243ce980fc
'''
'''
Example:
@yig
yig / matrix derivatives.txt
Last active December 1, 2023 19:39
matrix derivatives via frobenius norm
matrix derivatives via Frobenius norm
# Automatic matrix derivatives: http://www.matrixcalculus.org/
# A good primer on basic matrix calculus: https://atmos.washington.edu/~dennis/MatrixCalculus.pdf
# The Matrix Reference Manual: http://www.ee.ic.ac.uk/hp/staff/dmb/matrix/intro.html#Intro
# Trying to understand the derivative of the inverse: https://math.stackexchange.com/questions/1471825/derivative-of-the-inverse-of-a-matrix
# Derivative of the pseudoinverse:
https://math.stackexchange.com/questions/2179160/derivative-of-pseudoinverse-with-respect-to-original-matrix
https://mathoverflow.net/questions/25778/analytical-formula-for-numerical-derivative-of-the-matrix-pseudo-inverse
@yig
yig / zoom-defang.sh
Last active September 11, 2023 11:54
Defang the macOS Zoom Installer. Extracts a .app that can be dragged to /Applications.
#!/bin/sh
## Author: Yotam Gingold
## License: CC0 (public domain) https://creativecommons.org/share-your-work/public-domain/cc0/
## URL: https://gist.github.com/yig/af5bbb054bb9c4de39abc9156e6863e1/
## Download the latest Zoom installer.
echo "==> Downloading the latest Zoom installer."
cd ~/Downloads
## Intel: