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 / 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 / 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'/")
@bquistorff
bquistorff / cli_smcl_log.do
Created November 20, 2014 04:19
Translates a Stata smcl log into log format
*Callable from the command line for converting a gph to eps's in the right places
global dir_base ".."
translate "${dir_base}/log/smcl/`1'.smcl" "${dir_base}/log/`1'.log", replace linesize(140)
@bquistorff
bquistorff / svn_batch_rename.sh
Created November 20, 2014 03:35
Batch renames SVN files
#!/bin/bash
# renames files (and svn mv's them if in svn)
# not sure if this works if there is whitespace in these vars
# use from base of project
findstr=$1
replacestr=$2
# It currently doesn't search in hidden folders
# for no recursion, use:
# for i in *