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 / process_abaqus_rpt.py
Created November 22, 2013 14:42
This python function attempts to convert the XYData report generated by Abaqus into something useful
def process_rpt(fname):
with open(fname, 'rb') as f:
lines = f.readlines()
lines_cleaned = []
for line in lines:
# Strip leading and trailing whitespace
line_cleaned = line.lstrip().rstrip()
# Ignore blank lines
if len(line_cleaned):
# Check if first element is a float
@crmccreary
crmccreary / mv_sub.sh
Created October 24, 2013 20:43
Move all files in subdirectories to current directory
find ./*/* -type f -print0 | xargs -0 -I % mv % .
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crmccreary
crmccreary / AESCipher.py
Created May 20, 2013 02:17
Encryption using pycrypto, AES, and PKCS5 padding
from Crypto.Cipher import AES
from Crypto import Random
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
class AESCipher:
def __init__( self, key ):
"""
## {{{ http://code.activestate.com/recipes/577814/ (r1)
# Lorenz Attractor (projected onto XY-plane)
# http://en.wikipedia.org/wiki/Lorenz_attractor
# FB - 201107317
import random
from PIL import Image
imgx = 800
imgy = 600
image = Image.new("RGB", (imgx, imgy))
import numpy as NP
import math
def isclose(x, y, rtol=1.e-5, atol=1.e-8):
return abs(x-y) <= atol + rtol * abs(y)
def euler_angles_from_rotation_matrix(R):
'''
From a paper by Gregory G. Slabaugh (undated),
"Computing Euler angles from a rotation matrix
@crmccreary
crmccreary / odbPrinStressAngle.py
Created February 22, 2013 18:25
Python script for use within Abaqus to create a fieldOutput of the angle between a specified vector and the normal to the maximum principal stress plane
import sys, getopt, os, string
import math
from odbAccess import *
from abaqusConstants import *
import numpy as np
from numpy import linalg as LA
def get_p1_vector(s):
'''
11, 22, 33, 12, 13, 23
@crmccreary
crmccreary / GroutTestData.ipynb
Last active December 12, 2015 04:08
ipython nb of grout test data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.