Skip to content

Instantly share code, notes, and snippets.

View Jwink3101's full-sized avatar

Justin Winokur Jwink3101

View GitHub Profile
@Jwink3101
Jwink3101 / parmap.py
Last active August 8, 2018 13:25
parmap.py -- multiprocessing tool to help simplify parallel function evaluation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division, print_function, unicode_literals, absolute_import
__version__ = '20180726.0'
__status__ = 'beta'
import multiprocessing as mp
import multiprocessing.dummy as mpd
from threading import Thread
@Jwink3101
Jwink3101 / run_python_in_bash.sh
Created April 27, 2018 16:53
Two examples of running python inside a bash script. The first is a simple one that just returns a result while the second gives bash a series of commands to run or a result to print (such as from parsing command line arguments).
#!/usr/bin/env bash
############################################################################
################################## Intro ###################################
############################################################################
# Example on how to run python inside of bash. Anything that is printed
# in the python part is "returned" to bash
#
# Examples:
@Jwink3101
Jwink3101 / open_ssl_from_python
Last active April 9, 2018 19:25
An example I am working on to use openssl via subprocess from Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Simple example of calling openSSL from python. Also with base64 set since I
will want to store in a text file
"""
from __future__ import print_function, unicode_literals
import subprocess
import shlex
@Jwink3101
Jwink3101 / python_bash.py
Created January 4, 2018 18:11
Python Bash interaction -- ALPHA (at best)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Interact with bash from python
ALPHA at best and hasn't been tested in a while
"""
from __future__ import print_function, unicode_literals
import subprocess
@Jwink3101
Jwink3101 / palette.m
Created October 12, 2017 14:45
Plot a palette in Matlab
function palette(cmap,varargin)
%% palette - Plot the color palette for a given map on x,y in [0,1]
% in the current window/axis
% Inputs:
% cmap - N x 3 array of colors --OR-- a cell array of 1x3 colors
% Options/Flags (note the `-` on flags)
% -no-label - If specified, will *never* label. Otherwise, will label
% for N<=10
% -vert - Plot vertically
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Demo of subplot methods for matplotlib using pyplot only when needed
and doing the main plotting on axes objects
"""
import itertools
import numpy as np
import matplotlib.pylab as plt