Skip to content

Instantly share code, notes, and snippets.

:atom:
Crunching numbers

Benjamin Morgan bjmorgan

:atom:
Crunching numbers
View GitHub Profile
@bjmorgan
bjmorgan / compile
Last active Jan 2, 2019 — forked from CameronDevine/compile
A bash script for compiling JOSS and JOSE papers locally
View compile
#!/usr/bin/env bash
# Help text
description="A bash script for compiling JOSS and JOSE papers locally";
doc="compile [-j <journal>] [-d <doi>] [-v <volume>] [-i <issue>] [-p <page>]
[-s <submitted>] [-u <published>] [-r <review>] [-g <repository>] [-a <archive>] FILE
Compile a markdown FILE to a JOSS or JOSE paper.
@bjmorgan
bjmorgan / environment.py
Created Aug 22, 2018
Python script for reporting runtime environment
View environment.py
#! /usr/bin/env python3
import platform
import pip
import sys
def pip_freeze():
try:
from pip._internal.operations import freeze
except ImportError: # pip < 10.0
@bjmorgan
bjmorgan / VASP_5.4.4_VDATCAR_patch
Created Nov 18, 2017
patch for VASP 5.4.4 to write velocities in A/fs to VDATCAR
View VASP_5.4.4_VDATCAR_patch
*** vasp.5.4.4/src/main.F Sat Nov 18 09:31:39 2017
--- vasp.5.4.4.vel/src/main.F Sat Nov 18 13:18:45 2017
***************
*** 479,484 ****
--- 479,485 ----
OPEN(UNIT=16,FILE=DIR_APP(1:DIR_LEN)//'DOSCAR',STATUS='UNKNOWN')
OPEN(UNIT=17,FILE=DIR_APP(1:DIR_LEN)//'OSZICAR',STATUS='UNKNOWN')
OPEN(UNIT=60,FILE=DIR_APP(1:DIR_LEN)//'PCDAT',STATUS='UNKNOWN')
+ OPEN(UNIT=62,FILE=DIR_APP(1:DIR_LEN)//'VDATCAR',STATUS='UNKNOWN')
OPEN(UNIT=61,FILE=DIR_APP(1:DIR_LEN)//'XDATCAR',STATUS='UNKNOWN')
@bjmorgan
bjmorgan / Find in OmniFocus.scpt
Last active Dec 24, 2015
AppleScript for triggering a search in OmniFocus from LaunchBar. Accepts text items from Launchbar (hit space, or send a text item to the script), or prompts the user for a search query.
View Find in OmniFocus.scpt
on handle_string(the_string)
if (length of the_string is 0) then
display dialog "Search OmniFocus for:" default answer ""
end if
open location "x-launchbar:hide"
my search_in_omnifocus(the_string)
end handle_string
on search_in_omnifocus(the_search_string)
tell application "OmniFocus"
@bjmorgan
bjmorgan / activation_energies.rb
Last active Dec 23, 2015
Calculates activation energies from a set of `T y` data (see example `data.dat`) (in eV), according to the Arrhenius equation. Uses a linear regression around `r` points away from each point considered to calculate the local slope.
View activation_energies.rb
#!/usr/local/bin/ruby
# September 16, 2013
require 'optparse'
options = {}
executable_name = File.basename($PROGRAM_NAME)
@bjmorgan
bjmorgan / meansqerror.rb
Created Jun 26, 2013
Calculated the mean squared error between data in two files. Files should be single columns of the same length.
View meansqerror.rb
#! /home/morgan/bin/ruby/bin/ruby
# Calculates the mean squared error between two data sets
# http://en.wikipedia.org/wiki/Mean_squared_error
# BJM 26/06/13
def check_files_exist( filenames )
all_files_exist = true
filenames.each do |filename|
@bjmorgan
bjmorgan / Default (OSX).sublime.keymap
Last active Dec 15, 2015
Sublime Text 2 plugin for inserting \ref{<reference string>} code into LaTeX documents. The plugin scans the file for \label{<reference string>} commands (ignoring those in commented out lines), and presents a drop-down list of <reference string> options, alphabetically sorted. The keymappings given here bind the command to ⌘-l, ⌘-r.
View Default (OSX).sublime.keymap
[
// Run LaTeX plugin to insert reference code
{
"keys": ["super+l", "super+r"],
"command": "insert_latex_reference",
"context": [
{ "key": "selector", "operator": "equal", "operand": "text.tex.latex" }
]
}
]
@bjmorgan
bjmorgan / Sections.tmPreferences
Created Dec 21, 2012
Modified symbol matching ( TM | SL2 ) preference file for LaTeX. This presents the different sections indented according to their hierarchy.
View Sections.tmPreferences
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Symbol List</string>
<key>scope</key>
<string>meta.function.section.latex</string>
<key>settings</key>
<dict>
@bjmorgan
bjmorgan / figure.latex.sublime-snippet
Last active Dec 10, 2015
Sublime Text 2 snippet for inserting code for a `figure` environment. Triggered with `"figure"+tab`.
View figure.latex.sublime-snippet
<snippet>
<content><![CDATA[\begin{figure}[tb]
\begin{center}
\resizebox{${3:8.5}cm}{!}{\includegraphics*{${1:filename}.eps}} % $4
\caption{\label{fig:${1:label}}${2:Caption}}
\end{center}
\end{figure}
$0]]></content>
<tabTrigger>figure</tabTrigger>
@bjmorgan
bjmorgan / table.latex.sublime-snippet
Created Dec 21, 2012
Sublime Text 2 snippet for inserting a `table` environment, triggered by `"table"+tab`
View table.latex.sublime-snippet
<snippet>
<content><![CDATA[\begin{table}[htb]
\begin{center}
\begin{tabular}{$3}
$0 \\\\
\end{tabular}
\caption{\label{tab:${1:label}}${2:CAPTION}}
\end{center}
\end{table}
You can’t perform that action at this time.