Skip to content

Instantly share code, notes, and snippets.

View kbjarkefur's full-sized avatar
🌱
seeding

Kristoffer Bjärkefur kbjarkefur

🌱
seeding
View GitHub Profile
/*************************************
This gist shows how to use iebaltab to generate statistics and use them
in customized tex tables instead of using the iebaltab's default output
**************************************/
********************************
* Set up mock data example
@kbjarkefur
kbjarkefur / pool-tiebreaker.do
Last active December 19, 2022 13:08
pool-tiebreaker
qui {
* Fill in the entry fee and number of entried
local entry_fee = 5
local entries = 16
* rounding to take care of some floating point math issue
local pool = round(`entry_fee' * `entries',1)
* Fill in the how many people placed 1st, 2nd, 3rd
local ties_1st 1
local ties_2nd 1
@kbjarkefur
kbjarkefur / README.md
Last active May 30, 2024 12:43
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

@kbjarkefur
kbjarkefur / 2018-11-08-continued-education-ado-files.md
Last active March 19, 2022 00:26
DIME Continued Education - November 08, 2018

How to write programs (also called commands or functions) in Stata

This is an introduction to how to write programs in Stata. To try this out yourself, download this Gist by clicking Download Zip. Unpack the .zip file and edit the path global in the runfile.do. Then follow these instructions and run the corresponding section of the run file.

If you have any questions or want us to add another examples on how you can expand myhist.ado as us in the comment section below.

Hello World

It is common in computer science that the first function/command you write is a simple command that just display the message Hello World!. That is what the program in hello_world.ado does.

@kbjarkefur
kbjarkefur / Add-sub-functions.md
Last active June 22, 2019 08:32
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 agrees 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