Skip to content

Instantly share code, notes, and snippets.

View tyleransom's full-sized avatar

Tyler Ransom tyleransom

View GitHub Profile
@tyleransom
tyleransom / NppVimCrosswalk.md
Last active February 29, 2024 17:10
Crosswalk between Notepad++ and Vim utilities

Crosswalk between Notepad++ and Vim utilities

Action Notepad++ shortcut Vim shortcut
Duplicate line Ctrl+D yyp
Cut line Ctrl+L dd
Move line up/down Ctrl+Shift+<up/down> dd<k/j>p
Compare files File compare plugin wizard :vsplit <filename> or vimdiff file1 file2 (from command line)
Select all (from here to top/bottom of file) Ctrl+Shift+<home/end> v<gg/G>
Select all (from here up/down one page) Ctrl+Shift+ v Ctrl+
@tyleransom
tyleransom / linking_with_embeddings.R
Last active January 17, 2024 01:59
Using embeddings to fuzzy match databases
library(tidyverse)
library(openai)
#-------------------------------------------------------------------------------
# Step 1: Open AI API key
#-------------------------------------------------------------------------------
# Your OpenAI API key should be an environment variable you set in ~.Renviron
# ... you should never put your API key directly in your code!
@tyleransom
tyleransom / gcc-5.4.0-install.sh
Last active January 11, 2024 05:47 — forked from jdhao/gcc-5.4.0-install.sh
The script will install GCC 5.4.0 on your CentOS 7 system, make sure you have root right.
echo "Downloading gcc source files..."
curl https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.bz2 -O
echo "extracting files..."
tar xvfj gcc-5.4.0.tar.bz2
echo "Installing dependencies..."
yum install gmp-devel mpfr-devel libmpc-devel
echo "Configure and install..."
@tyleransom
tyleransom / container_btiming.jl
Created November 16, 2023 02:47
Julia Benchmarking of Data Containers
using Statistics, BenchmarkTools, DataFrames, Random
Random.seed!(1234)
mutable struct allParmsM
x::Float64
end
# fill in the mutable struct with the values
allpM = allParmsM(
5.784 # x
@tyleransom
tyleransom / JHRchecklist.md
Last active July 2, 2023 12:30
Checklist for converting LaTeX PDF to Microsoft Word for *Journal of Human Resources* publication process

Make following formatting changes in LaTeX before importing the resulting PDF into Word

  • Sections and subsections numbered like "II.A.1" (add following to end of preamble)
    • \renewcommand{\thesection}{\Roman{section}}
    • \renewcommand{\thesubsection}{\thesection.\Alph{subsection}}
    • \renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
  • roman numeraled endnotes instead of footnotes (add following to preamble)
    • \usepackage{endnotes}
    • \let\footnote=\endnote
    • \renewcommand{\theendnote}{\roman{endnote}}
  • put "\theendnotes" just before the online appendix
* Dodging local macros (backtick)
* works
file open tb using "test1.tex", write replace
file write tb "These are backticks: " "`" "`" "air quotes''. "_n
file close tb
* works
!echo "These are backticks:" "`=char(92)'`=char(96)'""`=char(92)'`=char(96)'""air quotes''." > test2.tex
@tyleransom
tyleransom / grapher.R
Created February 21, 2023 04:12
graph-spline
library(ggplot2)
# create a matrix with the given points
pts <- matrix(c(3, 3, 3, 3, 3, 3, 3, 0.5, -1, -3, 1, 1.5, 2.75, 3, 1.25, 1.75, 0, 4, 8, 12, 16, 20, 23, 24, 25, 37, 38.5, 48, 60, 69, 71, 84), ncol = 2, byrow = F)
# sort the points by x value
pts <- pts[order(pts[, 2]), ]
# create the spline interpolation function
interp <- splinefun(pts[, 2], pts[, 1], method = "natural")
@tyleransom
tyleransom / NHANES.R
Last active October 13, 2022 21:48
Data manipulation code files for undergrad econometrics class
library(NHANES)
library(tidyverse)
library(magrittr)
library(modelsummary)
df <- as_tibble(NHANES)
datasummary_skim(df, type="categorical")
datasummary_skim(df, type="numeric")
@tyleransom
tyleransom / build-gcc-4.7.sh
Created August 31, 2018 22:33
Script to build GCC 4.7.x on newer Linux distributions (using
#!/bin/bash
#Download source
wget http://mirrors.concertpass.com/gcc/releases/gcc-4.7.2/gcc-4.7.2.tar.bz2
tar xvfj gcc-4.7.2.tar.bz2
cd gcc-4.7.2
./contrib/download_prerequisites
#Download and apply fix to be able to build GCC 4.7 with GCC 5.x
@tyleransom
tyleransom / test-optional.R
Last active July 13, 2022 12:35
Adoption of test-optional admissions policies over time
library(tidyverse)
library(magrittr)
library(pdftools)
# get a timeline of movement to test optional from fairtest.org
# url accessed on 30 Jun 2022
optl <- pdf_text(pdf = "https://www.fairtest.org/sites/default/files/Optional-Growth-Chronology.pdf") %>% str_split('\n')
optdf <- list()
for (i in seq(1:18)) {
print(length(optl[[i]]))