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 / extract_bearing_end_displacements.py
Created July 10, 2011 13:15
Extracts connector displacements and rotations and then applies them to a templated 3d model
import os
import sys
sys.path.append('/usr/lib/python2.6/site-packages/Jinja2-2.5.5-py2.6.egg')
from jinja2 import Template
import odbAccess
from symbolicConstants import *
from abaqusConstants import *
import csv
import re
import glob
@crmccreary
crmccreary / make_connector_behavior.py
Created July 10, 2011 13:18
Creates a bushing connector behavior from a 3D model
import os
import sys
import odbAccess
from glob import glob
import re
from collections import defaultdict
import numpy as NP
import subprocess
def open_odb(odbPath):
@crmccreary
crmccreary / MaxResult.py
Created July 10, 2011 13:57
Extracts the maximum result from an Abaqus odb
import sys
import os
import odbAccess
import numpy as NP
import math
def open_odb(odbPath):
base, ext = os.path.splitext(odbPath)
odbPath = base + '.odb'
new_odbPath = None
@crmccreary
crmccreary / paycheck_deductions.py
Created October 8, 2011 15:30
Given a paycheck total, calculate deductions
#!/usr/bin/python
import sys
FICA_employee_rate = 0.042
FICA_company_rate = 0.062
Medicare_rate = 0.0145
federal_withholding_rate = 0.28
FUTA_rate = 0.006
check_amount = float(sys.argv[1])
pay = check_amount/(1.0-
FICA_employee_rate-
@crmccreary
crmccreary / unzip_recursively.bash
Created October 12, 2011 16:31
Recursively unzip files
find . -name "*.zip" | while read filename; do unzip -n -d "`dirname "$filename"`" "$filename"; done;
@crmccreary
crmccreary / isclose.py
Created January 11, 2012 03:11
Rational test of floating point numbers for "equality"
def isclose(x, y, rtol=1.e-5, atol=1.e-8):
return abs(x-y) <= atol + rtol * abs(y)
@crmccreary
crmccreary / euler_angles_from_rotation_matrix.py
Created January 11, 2012 04:50
Computing Euler angles from a rotation matrix
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 / recursive_copy.py
Created January 11, 2012 14:57
Recursive copy files in src but not in dst
import os
import shutil
import sys
import argparse
def split_path(path):
folders=[]
while 1:
path,folder=os.path.split(path)
@crmccreary
crmccreary / upgrade_notes.rst
Created February 25, 2012 18:02
Upgrading OpenERP pre 6.1.1 to 6.1.1
@crmccreary
crmccreary / s3put
Created June 14, 2012 14:00 — forked from mattbillenstein/s3put
boto parallel s3 upload script
#!/usr/bin/env python
import gevent.monkey
gevent.monkey.patch_all()
import boto
import config
import gevent
import gevent.pool
import os