Skip to content

Instantly share code, notes, and snippets.

Ken Hughes hugke729

Block or report user

Report or block hugke729

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hugke729
hugke729 / elaborate_matplotlib_animations.py
Last active Feb 3, 2020
Quiver, 3D contour, polar, scatter, and fill animations with Matplotlib
View elaborate_matplotlib_animations.py
# Example animations using matplotlib's FuncAnimation
# Ken Hughes. August 2019
# For more detail, see
#https://brushingupscience.com/2019/08/01/elaborate-matplotlib-animations/
# Examples include
# - quiver plot with variable positions and directions
# - 3D contour plot
# - line plot on a polar projection
@hugke729
hugke729 / autokey_alternative.md
Created May 28, 2019
An alternative way to input unicode characters with Autokey
View autokey_alternative.md

An alternative way to input unicode characters with Autokey

The post Add any symbol without leaving the keyboard explains how to input unicode characters easily on Linux. However, the instructions given may not always work or you may be stuck with Autokey version 2, which doesn't play nice with unicode. What follows is a brief description of a work-around.

First, create a file called MyCopy.py containing the following

import sys
reload(sys)
sys.setdefaultencoding('utf8')
@hugke729
hugke729 / Sublime and Matlab (Windows).md
Last active Mar 27, 2020
Use Sublime Text and Matlab together in a REPL-like fashion
View Sublime and Matlab (Windows).md

Running an m-file or selected code from Sublime in Matlab's command window

A supplement to the Brushing Up Science post: Invest in a good text editor

I use both Matlab and Sublime Text. Although I edit m-files in Sublime, when I run the file or evaluate lines, I do so in Matlab. Detailed below is how I achieve this in such a way that if I want to run the file or evaluate the selected lines, I simply press Shift + Enter.

This example works for Windows using AutoHotKey. For Linux instructions, click here

Step 1: Autokey code

@hugke729
hugke729 / Sublime and Python (Windows).md
Last active May 17, 2018
Use Sublime and Spyder together in a REPL-like fashion
View Sublime and Python (Windows).md

Running a Python script or selected code from Sublime in Spyder's IPython console

A supplement to the Brushing Up Science post: Invest in a good text editor

I like to use both Python and Sublime Text. But I also like Spyder as a Python IDE. Therefore, although I edit in Sublime, to run scripts or evaluate lines of code in a REPL-like fashion, I do so via Spyder. Detailed below is how I achieve this in such a way that if I want to run the file or evaluate the selected lines, I simply press Shift + Enter.

This example works for Windows using AutoHotKey. For Linux instructions, click here.

Step 1: AutoHotKey code

@hugke729
hugke729 / Sublime and Python (Linux).md
Last active Aug 11, 2018
Use Sublime and Spyder together in a REPL-like fashion
View Sublime and Python (Linux).md

Running a Python script or selected code from Sublime in Spyder's IPython console

A supplement to the Brushing Up Science post: Invest in a good text editor

I like to use both Python and Sublime Text. But I also like Spyder as a Python IDE. Therefore, although I edit in Sublime, to run scripts or evaluate lines of code in a REPL-like fashion, I do so via Spyder. Detailed below is how I achieve this in such a way that if I want to run the file or evaluate the selected lines, I simply press Shift + Enter.

This example works for Linux using Autokey. For Windows instructions, click here.

Step 1: Autokey code

@hugke729
hugke729 / Sublime and Matlab (Linux).md
Last active May 4, 2020
Use Sublime Text and Matlab together in a REPL-like fashion
View Sublime and Matlab (Linux).md

Running an m-file or selected code from Sublime in Matlab's command window

A supplement to the Brushing Up Science post: Invest in a good text editor

I use both Matlab and Sublime Text. Although I edit m-files in Sublime, when I run the file or evaluate lines, I do so in Matlab. Detailed below is how I achieve this in such a way that if I want to run the file or evaluate the selected lines, I simply press Shift + Enter.

This example works for Linux using Autokey. For Windows instructions, click here

Step 1: Autokey code

@hugke729
hugke729 / rasterize_and_save.py
Last active May 3, 2020
Simplify export of matplotlib figures when both raster and vector components are desired in output
View rasterize_and_save.py
# A function to rasterize components of a matplotlib figure while keeping
# axes, labels, etc as vector components
# https://brushingupscience.wordpress.com/2017/05/09/vector-and-raster-in-one-with-matplotlib/
from inspect import getmembers, isclass
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
def rasterize_and_save(fname, rasterize_list=None, fig=None, dpi=None,
View animation_examples.py
# Example animations using matplotlib's FuncAnimation
# Ken Hughes. 18 June 2016.
# For more detail, see
# https://brushingupscience.wordpress.com/2016/06/21/matplotlib-animations-the-easy-way/
# Examples include
# - line plot
# - pcolor plot
# - scatter plot
View kens_beamer_theme.tex
\documentclass{beamer}
\definecolor{blue}{rgb}{0,0,0.8}
\usetheme{Hannover}
\usecolortheme{beaver}
\setbeamercovered{transparent=30}
\setbeamercolor{section in sidebar}{fg=blue}
\setbeamercolor{subsection in sidebar}{fg=blue}
\setbeamercolor{title in sidebar}{fg=blue}
\setbeamercolor{title}{fg=blue}
View insert_symbols.ahk
#SingleInstance Force
; AutoHotKey script to allow for easy input of various unicode characters often used in science.
; Written by Ken Hughes Jan 2015
; Tested with Windows 7 and 10
; Example:
; Type in /Delta and the script will automatically replace with Δ
; For best results, save this script into your startup folder which will be something like
; C:\Users\<USERNAME>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
; Autohotkey allows simpler ways to convert text to other text, but for unicode characters to work with Inkscape as well, they appear to need the function svc below.
You can’t perform that action at this time.