Skip to content

Instantly share code, notes, and snippets.

@hertzsprung
hertzsprung / faceVertexFace.C
Created March 2, 2017 16:22
OpenFOAM application to find faces that share points (vertices) with other faces
#include "fvCFD.H"
using namespace fv;
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
@hertzsprung
hertzsprung / post.sh
Created June 15, 2016 22:28
tempestmodel post-processing
#!/bin/tcsh
setenv CASE /glade/scratch/jashaw/supercell/15
setenv EXTRACT_SURFACE $HOME/work/tempestmodel/util/ExtractSurface/ExtractSurface
ncrcat --overwrite $CASE/outU7.0000-*.nc $CASE/outU7.all.nc
bsub -K -q tutorial -W "0:05" -n 1 -P SCIS0006 mpirun.lsf $EXTRACT_SURFACE --in $CASE/outU7.all.nc --out $CASE/outU7.all.5km.nc --var 'W,Rho,RhoQr' --z 5000
ncl plot_supercell_5km_xsec.ncl
@hertzsprung
hertzsprung / gist:b714e54926abb4793038998f8781c20b
Last active May 20, 2016 09:36
PDF metadata for LaTeX documents
\makeatletter
\AtBeginDocument{
\hypersetup{
pdftitle = {\@title},
pdfauthor = {\@author}
}
}
\makeatother
@hertzsprung
hertzsprung / animate-gnuplot.sh
Last active March 17, 2016 11:38
Visualising a least squares fit of a polynomial surface to 12 data points in 2D space
#/bin/bash
set -e
rm -f plot*.png plot.gif
for i in $(seq 0 119);
do
./surface-fit-visualisation.py 60 $((30 + $i * 3)) $(printf "%03g" $i) | gnuplot5
done
for i in $(seq 0 30);
@hertzsprung
hertzsprung / NestedProvidersTest.java
Created April 5, 2013 18:04
Attempting to nest custom providers
import com.sun.jersey.api.core.DefaultResourceConfig;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.LowLevelAppDescriptor;
import com.sun.jersey.test.framework.spi.container.TestContainerException;
import org.junit.Test;
import javax.ws.rs.GET;
@hertzsprung
hertzsprung / AllOfTestCase.java
Created March 12, 2013 10:18
Hamcrest AllOf diagnostics
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasProperty;
import org.junit.Test;
import java.util.Arrays;
import java.util.Iterator;
@hertzsprung
hertzsprung / gist:4716775
Created February 5, 2013 19:04
Silly bit twiddling for berlin clock
public class BerlinClock {
public static String[] print(Time time) {
char seconds = (char) (89 - 10 * (time.second & 1));
char our = (char) (79 + 3 * (time.hour & 1));
/*
000 00000000 00000000 00000000 00000000
001 00000000 00000000 00000000 10000000
#!/usr/bin/env python3
from numpy.linalg import pinv
from numpy import diag
from numpy import transpose
from numpy import dot
import numpy as np
# a 3x3 stencil with centroids between (-1.5,1) and (0.5,1)
# to interp onto face at (0,0)
# upwind cell first, then downwind cell, then top row L-R, bottom row L-R, then left-most cell in middle row
@hertzsprung
hertzsprung / gist:4049487
Created November 10, 2012 01:54
Amerika
* = harmonic
( ) = optional
T = tap
A = artificial harmonic
--9-9-----------9-7*--9--------------9-11-13-----------
---------11-11----9*-----9-9---11-12----------14-------
-------0---------(7)-----------------------------13-14-
------------------9*-----------------------------------
@hertzsprung
hertzsprung / BeanTest.java
Created November 8, 2012 17:00
Spring Java configuration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes=BeanTest.Config.class)
public class BeanTest {
@Test
public void test() {}
@Configuration
public static class Config {
@Bean public Object bean1() {
System.out.println(bean2());