Skip to content

Instantly share code, notes, and snippets.

View bquistorff's full-sized avatar

Brian Quistorff bquistorff

View GitHub Profile
@bquistorff
bquistorff / proj-only-ado.do
Last active August 29, 2015 14:05
Stata dependencies stored with project
//Limit to just the project ados
cap adopath - SITE
cap adopath - PLUS
cap adopath - PERSONAL
cap adopath - OLDPLACE
adopath ++ "${dir_base}/code/ado/"
*add mlibs in the new adopath to the index
mata: mata mlib index
@bquistorff
bquistorff / local-ado-install.do
Last active August 29, 2015 14:05
How to install dependencies locally
net set ado "${dir_base}/code/ado/"
* Simple module.
* Just install it once into your project. Copies of the project folder will work fine.
ssc install parallel
* Modules with machine-specific code.
* Needs to install each time you put the project folder on a new computer type.
* Needs an absolute path so let -pwd- is "${dir_base}/code"
net install synth , all force from("`c(pwd)'/${dir_base}/code/ado-store/s/")
@bquistorff
bquistorff / stata-highlight-gist.html
Created August 25, 2014 17:13
How to custom syntax highlight Stata gists
<!-- include in header -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- These below should be integrated into highlight.js -->
<link rel="stylesheet" href="http://quistorff.com/stata/stata-default.css">
<script src="http://quistorff.com/stata/highlight.pack.js"></script>
<script>
$(document).ready(function() {
$('div.line').replaceWith(function() { return this.innerHTML.concat('\n'); });
$('pre').each(function(i, block) { hljs.highlightBlock(block); });
@bquistorff
bquistorff / beamer_outputs.sh
Last active August 29, 2015 14:05
Creates the various versions of a presentation from a beamer LyX document.
#!/bin/bash
# Creates three PDFs from a Beamer LyX document.
# Doesn't assume anything about existing options
# so makes all docs with new file suffixes.
#
# Added to Right-click menu with FileMenu Tools by lopesoft
# Pass in the filename with extension
filename=${1%%.*}
@bquistorff
bquistorff / beamer_outputs_bash.sh
Created September 27, 2014 15:01
Creates the various versions of a presentation from a beamer LyX document (command line version).
#!/bin/bash
# Creates three PDFs from a Beamer LyX document.
# Doesn't assume anything about existing options
# so makes all docs with new file suffixes.
#
# Added to Right-click menu with FileMenu Tools by lopesoft
# Pass in the filename with extension
filename=${1%%.*}
@bquistorff
bquistorff / patch-mlibs.do
Last active August 29, 2015 14:07
Patch system mata functions with personal ones
*Make sure -mata: mata mlib index- has been executed previously
cap di regexm("`c(matalibs)'", "(.*);lpersonal(.*)")
mata: mata set matalibs "lpersonal;`=regexs(1)'`=regexs(2)'"
@bquistorff
bquistorff / statab.sh
Last active June 5, 2019 18:21 — forked from pschumm/statab
Wrapper for launching Stata in batch-mode
#! /bin/bash
# Wrapper for Stata batch-mode which:
# -issues an informative error msg and appropriate (possibly non-zero) return code
# -allows an implicit -do- when called with just a do file
# Requirements: set $STATABATCH (e.g. 'stata-mp -b')
# updated from Phil Schumm's version at https://gist.github.com/pschumm/b967dfc7f723507ac4be
args=$# # number of args
@bquistorff
bquistorff / store-mod-install-files.sh
Created October 7, 2014 18:56
Downloads to a folder the necessary installation files for a Stata module
#!/bin/bash
# Example usage
#./store-mod-install-files.sh http://fmwww.bc.edu/repec/bocode/s/synth.pkg ado-store
# Assumes the standard first-letter directory structure.
pkgfilename=$(basename "$1")
pkgdirpath=$(dirname "$1")
pkgbase="${pkgfilename%.*}"
pkgbase_letter=${pkgbase:0:1}
orig_dir=$PWD
@bquistorff
bquistorff / gen-makefile.sh
Last active April 4, 2018 13:51
Generates a makefile keep Stata module installed files up-to-date with changes to the installation files
#!/bin/bash
#make a package-specific makefile
# Requirement: set the environment variable STATA_PLATFORM
# The platform names are:
# WIN (32-bit x86) and WIN64A (64-bit x86-64) for Windows;
# MACINTEL (32-bit Intel, GUI), OSX.X86 (32-bit Intel, console), MACINTEL64 (64-bit Intel, GUI), OSX.X8664 (64-bit Intel, console), MAC (32-bit PowerPC), and OSX.PPC (32-bit PowerPC), for Mac;
# LINUX (32-bit x86), LINUX64 (64-bit x86-64), SOL64, and SOLX8664 (64-bit x86-64) for Unix.
# To do: generate this automatically
@bquistorff
bquistorff / cli-install-module.do
Created October 7, 2014 19:16
Callable from the command line for install packages from local store (that need machine-specific installation)
*Callable from the command line for install packages from local store (that need machine-specific installation)
global dir_base ".."
* Use the -net set- line before installing other packages
net set ado "${dir_base}/code/ado/"
local letter1 = substr("`1'",1,1)
net install `1' , all force from("`c(pwd)'/${dir_base}/code/ado-store/`letter1'/")