Skip to content

Instantly share code, notes, and snippets.

View briandk's full-sized avatar

Brian A. Danielak briandk

View GitHub Profile
@briandk
briandk / stringingFormulaVariablesTogether.r
Created September 17, 2014 00:16
Helping Cynthia with her problem
getFormula <- function(checkboxOutput, variablesThatMustAppearInModel) {
formula <- "testScores ~"
variables1 <- paste(variablesThatMustAppearInModel, collapse = " + ")
variables2 <- paste(checkboxOutput, collapse = " + ")
fullCall <- paste(variables1,
variables2,
collapse = " + ",
sep = " + ")
return(paste(formula,
fullCall))
@briandk
briandk / sampleSchemCode.scm
Created September 22, 2014 20:59
Syntax color testing for scheme
(define (clockpatience cards)
(let ((hand (deal cards 'K)))
(play (topcard 'K hand) 'K hand 1)
)
)
@briandk
briandk / precommit.sh
Created October 3, 2014 22:11
a precommit hook for naive build versioning in R package development
#!/bin/bash
D=`date +%Y%m%d%H%M%S`
branch=`git status|grep -ie 'on branch master'`
if [ -z "$branch" ]; then
cat DESCRIPTION | sed -e 's/^\(Version: [0-9]*\.[0-9]*\).*/\1.'$D'/' > DESCRIPTION.temp
rm DESCRIPTION
mv DESCRIPTION.temp DESCRIPTION
git add DESCRIPTION
@briandk
briandk / cantorDiagonal.py
Last active August 29, 2015 14:08
Cantor's Diagonal Proof Code
complement = {0: 1,
1: 0} # Maps 0 to 1 and vice versa
newNumber = [] # Initialize an empty list as a new number
def CantorDiagonal(MatrixOfAllNumbers, newNumber):
for i in range(len(MatrixOfAllNumbers)):
"""
Remember, the length of the matrix is infinite,
so this loop runs forever. It scans the diagonal
@briandk
briandk / danielakResearchStatement.Rmd
Last active August 22, 2023 09:21
My research statement
---
title: Danielak - Statement of Research Experience
output: rmarkdown::tufte_handout
---
## My experience, knowledge, and interest in PER
I spent five years at the University of Maryland--College Park (UMD) as a National Science Foundation Disciplinary Expert in Science Education Research. While there, I was an active member of UMD's Physics Education Research Group (PERG), presenting at the AAPT 2010 Winter Meeting and attending the 2012 AAPT Summer Meeting and PERC. My core areas of expertise, evidenced in both my dissertation[^1] and my first-authored journal publication[^2], include:
- **6** years of experience conducting clinical interviews with students and engineers to understand their cognition and practices
@briandk
briandk / pasteUsingSepAndCollapseInR.R
Created November 27, 2014 07:11
Understanding `sep` and `collapse` in R using `paste()
# The difference between the `sep` and `collapse` arguments
# in paste can be thought of like this:
#
# paste can accept multiple *vectors* as input, and will
# concatenate the ith entries of each vector pairwise
# (or tuplewise), if it can.
#
# When you pass paste multiple vectors, sep defines what
# separates the entries in those tuple-wise concatenations.
#
@briandk
briandk / transdown.js
Created November 30, 2014 22:49
transdown debugging
var transdownNamespace = {
updatePreviewAfterEachKeypress : function () {
$('#text-to-transdownify').keyup(this.renderTranscriptPreview);
},
transdownify : function (text) {
return (text);
},
renderTranscriptPreview : function () {
@briandk
briandk / logicalToBinary.scm
Created December 9, 2014 06:27
Inspired by Wil Doane, this is a probably broken function that's designed to take a list of 0s and 1s (say, from a matrix of indicator values like "single", "employed", "ownsHome") and generate a unique integer to represent that binary string
​(define (logicalToBinary listOfZeroesAndOnes powerOfTwo runningSum)
(if (= (cdr listOfZeroesAndOnes) `()); Not sure if this is right, but it should be "if you've exhausted the list,
; implemented as "if the remainder of the list equals an empty list"
; http://stackoverflow.com/questions/9115703/null-value-in-mit-scheme
runningSum)
(else return (logicalToBinary (cdr listOfZeroesAndOnes)
(+ powerOfTwo 1)
(+ runningSum (* runningSum powerOfTwo)))))
@briandk
briandk / usingMapWithAnExternalContext.js
Last active August 29, 2015 14:11
Figuring out how to pass an external context to a JavaScript map function. Why? Say you want a function that operates element-wise on an array, but generates results that it needs to add to some outside object, like an array or a dictionary.
var myDictionary = {
rocket: 'Atlas V',
spaceport: 'Cape Canaveral',
astronauts: [
'Brian',
'Wil'
]
};
var getValueFromExternalDictionary = function (currentKey, indexOfCurrentKey) {
@briandk
briandk / magrittrExamples.R
Last active August 29, 2015 14:12
Formatting conventions for piping with magrittr in R
df <-
  df %>%
  select(col1 = str_split(oldcol2, ','),
         col2,
         col3 = paste0(oldcol1, 'amber')) %>%
  filter(col1 == "America" | col2 >= 55) %>%
  group_by(col1, col2) %>%
  summerize(count = n())
df <-