Skip to content

Instantly share code, notes, and snippets.

View bjmorgan's full-sized avatar
:atom:
Crunching numbers

Benjamin Morgan bjmorgan

:atom:
Crunching numbers
View GitHub Profile
@bjmorgan
bjmorgan / VASP_5.4.4_VDATCAR_patch
Created November 18, 2017 13:22
patch for VASP 5.4.4 to write velocities in A/fs to VDATCAR
*** 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 / TeXShop Extended.thTheme
Last active June 25, 2021 16:47
Light theme designed for LaTeX in TextMate / Sublime Text. Based on my colour scheme in TeXShop, with extensions for additional syntax highlighting for \ref, \label, \cite, \footnote, math environment, and others. Also supports syntax highlighting for \caption and \mathrm, provided these are listed in the LaTeX.tmLanguage file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>TeXShop Extended</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@bjmorgan
bjmorgan / compile
Last active January 2, 2019 21:09 — forked from CameronDevine/compile
A bash script for compiling JOSS and JOSE papers locally
#!/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 August 22, 2018 08:59
Python script for reporting runtime environment
#! /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 / Find in OmniFocus.scpt
Last active December 24, 2015 10:49
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.
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 December 23, 2015 06:09
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.
#!/usr/local/bin/ruby
# September 16, 2013
require 'optparse'
options = {}
executable_name = File.basename($PROGRAM_NAME)
@bjmorgan
bjmorgan / meansqerror.rb
Created June 26, 2013 07:46
Calculated the mean squared error between data in two files. Files should be single columns of the same length.
#! /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 December 15, 2015 07:18
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.
[
// 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 December 21, 2012 18:43
Modified symbol matching ( TM | SL2 ) preference file for LaTeX. This presents the different sections indented according to their hierarchy.
<?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 December 10, 2015 00:58
Sublime Text 2 snippet for inserting code for a `figure` environment. Triggered with `"figure"+tab`.
<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>