Skip to content

Instantly share code, notes, and snippets.

View mpadge's full-sized avatar
🤹‍♀️
Coding away ...

mark padgham mpadge

🤹‍♀️
Coding away ...
View GitHub Profile
@mpadge
mpadge / script.R
Created July 2, 2024 14:06
GitHub commit history hack (in R)
# Hand-coded letter forms (created for 2024-07-02):
dates <- c (
# ->
"20230705",
"20230712",
"20230717",
"20230719",
"20230721",
"20230725",
"20230726",
# download and store the data
library (osmdata)
library (dodgr0
library (bikedata)
bikedir <- "/data/data/bikes"
bikedb <- file.path (bikedir, "all_bike_data.sqlite")
cities <- bike_demographic_data ()$city
dl <- function ()
{
@mpadge
mpadge / gist:af71512eca0ed74b42099ad42d857a38
Created September 27, 2017 13:19
clang manual compile R package
# Run script anywhere in R package directory to manually run a clang pedantic check on all src files
cpp_flgs <- c_flgs <- "-Wall -pedantic -Werror"
setwd (here::here ("src"))
cmd_base <- paste ("-I/usr/share/R/include -DNDEBUG",
"-I\"/usr/local/lib/R/site-library/Rcpp/include\" -fpic",
"-g -O2 -fstack-protector-strong -Wformat",
"-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g")
flist_c <- list.files (".", pattern = "\\.c$")
for (f in flist_c)
{
@mpadge
mpadge / bikedata-testfiles.md
Created May 3, 2017 12:21
Script to create the `bikedata/data/bike-test-data.rda` file.

This gist can be used to create test files for the bikedata package. These are ultimately stored in an .rda structure, but this removes a lot of the original text-based idiosyncracies of the raw .csv files. This script is thus necessary to convert the read.csv() results back in to the precise forms of the individual .csv files for each city.

First step is to create sample test files for each city and compress them in .zip archives. These can then be unzipped and read into R with these lines:

@mpadge
mpadge / probrouter-ref.md
Last active April 12, 2017 08:51
probrouter-ref.md
devtools::load_all (".", export_all = FALSE)
## Loading osmprob
#devtools::load_all (".")
#devtools::document (".")
#devtools::check (".")
@mpadge
mpadge / newpkg.sh
Last active December 12, 2016 16:30
R package skeleton
#!/bin/bash
# AUTHORS: Bob Rudis <[email protected]> (@hrbrmstr)
# Mark Padgham <[email protected]>
# LICENSE: MIT + file zLICENSE
#
# Adapted by Mark Padgham from original gist of Bob Rudis
TODAY=`date +%Y-%m-%d`
TODAY_MD=`date +%B\ %d,\ %Y`
YEAR=`date +%Y`
@mpadge
mpadge / aaaline-tests.md
Last active June 2, 2016 16:11
Rcpp speed comparison for different ways of constructing sp objects

Compares Rcpp construction of sp::Line objects either:

  1. Constructed as new objects with slots filled directly, or
  2. Constructed the 'usual' way through filling the sp object with data.

In R terms, these are equivalent to:

library (sp)
# first way