Instantly share code, notes, and snippets.

# David Shepherddavidshepherd7

• Sort options
Last active Oct 1, 2017 — forked from rejeep/travis-evm-cask.sh
 #!/bin/sh # This script will setup Evm (Emacs Version Manager) and Cask on # Travis to use for Emacs Lisp testing. # # In .travis.yml, add this: # # - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh # # Emacs 24.3 is installed in the above script because Cask requires
Last active Dec 30, 2015
 double Problem:: adaptive_unsteady_newton_solve(const double &dt_desired, const double &epsilon, const bool &shift_values) { //First, we need to backup the existing dofs, in case the timestep is //rejected //Find total number of dofs on current processor unsigned n_dof_local = dof_distribution_pt()->nrow_local();
Created Aug 26, 2013
 def emr_step(dt_n, y_n, dy_n, dt_nm1, y_nm1): """Take a single step of the explicit midpoint rule. From G&S pg. 715 and Prinja's thesis pg.45. """ dtr = dt_n / dt_nm1 y_np1 = (1 - dtr**2)*y_n + (1 + dtr)*dt_n*dy_n + (dtr**2)*(y_nm1) return y_np1 def bdf2_dydt(ts, ys): """Get dy/dt at time ts[-1] (allowing for varying dt).
Created Jun 28, 2013
View gist:5883871
 /// \short Indexed output function to print a matrix to the stream outfile /// as i,j,a(i,j) for a(i,j)!=0 only with a specified precision. void sparse_indexed_output(std::ostream &outfile, const unsigned &precision, const bool& output_bottom_right_entry_regardless=false) const { // Note: we might have to specify "output_bottom_right_entry_regardless" // as well (can't be a default). C++ can silently convert between // unsigned and bool, so having a default set for // output_bottom_right_entry_regardless would give the same function
Last active Dec 15, 2015
View Automatically run make on multiple cores
 # Changes to defaults for "make" # ============================================================ # How many cores do we have? Find out from /proc/cpuinfo (using regexp matching # the start of info for a new processor). NCORES=`grep --count '^processor[[:space:]]*:' /proc/cpuinfo` # Apparently make runs fastest with one more job than there are cores. NJOBS=\$((\$NCORES + 1)) export MAKEFLAGS="-j\$NJOBS"
Created Jan 29, 2013
example parallel parameter sweep for an oomph-lib driver
View gist:4666285
 #!/usr/bin/env python import subprocess as subp from multiprocessing import Pool import itertools import sys import numbers import argparse
Created Nov 18, 2012
View gist:4106279
 (define (q t) (abs (- t 5))
Created Nov 18, 2012
1.31 Velocity Transformation
View gist:4105231
 ;; Just use the transformation from the example then pull out the velocity from the tuple. (define (velocity-transform coordinate-transform) (compose (lambda (tuple) (velocity tuple)) (F->C coordinate-transform))) ;; ;; Or explicitly using Gamma-bar this is: ;; (define (velocity-transform coordinate-transform) ;; (define (f-bar q-prime) ;; (define q (compose coordinate-transform (Gamma q-prime))) ;; (Gamma q)) ;; (compose (lambda (x) (velocity x)) (Gamma-bar f-bar)))
Created Apr 17, 2015
python string split iterator
View isplit.py
 #! /usr/bin/env python3 import sys import re def isplit(string, delimiter = None): """Like string.split but returns an iterator (lazy) Multiple character delimters are not handled.
Created Apr 12, 2015
coursera crypto assignment 4: fixed Makefile
View Makefile
 all: vrfy mac vrfy: vrfy.o cbcmac.o aes_core.o gcc -o vrfy vrfy.o cbcmac.o aes_core.o -lpthread mac: mac.o cbcmac.o aes_core.o gcc -o mac mac.o cbcmac.o aes_core.o -lpthread clean: rm -f mac.o aes_core.o cbcmac.o mac.o vrfy.o vrfy mac
You can’t perform that action at this time.