Skip to content

Instantly share code, notes, and snippets.

View MilesMcBain's full-sized avatar

Miles McBain MilesMcBain

  • Queensland Fire and Emergency Services
  • Brisbane, Queensland
View GitHub Profile
@MilesMcBain
MilesMcBain / rofi.cfg
Created July 17, 2018 02:19
vim like keys for rofi
rofi.kb-row-up: Up,Control+k,Shift+Tab,Shift+ISO_Left_Tab
rofi.kb-row-down: Down,Control+j
rofi.kb-accept-entry: Control+m,Return,KP_Enter
rofi.terminal: mate-terminal
rofi.kb-remove-to-eol: Control+Shift+e
rofi.kb-mode-next: Shift+Right,Control+Tab,Control+l
rofi.kb-mode-previous: Shift+Left,Control+Shift+Tab,Control+h
rofi.kb-remove-char-back: BackSpace
@MilesMcBain
MilesMcBain / recurse_html.R
Created July 29, 2022 03:59
recurse_html.R
library(tibble)
library(purrr)
library(tidyr)
library(htmltools)
library(dplyr)
df <- tibble::tribble(
~level_1, ~level_2, ~level_3,
"coffee", "espresso", "with milk",
"coffee", "espresso", "without milk",
@MilesMcBain
MilesMcBain / bike_share_filter_rdeck.R
Created July 8, 2022 01:31
Demo of the {rdeck} feature editor with {shiny}
library(shiny)
library(rdeck)
library(sf)
sf::sf_use_s2(FALSE)
library(spData)
library(dplyr)
library(ggplot2)
bikes <-
spData::cycle_hire
@MilesMcBain
MilesMcBain / cloud_view.R
Created June 27, 2022 23:50
cloud_view()
cloud_view <- function(obj) {
withr::with_options(
list(viewer = function(url, ...) {
get_url_dir <- function(url) gsub("file://|/index.html", "", url)
server <- servr::httd(
dir = get_url_dir(url),
verbose = TRUE,
browser = FALSE
)
.vsc.browser(server$url, ...)
@MilesMcBain
MilesMcBain / .Rprofile
Created June 29, 2022 00:08
remote .Rprofile VSCode settings
options(
vsc.rstudioapi = TRUE,
vsc.browser = "Beside",
vsc.dev.args = list(width = 1200, height = 900),
vsc.str.max.level = 2
)
@MilesMcBain
MilesMcBain / base_r_travel_time_sim.R
Last active August 18, 2021 05:11
vectorised base R simulation
library(tidyverse)
do_sim <- function() {
n_locations <- 1000
n_stations <- 10
n_sources <- n_stations + n_locations
n_incidents <- 20000
n_replicates <- 100
probabilities <- seq(0.7, 1, by = 0.05)
@MilesMcBain
MilesMcBain / concat_maps.R
Last active April 15, 2021 23:52
concat_maps.R
concat_maps <- function(...) {
rdeck_maps <- list(...)
rdeck_map_names <- names(rdeck_maps)
rdeck_map_names[nzchar(rdeck_map_names) == 0] <- "Base layers"
# set up init for reduce
container <- rdeck_maps[[1]]
container$x$layers <-
map(container$x$layers, function(layer) {
layer$group_name <- rdeck_map_names[[1]]
layer$visibility_toggle <- TRUE
@MilesMcBain
MilesMcBain / example.R
Created March 12, 2021 11:25
Prepare languageserver tcp client
client <- TCPLanguageClient$new(port = 8888) #session 1
run(port = 8888) # session 2
client$start()
data <- client$fetch(blocking = TRUE)
client$handle_raw(data)
## do stuff with client
client %>% did_save(defn_file_path2)
result <- client %>% respond_document_symbol(defn_file_path2)

as per: aws_overpass_instance.md

  • docker
  • aws cli
    • aws credentials

get osrm australia data from s3

 aws s3 cp s3://pims-osrm-source-data/australia-latest.osm.bz2 ./australia-latest.osm.bz2
@MilesMcBain
MilesMcBain / crunchy.R
Last active March 5, 2021 02:08
ra30 res 9
system.time({
library(conflicted)
library(qfes)
library(tidyverse)
library(rmapshaper)
library(sf)
library(h3jsr)
library(furrr)
library(future)
library(rdeck)