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 / 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 / gist:4344886
Created December 20, 2012 11:56
A Ruby TextExpander snippet that takes data copied to the clipboard from Numbers and pastes LaTeX source for a table environment. Discussed here: http://analysisandsynthesis.com/utilities/2012/12/20/quick-latex-tables-using-textexpander.html
#!/usr/local/bin/ruby
class Line
@@max_length = nil
@@eol = ' \\\\'
def initialize( data )
@contents = data
@@max_length = [0]*@contents.size if @@max_length.nil? # initialize array if this is the first Line instance
@bjmorgan
bjmorgan / Bibtex.sublime-build
Created December 20, 2012 23:30 — forked from dpo/BibTeX.sublime-build
Build files, keymap entries, and `run_latex_build.py` plugin for adding the option for running bibtex and cleaning up auxiliary files for LaTeX in Sublime Text 2. Added the ability to run bibtex, and changed key bindings.
{
"cmd": ["bibtex", "$file_base_name"],
"path": "$PATH:/usr/texbin:/usr/local/bin",
"file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",
"selector": "text.tex.latex"
}
@bjmorgan
bjmorgan / Default (OSX).sublime.keymap
Last active December 10, 2015 00:48
Sublime Text plugin for LaTeX that lists a choice of `.eps` files in the directory defined in `\graphicspath{<DIRECTORY>}`, and after the user selecting one inserts boilerplate figure code. If `\graphicspath` is missing, or the line is commented out, the plugin will look for .eps files in the root directory of the `.tex` file.
[
// Run LaTeX plugin to insert figure code
{
"keys": ["super+l", "super+f"],
"command": "insert_latex_figure",
"context": [
{ "key": "selector", "operator": "equal", "operand": "text.tex.latex" }
]
}
]
@bjmorgan
bjmorgan / table.latex.sublime-snippet
Created December 21, 2012 18:16
Sublime Text 2 snippet for inserting a `table` environment, triggered by `"table"+tab`
<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}
@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>
@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 / 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 / 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 / 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)