Pipenv install with all the flags, explained

Posted on Thu 19 November 2020 in programming • Tagged with python, pipenv, docker

A common pattern of using pipenv in containers is to install as follows:

COPY Pipfile Pipfile.lock ./
RUN pip install --upgrade pip && \
    pip install pipenv && \
    pipenv install --system --deploy --ignore-pipfile && \
    pipenv --clear

What is going on here, exactly? How does one understand the intersection of the flags given to pipenv …


Continue reading

Inline markup within words in reStructuredText

Posted on Wed 12 August 2020 in programming • Tagged with rst, docs

I often write documentation with reStructuredText and Sphinx. Sometimes I want to refer to the plural of some programming concept, where the concept is monospace font but the plural form is in the normal font, e.g. lists.

While this is easy to do in markdown:

`list`s

It …


Continue reading

Hidden Icon? files on macOS

Posted on Mon 15 June 2020 in programming • Tagged with macos

For a while I've tolerated files named Icon? that appear in my console ls and git status output on macOS as well as in some IDE file trees like in Atom:

$ \ls -Al
total 696
-rw-------  1 micahsmith  staff  179 Nov 12  2019 Experiment Datasets.gsheet
-rw-r--r--@ 1 micahsmith  staff …

Continue reading

Dataclasses and mutable defaults

Posted on Tue 14 January 2020 in programming • Tagged with python

One common Python gotcha is the use of mutable objects as defaults for function keyword arguments. There are approximately one billion questions on SO about this or nice discussions elsewhere. I came across a nice feature in Python's dataclasses library that addresses a similar problem.

Mutable defaults are bad

As …


Continue reading

Fixing invalid argument iwhite on vimdiff

Posted on Thu 07 November 2019 in programming • Tagged with vim, macos, catalina

[Update from 2020-03-27 below]

Vim's diff mode is a lightweight diffing tool that can be used at the command line, in particular with the git diff command. In a previous post, I wrote about configuring vimdiff as the git difftool for use with Matlab development (yes, way back when I …


Continue reading

Find ports in use on macOS

Posted on Mon 16 September 2019 in programming • Tagged with macos, shell

How to find ports that are already "in use" on macOS:

sudo lsof -P -i TCP -s TCP:LISTEN

This is helpful if you are trying to figure out which process is using a port so that you can kill that process — for example, if you have a web server …


Continue reading

Trim graphics in LaTeX

Posted on Fri 13 September 2019 in programming • Tagged with latex

How to trim a figure in LaTeX.

You've already inserted the figure into a figure environment and now want to trim excess whitespace.

Start adjusting from here:

\fbox{\includegraphics[clip=true, trim={0 0 0 0}, width=\linewidth]{myfigure}}

fbox is a black box around the float content so you …


Continue reading

Using autoreload in IPython

Posted on Fri 13 September 2019 in programming • Tagged with python, ipython, jupyter

Using the autoreload extension.

%load_ext autoreload
%aimport mymodule
%autoreload 1

The autoreload command understands three levels:

  • 0 -> extension is disabled
  • 1 -> reload modules that were marked with %aimport
  • 2 -> reload everything

The easiest usage of autoreload is to not aimport anything and set %autoreload 2, which causes the extension to …


Continue reading

You need a doorbell

Posted on Fri 03 February 2017 in programming • Tagged with life, programming, python, twilio, flask

Sometimes a dumb technical approach can be a solution to a real world problem.

I live in a graduate residence that doesn't have a buzzer system. To be granted access, my guests have to text/call me directly and I have to walk downstairs to let them in. Though this …


Continue reading

Why I'm bailing on Julia for machine learning

Posted on Fri 04 November 2016 in programming • Tagged with julia, python, ml

I'm bailing on Julia for machine learning — just for my one class, that is. Don't worry ~too much~!

I'm taking graduate machine learning (6.867) this semester at MIT. There are three homework assignments in the course that are structured as mini-projects, in which students implement canonical algorithms from scratch …


Continue reading

Using vimdiff with dumb paths

Posted on Tue 02 February 2016 in programming • Tagged with vim, git, matlab

I've been loving vimdiff as my git difftool for a while.

Vimdiff and Matlab packages

Vimdiff runs into some problems when working with Matlab code. Matlab considers directories with names beginning with + as "packages", a natural way to organize projects. However, this means that many paths relative to the git …


Continue reading