layout | author | title | revision | version | description |
---|---|---|---|---|---|
default |
mattmc3 |
Modern SQL Style Guide |
2019-01-17 |
1.0.1 |
A guide to writing clean, clear, and consistent SQL. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Before running, load ecoregions, ecosections, bec, nr regions | |
-- to the db with the same schema.table name as in bcgw | |
-- This assumes using ogr2ogr for the load, it creates the objectid columns | |
-- ---------------------------- | |
-- first, overlay designatedlands with nr regions | |
-- ---------------------------- | |
DROP TABLE IF EXISTS nr_sub; | |
CREATE TABLE nr_sub AS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(sf) | |
library(dplyr) | |
library(fasterize) | |
shape <- "MULTIPOLYGON (((1126095 1246073, 1126221 1246053, 1126358 1246059, 1126383 1245909, 1126457 1245800, 1126605 1245831, 1126756 1245812, 1126812 1245652, 1126805 1245526, 1126841 1245377, 1126859 1245227, 1126868 1245077, 1126881 1244927, 1126949 1244805, 1126954 1244667, 1126806 1244635, 1126658 1244602, 1126508 1244591, 1126358 1244591, 1126283 1244701, 1126248 1244825, 1126256 1244951, 1126219 1245100, 1126197 1245249, 1126175 1245374, 1126145 1245498, 1126114 1245622, 1126025 1245743, 1125919 1245839, 1125803 1245897, 1125638 1245928, 1125547 1246037, 1125693 1246143, 1125842 1246150, 1126095 1246073)))" | |
tictoc::tic() | |
## Actually connect to the database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gganimate) | |
library(mgcv) | |
library(mvtnorm) | |
# Fit a GAM to the data | |
mod <- gam(hp ~ s(mpg), data=mtcars, method="REML") | |
# Get the linear prediction matrix | |
newdat = data.frame( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/munki/munki-python | |
# change the above path to your own python if you don't have Munki installed | |
""" | |
Merges add_servers into current favorites and removes remove_servers. | |
Run as root to update all users or as normal user to update just that user. | |
""" | |
import os | |
import getpass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Plot a ggmap object when you will be adding geom_sf() layers | |
#' | |
#' This is a wrapper around [ggmap::ggmap()], that transforms the bounding | |
#' box of the ggmap object to epsg:3857, which is what the underlying | |
#' data is in. This allows you to add `geom_sf()` layers with a crs | |
#' of epsg:3857 and have them line up properly. | |
#' | |
#' See [this stackoverflow question](https://stackoverflow.com/q/47749078/1736291) | |
#' | |
#' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TODAY=`date +%Y-%m-%d` | |
TODAY_MD=`date +%B\ %d,\ %Y` | |
YEAR=`date +%Y` | |
PACKAGENAME=$1 | |
## | |
## CHANGE ME!!! |
library(sf)
#> Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 5.0.0
library(rmapshaper)
library(geojsonio)
#>
#> Attaching package: 'geojsonio'
#> The following object is masked from 'package:base':
#>
#> pretty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
camel_to_snake <- function(x, case = c("lower", "upper")) { | |
case <- match.arg(case) | |
case_fun <- switch(case, lower = tolower, upper = toupper) | |
case_fun(gsub("([a-z0-9])([A-Z]+)", "\\1_\\2", x)) | |
} | |
snakeToCamel <- function(x) { | |
x <- tolower(x) | |
gsub("([a-z0-9]+)_([a-z0-9])", "\\1\\U\\2\\E", x, perl = TRUE) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"editor.fontFamily": "'Operator Mono Lig', Iosevka, Menlo, Monaco, 'Courier New', monospace", | |
"editor.fontLigatures": true, | |
"editor.fontSize": 14, | |
"editor.tabSize": 2, | |
"editor.wordWrap": "on", | |
"r.rterm.mac" : "/usr/local/bin/rtichoke", | |
"r.rterm.option" : [], | |
"r.lintr.enabled": false, | |
"terminal.external.osxExec": "iTerm.app", |