How to set the IPython/Jupyter Qt Console font size on WinPython

TL; DR: create a file called under .jupyter\ in the WinPython settings directory (e.g. C:\Users\user\WinPython-64bit-\settings\.jupyter\ and write the line c.ConsoleWidget.font_size = 12, where the number is what you want the font size to be, in points.

On my Windows machine, for my Python setup, I use WinPython because it is super easy to set up, it’s self-contained, and, if I muck up anything, it is very easy to delete the install and start over. IDEs like JetBrains PyCharm can also be easily set up to point to the WinPython interpreter as well (File > Settings > Project > Project Interpreter) so you can benefit from all the IDE code completion, module analysis, introspection etc etc.

WinPython also comes with a ton of useful modules and “plugins” — Jupyter, IPython (and Qt Console), Spyder, and all the Scientific Python libraries: Numpy, Scipy, Pandas, Matplotlib, etc etc. Python is already “batteries included” — Winpython is like “nuclear reactor included.”

How to reload a Python module

Reloading a Python module can be useful if you are doing interactive testing and development. For example, say you are making incremental changes to a function and with each change you want to poke at it in an interactive console. Or, perhaps you are working in a Jupyter notebook rather than an interactive console. Same idea.

In Python 3.4 and greater, do this:

import importlib
import my_great_module

In Python 3 prior to 3.4 do this:

import imp
import my_great_module

In Python 2, do this:

import my_great_module

A word of caution from the importlib.reload documentation:

When a module is reloaded, its dictionary (containing the module’s global variables) is retained. Redefinitions of names will override the old definitions, so this is generally not a problem. If the new version of a module does not define a name that was defined by the old version, the old definition remains.

This effect can be demonstrated by calling dir() on a loaded module before and after removing some module variables and reloading the module.

Here are some useful references:


3D/GPU-related display problems with Atom editor on Xubuntu 16.04 VM

Was having a problem with Atom editor on a new Ubuntu/Xubuntu 16.04 virtual machine. Launching Atom using the --disable-gpu option seems to fix the problem:

$ atom --disable-gpu


Next, need to figure out how to modify the application launch item in the Whisker Menu so that it executes that command instead of the vanilla $ atom command.


Audio quality peculiarities on mobile YouTube app

I noticed a weird thing today, watching Harvard i-lab | Startup Secrets Part 1: Value Proposition – Michael Skok, and that weird thing was that the audio for this video sounded really bad when played through my iPhone 6S speaker but sounds totally fine when I plug my headphones in. There is definitely audible compression-related distortion even through the headphones but it’s not at all a problem for listening comprehension. In contrast, the audio is extremely difficult to understand when played through the iPhone speaker. I wonder if this is app shenanigans or if it is an interesting hardware (i.e. speaker + drive electronics) interaction with the raw audio signal from the YouTube stream. I am kind of hoping for a weird corner case where the speaker’s frequency response is emphasizing the distortion in the audio signal.

To be continued… hopefully…

Using git config to fix settings and stuff

I am a bit of a git noob so I had to poke around a bit to figure out how to fix my setting. Here are some snippets of useful git config commands and options to illustrate behavior.

Initialize empty git repo in dummy directory:

$ git init

Initialized empty Git repository in /home/mrmagoo/foogit/.git/

List all config items. These were created automatically when we executed the git init command because at some point in the past I had set them using git config --global --add:

$ git config -l Magoo

Remove the global setting:

$ git config --global --unset

$ git config -l Magoo

Re-add the global setting but give it a different value this time:

$ git config --global --add

$ git config -l Magoo

Add a local setting:

$ git config --add

$ git config -l Magoo


CUPS and network printing on Linux

CUPS and network printing on Ubuntu GNOME 16.04, to be specific. CUPS is an open-source printing system for Mac OS, Linux and UNIX which I don’t know much about yet but appears to be pretty widely used judging by my limited googling.

Via Ask Ubuntu, a CUPS web dashboard can be accessed via the URL http://localhost:631/

Continue reading “CUPS and network printing on Linux”

Resetting a Brother HL-5250DN printer to factory default settings

I have an old Brother HL-5250DN black and white laser printer that I found via Craigslist. I want to set up the printer as a network printer on my home network — the first step is to factory reset the printer so that I can regain access to the admin control panel!

Continue reading “Resetting a Brother HL-5250DN printer to factory default settings”

Concatenating M4V files on Ubuntu 16.04

Hat tip My Web Experiences blog.

This is pretty neat. If you have two (or perhaps more) .m4v files that you want to concatenate, there is an open source package called gpac available for Ubuntu and Debian. Debian packages are available at the project website, and the source code is on a github repo.

The package is also available via the Ubuntu apt package manager. As of 2016 Dec 18, the latest release available via apt is 0.5.2, which is a bit behind the latest project release, 0.6.1.

While the package is called gpac, the command provided by the package used to concatenate M4V files is called MP4Box, and the syntax is:

$ MP4Box -cat video1.m4v -cat video2.m4v -new combinedvideo.m4v

This took maybe 5 minutes to combine two approx. 1 GB files on my Intel i5 from 2008.

Bytes in Python 3.5

I’m working with os.urandom and I was puzzled by this output:

>>> x = os.urandom(16)
>>> print(x)
>>> type(x)
>>> len(x)
>>> x[5]
>>> x.hex()
>>> x[0]      # ASCII code for 'c' is 99 (decimal)
>>> hex(x[0]) # ASCII code for 'c' is 63 (hexadecimal)
>>> hex(x[5])

This question on StackOverflow clears things up greatly.

print(x) displays a “mixed hexadecimal/ascii” representation of the bytes object x. Bytes that correspond to ASCII characters are displayed as ASCII characters, and bytes that do not are displayed in hexadecimal notation. Which is a little bit confusing if you aren’t expecting it.