Skip to content

Instantly share code, notes, and snippets.

View bbdaniels's full-sized avatar

Benjamin Daniels bbdaniels

View GitHub Profile
@bbdaniels
bbdaniels / boilerplate.tex
Last active May 10, 2019 18:45
Simple tex document
\documentclass[fleqn,10pt]{wlscirep}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\doublespacing
\title{Scientific Reports Title to see here}
\author[1,*]{Alice Author}
@bbdaniels
bbdaniels / figure.tex
Last active May 9, 2019 20:26
Simple figure in latex
\newpage
\section*{Figure: Title}
\newline
\includegraphics[width=1\textwidth]{filepath.eps}
\newline
\textbf{Notes:}
@bbdaniels
bbdaniels / round.do
Created April 18, 2019 17:08
Correct rounding in Stata
local `param' : di %3.2f ``param''
@bbdaniels
bbdaniels / sensible-stata-axes.do
Created March 11, 2019 18:53
Include 0 and number of ticks explicitly
tw [anything] , yscale(r(0)) ylab(#6)
@bbdaniels
bbdaniels / Notes:
Last active July 28, 2023 18:05
Pandoc tex to docx
- Copy in cover page
- Move up references
- Remove images if necessary
@bbdaniels
bbdaniels / forward.html
Created December 13, 2018 23:09
HTML to forward to another page
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<title>Your Page Title</title>
<meta http-equiv="refresh" content="0;url=http://bbdaniels.github.io">
</head>
<body>
<p>Put any cool message you want here.</p>
@bbdaniels
bbdaniels / minimum-detectable-effect.do
Last active December 7, 2018 20:05
Power calculations by simulation
// Want to know the minimum detectable effect size?
// Explore power for different treatment effect sizes with a given sample size.
clear
set matsize 5000
cap mat drop results
qui forval te = 0(0.1)1 { // Loop over treatment effect sizes (te) of 0 to 1 standard deviations at increments of 0.1 SDs
forval i=1/1000 { // Running this loop 1000 times
clear
@bbdaniels
bbdaniels / globals.do
Last active January 17, 2019 22:55
Ben's useful boilerplate for Stata
** Load all the adofiles!
local adoFiles : dir `"${directory}/ado/"' files "*.ado"
local adoFiles = subinstr(`" `adoFiles' "', `"""' , "" , .)
foreach adoFile in `adoFiles' {
qui do "${directory}/ado/`adoFile'"
}
** Useful globals for everybody!
@bbdaniels
bbdaniels / outwriter.ado
Created November 13, 2018 16:59
Does something
// Write values
forvalues i = 2/`nRows' {
forvalues j = 2/`nCols' {
// Get the placement
local theCol : word `j' of `c(ALPHA)'
local theRow = `i'
// Get the values
local nStars = `anything'_STARS[`=`i'-1',`=`j'-1']
@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