Skip to content

Instantly share code, notes, and snippets.

View bbdaniels's full-sized avatar

Benjamin Daniels bbdaniels

View GitHub Profile
@bbdaniels
bbdaniels / README.md
Last active March 23, 2020 13:39 — forked from kbjarkefur/README.md
Include link to git commit SHA used to compile pdf in LaTeX

Automatically include link to current git commit/SHA in compiled LaTeX pdf

This code lets you include an automatically updating link in a LaTeX compiled document that points to the last commit in the branch currently checked out in the repository where the .tex file used to compile the documents is saved. This allows you to track exactly which version of your .tex file was used to generate a given PDF.

Using Git you can then go back to the exact code used when compiling any saved or printed version of your document you find, no matter how long ago it was compiled. The commit SHA (the unique commit ID) will automatically update each time there is a new commit

@bbdaniels
bbdaniels / Add-sub-functions.md
Created November 8, 2018 21:54 — forked from kbjarkefur/Add-sub-functions.md
How to have to commands in seperate ado-files sharing the same sub-commands in a separate file.

Two commands sharing the same sub-functions

It is common that two ado-files in the same package share a lot of sub-commands (also called utility commands, functions etc.). It is bad practice to write the commands in one file first and copy and paste the sub-commands to the other ado-file. This is ad practice as updating these commands is very likely to lead to errors. This is a part of the DRY coding principle that is one of the few coding paradigms that all computer scientists agree on.

This Gist explains how you can set this up in a Stata environment.

The mySubCommandsXYZ.do file

You should give this file a unique name if you are planning on publishing commands using this method as there will be a name conflict if someone else also have a file called mySubCommandsXYZ.do or whatever you end up calling your file.

This file includes all sub-commands that should be included in the ado-files for the commands. The commands in this file may not have

@bbdaniels
bbdaniels / csv.lua
Created March 26, 2018 19:03 — forked from calebreister/csv.lua
Lua script that converts a CSV file to the LaTeX tabular format
--To include this file, use
--dofile('csv.lua') or require('csv')
--Function to convert a *SV file to a Lua array
--file: the name of the file to read
--delim: the delimeter (default ',')
function dataToTable(file, delim)
--Set initial values
if delim == nil then --allow delim to be optional
delim = ','