Instantly share code, notes, and snippets.

View gallery_simple.py
View update_mactex.md

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:

View matrix derivatives.txt
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
View httpserver.jl
#=
Author: Yotam Gingold <yotam (strudel) yotamgingold.com>
License: Public Domain [CC0](http://creativecommons.org/publicdomain/zero/1.0/)
Description: A simple static file server written in Julia. Listens on localhost port 8000. Doesn't serve files outside current working directory (unless symlinked). Doesn't print directory listings.
URL: https://gist.github.com/yig/f65e86b7730019d4060449f24342fcb4
=#
using HttpServer
using Base.Filesystem
View controlc_pipeline.py
# Run with
## python -u controlc_pipeline.py | tee foo.out
# Then press control-C.
## You never see the output without an IOError handler,
## because an IOError is generated (stdout went away) before a KeyboardInterrupt.
## You could catch the IOError and redirect stdout manually. UPDATE: That doesn't seem to work.
## Or you could tell `tee` to ignore SIGINT and exit this program gracefully:
# python -u controlc_pipeline.py | tee -i foo.out
from __future__ import print_function, division
View DMAT2MATLAB.py
#!/usr/bin/python
# Convert a libigl DMAT to a Matlab .mat file.
# 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/0fb7fe73b2ce914c4b1d6de3b4e4ba01
from __future__ import print_function, division
from numpy import *
View get_icloud_note
#!/bin/bash
# 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/76e87324ca1e9c754e8f28a8ef294dd0
usage()
{
echo 1>&2 "Usage:" "$0" '<Notes.app note name>'
exit -1
View trim-together.py
#!/usr/bin/env python
'''
Author: Yotam Gingold <yotam (strudel) yotamgingold.com>
License: Public Domain [CC0](http://creativecommons.org/publicdomain/zero/1.0/)
Description: Applies imagemagick's -trim to a set of images, but applies the same crop to all of them together (making sure to cut nothing untrimmable off from any).
URL: https://gist.github.com/yig/7770ec597c595ae4bf1d0de4ca5a65cf
'''
from __future__ import print_function, division
View PNG colorspace experiments
## Make a 5 pixel gradient PNG with no header: 0, 64, 128, 191, 255.
## Save the values with PIL (Python Image Library). PIL does not store a header.
python make_png.py
'''
from numpy import *
from PIL import Image
N = 5
arr = zeros( (1,N,3) )
arr[:] = linspace(0,1,N)[newaxis,:,newaxis]
View cffi_asarray.py
'''
Author: Yotam Gingold <yotam (strudel) yotamgingold.com>
License: Public Domain [CC0](http://creativecommons.org/publicdomain/zero/1.0/)
Description: An `asarray` function that wraps a cffi pointer in a numpy.array.
URL: https://gist.github.com/yig/77667e676163bbfc6c44af02657618a6
'''
from __future__ import print_function, division
import numpy