Skip to content

Instantly share code, notes, and snippets.

View mpettis's full-sized avatar

Matt Pettis mpettis

  • Personal
  • Minneapolis, MN
View GitHub Profile
@drsimonj
drsimonj / multiple_lags.R
Last active July 8, 2022 14:53
Example of creating multiple lags with dplyr
library(dplyr)
d <- data_frame(x = seq_len(100))
d
#> # A tibble: 100 x 1
#> x
#> <int>
#> 1 1
#> 2 2
#> 3 3
@arcaravaggi
arcaravaggi / update_migrate.R
Last active May 3, 2024 16:26
Update R and migrate R packages to new installation from within the console
#From https://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r
# Run in the old version of R (or via RStudio)
setwd("C:/Temp/")
packages <- installed.packages()[,"Package"]
save(packages, file="Rpackages")
# INSTALL NEW R VERSION
if(!require(installr)) { install.packages("installr"); require(installr)} #load / install+load installr
# See here for more on installr: https://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/
@zehnpaard
zehnpaard / simple-compojure.core.clj
Created October 30, 2016 06:03
Simple Compojure Demo with GET/POST forms
(ns simple-compojure.core
(require
[ring.adapter.jetty :refer [run-jetty]]
[ring.middleware.params :as p]
[simple-compojure.middleware :as m]
[simple-compojure.routes :as r]
))
(def app
(-> r/routes
@clarle
clarle / hour_summary.R
Last active September 14, 2018 21:50
Summing hours in HH:MM:SS format in R
library(dplyr)
library(tidyr)
library(lubridate)
# Parse data from HH:MM:SS format into something that can be used by `lubridate`
hours %>%
separate(Duration, into = c("hours", "minutes", "seconds"), sep = ":", convert = TRUE) %>%
summarize(total_time = duration(hour = sum(hours), minute = sum(minutes), second = sum(seconds)))
@EderSantana
EderSantana / CATCH_Keras_RL.md
Last active October 16, 2023 08:32
Keras plays catch - a single file Reinforcement Learning example
@dewittpe
dewittpe / build-script.R
Last active November 28, 2021 15:47
Equation Numbering in Rmd
library(rmarkdown)
library(knitr)
render("eqn-numbering.Rmd")

Kim's Very Long and Boring Email Text File about File Versioning and Servers.

Hello all.

This is A Very Long and Boring Email Text File about File Versioning and Servers.

Please feel free to point and laugh, but this is all stuff that I've learnt the hard way, and that we should start to do as we get bigger. It doesn't take long for all this to become a habit; something you don't even think about doing. When it's working properly, it offloads a load of organisational stuff from your brain, too - which is nice, and what computers should help you do.

// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))