I often want to view the contents of .pickle files on my computer. I like doing this in the IPython REPL, so I would manually open a new Terminal window, switch to my data science virtualenv, import pickle, and then load the .pickle file in question into a variable. Sounds like a prime target for automation, eh?
Here's a Keyboard Maestro macro that will take the selected .pickle file in Finder and open it up in IPython (inside iTerm2), assigning it to the variable x
.
Here's what it looks like (the macro is triggered through LaunchBar with this custom action):
After the macro runs, I type in x
to show the object in the Pickle file (in this case, it's just {"hello": "world"}
.
Here's what the macro looks like in Keyboard Maestro:
Here's the code:
Note that this requires your Python virtualenv to be set up like this and you have to have a "data" virtualenv. If either of these things aren't true, you'll need to modify the shell commands in the AppleScript accordingly.
Put one of the following in a Jupyter notebook cell and run. If you make changes, clear cell contents, save, and refresh the browser.
All cells:
import IPython.core.display as di di.display_html(""" $('<style>.cell { margin-bottom: 100px !important;}</style>').appendTo('head'); """, raw=True)
To add padding just after code cells:
import IPython.core.display as di di.display_html(""" $('<style>.code_cell { margin-bottom: 100px !important;}</style>').appendTo('head'); """, raw=True)
To add padding just between code cells:
import IPython.core.display as di di.display_html(""" $('<style>.code_cell+.code_cell { margin-top: 100px !important;}</style>').appendTo('head'); """, raw=True)
SHOW FULL PROCESSLIST;
Sometimes the built-in camera on my Mac will stop working (no green light; no video). Restarting will fix it, but this appears to also work: sudo killall VDCAssistant
From How-To Geek:
Run sudo nvram SystemAudioVolume=%80
in the Terminal to disable the startup chime. Works like a charm on my late 2014 iMac.
To re-enable, run sudo nvram -d SystemAudioVolume
(I didn't test this part).
On multiple Macs, I have had the left/right balance of my headphones randomly drift. Apple says this can be caused by changing the volume while the CPU is under load, which doesn't seem to be what is happening to me. In any case, it's annoying.
Here's an AppleScript that will automatically reset the sound balance to the middle for the current output device:
There's also a $5 app called Balance Lock that in theory will solve this problem – I haven't tested it.
Note: This could be done in a loop. I don't do this because I often have results set-specific code that I want to run (e.g. renaming variables).
The following ImageMagick command will take an image with gray text (and a white background) and make the text black.
magick convert -level 80%,100%,1 in.png out.png
I've written some helper methods for quickly generating 2x2 tables (or contingency tables, cross tabulations, crosstabs) in Jupyter/IPython notebooks. This achieves the same thing, more or less, as Stata's tabulate twoway command.
The notebook below has the helper methods and examples of their output. I've added these to my ipython-setup file because I use them so frequently.