Skip to content

Instantly share code, notes, and snippets.

Lars Vilhuber larsvilhuber

Block or report user

Report or block larsvilhuber

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@larsvilhuber
larsvilhuber / program.R
Created Jan 30, 2020
Conditional handling of (non-distributable) absent data
View program.R
# this project might have some confidential data that cannot be distributed
# Rather than break the program, or worse, ask replicators to comment out lines,
# provide a clean skip of those things, or even an alternate output (robustness check?)
basepath <- c("/path/to/project")
# or :
# basepath <- here::here()
# set filepaths relative to basepath
confidential <- file.path(basepath,"data","confidential")
@larsvilhuber
larsvilhuber / aeagit
Created Jan 27, 2020
bitbucket shortcut for AEA
View aeagit
#!/bin/bash
AEASRC=git@bitbucket.org:aeaverification
call=$0
urlbase=https://aeadataeditors.atlassian.net/browse/AEAREP-
os=$(uname)
codeeditor=$(which code)
function code {
case $os in
Linux)
@larsvilhuber
larsvilhuber / add_datatoggle.sh
Last active Jan 14, 2020
Add a Data Toggle Tile to Samsung devices without root
View add_datatoggle.sh
#!/bin/bash
# Based on https://www.xda-developers.com/how-to-restore-mobile-data-quick-settings-tile-toggle-on-samsung-galaxy-devices/
# This will work with minor adjustments to your installation of the Android SDK or wherever you put adb.
# Should work on Linux and Mac, but only tested on Linux
PATH=../android-sdk-linux/platform-tools:$PATH
outfile=list.$(date +%F)
adb devices
echo "Do you see your device? [y|N]"
View hamming.tex
The \emph{Hamming} metric on $\mscr X^n$ is $H: \mscr X^n \times \mscr X^n \rightarrow \ZZ^{\geq 0}$, defined by $H(\ul x,\ul x') =\# \{i \mid x_i\neq x'_i\}$. %In other words, the Hamming distance counts the number of entries that differ between $X$ and $X'$.
@larsvilhuber
larsvilhuber / git_remotes.bash
Created Aug 5, 2019
git setup all remote branches
View git_remotes.bash
#!/bin/bash
# Credit:
# https://stackoverflow.com/questions/67699/how-to-clone-all-remote-branches-in-git
for branch in $(git branch --all | grep '^\s*remotes' | egrep --invert-match '(:?HEAD|master)$'); do
git branch --track "${branch##*/}" "$branch"
done
@larsvilhuber
larsvilhuber / config.do
Last active Jun 8, 2019
A stata config file to store parameters and file paths in a single project-specific location
View config.do
/* config.do */
/* Suggested by Lars Vilhuber */
/* Create a reproducible Stata sequence by calling this program from every other program in your sequence */
/* Get it at: https://gist.github.com/larsvilhuber/6bcf4ff820285a1f1b9cfff2c81ca02b */
/* Usage:
Adapt to your needs, save as config.do, then add
include "config.do"
in the author's main Stata program
*/
View global-libraries.R
####################################
# global libraries used everywhere #
####################################
# Package lock in - optional
MRAN.snapshot <- "2019-01-01"
options(repos = c(CRAN = paste0("https://mran.revolutionanalytics.com/snapshot/",MRAN.snapshot)))
pkgTest <- function(x)
{
if (!require(x,character.only = TRUE))
View Uploading to repositories
figshare: https://github.com/elifesciences/datacapsule-crossref
zenodo: https://developers.zenodo.org/#quickstart-upload
dataverse: https://github.com/IQSS/dataverse-uploader/wiki/DVUploader,-a-Command-line-Bulk-Uploader-for-Dataverse
@larsvilhuber
larsvilhuber / biblatex-doc.tex
Last active Dec 29, 2018
Default biblatex setup
View biblatex-doc.tex
%!TeX TXS-program:bibliography = txs:///biber
\documentclass{article}
\usepackage{authblk}
\usepackage[%
plainpages,%
colorlinks,% removes the boxes around links
urlcolor=black,%
filecolor=black,%
citecolor=Blue,% requires xcolor with option dvipsnames
pdfpagemode=UseOutlines,%
@larsvilhuber
larsvilhuber / acrodefs.tex
Created Dec 20, 2018
acronyms frequently used by me
View acrodefs.tex
%TCIDATA{Version=5.00.0.2570}
%TCIDATA{LaTeXparent=0,0,sw-edit.tex}
% $Id: acronyms.tex 11537 2014-05-27 03:52:54Z vilhuber $
% $URL: https://trac.vilhuber.org/svn/LEHD/branches/ticket983-snapshot2012/05_documentation/acronyms.tex $
%
% Define acronyms to be used in the text here. See
% http://www.mackichan.com/index.html?techtalk/456.htm~mainFrame for usage in
% Scientific workplace context
You can’t perform that action at this time.