Skip to content

Instantly share code, notes, and snippets.

View crmccreary's full-sized avatar

Charles McCreary P.E. crmccreary

View GitHub Profile
@crmccreary
crmccreary / circle_packing_polygonal_room2_basin_hopping.ipynb
Created June 12, 2020 18:22
Say you wanted to find out how many students you could pack into a classroom and still have a social separation of 6 foot? This reduces to the circle packing problem in a polygonal domain.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crmccreary
crmccreary / gist:6ecc52bd385fe47e0800c190fc6a0f5b
Created October 19, 2018 15:22
Converts python 2 print to python 3 print()
def convert_print(text):
index_of_print = text.find(PRINT)
if index_of_print != -1:
# find the argument of print
arg = text[index_of_print + len(PRINT):]
# Strip left white space using built-in string method lstrip()
# If line is print statement, use the format() method to add insert parentheses
return 'print({})'.format(arg.lstrip())
else:
return text
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crmccreary
crmccreary / instructions.txt
Created December 28, 2017 17:02
Concatenate mp4
inputs.txt:
file 'GOPR4405.MP4'
file 'GP014405.MP4'
ffmpeg -f concat -i inputs.txt -c copy trail.mp4
find . -iname '*.csv' -print0 | xargs -0 tar -cvf somefile.tar -T -
@crmccreary
crmccreary / find_and_zip
Created August 12, 2017 19:29
find and zip
find . -iname '*.csv' -print0 | xargs -0 zip csv_files.zip -@
'''
Run like:
abaqus cae noGUI=abaqusToOpenFOAM.py -- path/to/cae/model model-name
# So the polymesh will be upper diagonal
renumberMesh -overwrite
# Make sure all is OK
checkMesh
# If model built in mm
transformPoints -scale '(1e-3 1e-3 1e-3)'
@crmccreary
crmccreary / powerball.py
Last active January 14, 2016 01:36
A simple powerball simulator
from numpy.random import choice
JACKPOT = 1.5e9
NUM_TICKETS = 1000
def gen_numbers():
'''
Pick 5 numbers, without replacement, from 1-69
and the powerball from 1-26
import numpy as np
from scipy.interpolate import interp1d
from pylab import plt
def process_rpt(fname):
with open(fname, 'rb') as f:
lines = f.readlines()
lines_cleaned = []
for line in lines:
# Strip leading and trailing whitespace