Skip to content

Instantly share code, notes, and snippets.

View drhirsch's full-sized avatar

Michael Hirsch drhirsch

View GitHub Profile
@drhirsch
drhirsch / splitstring.f90
Last active October 4, 2015 07:06 — forked from ponderomotion/splitstring.f90
Split a string into 2 either side a delimiter in FORTRAN
! split a string into 2 either side of a delimiter token
function split(instr, delm)
implicit none
CHARACTER(len=80),intent(in) :: instr,delm
INTEGER :: idx
idx = scan(instr,delm)
split = instr(1:idx-1)
END function split
@drhirsch
drhirsch / find_available_port.py
Last active December 30, 2015 18:04 — forked from dbrgn/gist:3979133
Find an available port from Python script
#!/usr/bin/env python3
""" for use from shell, returns on STDOUT a free port number.
Yes, there is a slight race condition where between end of this program and start of your shell program,
another program could grab this port.
Useful for scripts with SSH port forwarding for example, where you have one or more hops before the final host.
reference: http://stackoverflow.com/questions/1365265/on-localhost-how-to-pick-a-free-port-number
Michael Hirsch