Skip to content

Instantly share code, notes, and snippets.

View crmccreary's full-sized avatar

Charles McCreary P.E. crmccreary

View GitHub Profile
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
@crmccreary
crmccreary / RR_SDOF.py
Created April 2, 2011 15:30
Calculates the random response of a single degree of freedom subject to a PSD
import numpy as np
import matplotlib.pyplot as plt
import scipy
from scipy.interpolate import interp1d
import math
PSD = np.array([[0.001,1.0e-8],
[5.0, 0.001],
[25.0, 0.03],
[30.0, 0.03],
@crmccreary
crmccreary / ogg2mp3.sh
Created June 8, 2011 23:52
Convert .ogg to .mp3
for name in *.ogg; do ffmpeg -ab 192k -i "$name" -map_meta_data 0:0,s0 "$(basename "$name" .ogg).mp3"; done;
@crmccreary
crmccreary / gist:1015749
Created June 8, 2011 23:54
Install Medibuntu
# For 9.10 to 10.10
sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update
sudo apt-get install ffmpeg libavcodec-extra-52
@crmccreary
crmccreary / Fp_dynamic.py
Created June 9, 2011 15:41
Damped driven pendulum
from numpy import sqrt, cos, sin, exp, arange, amax, absolute
from math import pow
from matplotlib import *
from pylab import *
def theta_func(L, g, m, x):
tmp = (179.5*pow(g,3./2.)*L*sin((sqrt(g)*x)/sqrt(L))*sin(x*(3.132-sqrt(g)/sqrt(L)))-\
179.5*pow(g,3./2.)*L*cos((sqrt(g)*x)/sqrt(L))*cos(x*(3.132-sqrt(g)/sqrt(L)))-\
5514.8*pow(L,5./2.)*sin((sqrt(g)*x)/sqrt(L))*sin(x*(3.132-sqrt(g)/sqrt(L)))+\
5514.8*pow(L,5./2.)*cos((sqrt(g)*x)/sqrt(L))*cos(x*(3.132-sqrt(g)/sqrt(L)))+\
@crmccreary
crmccreary / solve.py
Created June 9, 2011 15:42
Damped driven pendulum DE
from numpy import sin, cos
import scipy
from scipy.integrate import odeint
from scipy import arange, array
def func(y, t, L, S, g, c, scale):
theta = y[0]
d_theta_dt = y[1]
return (d_theta_dt, -g/L*sin(theta)-scale*S(t)/L*cos(theta)-c*d_theta_dt)
@crmccreary
crmccreary / ogg2mp3.py
Created June 9, 2011 23:25
Parallel transcoding of ogg files to mp3 (not that it's a good idea, just that I had to)
import subprocess
import os
import argparse
import pp
'''
Parallel transcoding of ogg files to mp3. And yes, lossy to lossy is a bad idea.
Needed to do this since Google's Music Beta doesn't support ogg and that's the
format in which my music is encoded.
This works on linux (ffmpeg), and needs the uncrippled ffmpeg (mp3 support, http://ubuntuforums.org/archive/index.php/t-1117283.html)
@crmccreary
crmccreary / MkConnectors.py
Created June 20, 2011 02:38
Make connector behavior and generate plots of stiffness
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 / abaqus_data_line.py
Created June 23, 2011 18:17
Writes out abaqus data lines, 4 pairs per line
for i,(time,temp) in enumerate(time_temp):
if not (i % 4):
f_amp.write('\n')
f_amp.write('%s,%s,' % (time,temp))
f_amp.write('\n')
@crmccreary
crmccreary / uniquefy.py
Created June 23, 2011 23:09
uniquefy a list
def uniquefy(seq, idfun=None):
# order preserving
if idfun is None:
def idfun(x): return x
seen = {}
result = []
for item in seq:
marker = idfun(item)
# in old Python versions:
# if seen.has_key(marker)