Skip to content

Instantly share code, notes, and snippets.

@mattbk
mattbk / start_mail_ip.py
Last active February 20, 2016 23:04 — forked from johnantoni/startup_mailer.py
Raspberry Pi - Send email with public IP address (will need Gmail account to send from. Need to allow less secure apps at Gmail, see http://naelshiab.com/tutorial-send-email-python/).
# https://gist.github.com/johnantoni/8199088
import subprocess
import smtplib
import socket
from email.mime.text import MIMEText
import datetime
# Change to your own account information
to = 'TO@gmail.com'
gmail_user = 'YOU@gmail.com'
gmail_password = 'PASSWORD'
@mattbk
mattbk / timer.html
Created November 8, 2017 16:25
Double Feature Timer
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: black;
font-family: monospace;
}
</style>
@mattbk
mattbk / raster-brick-cases.R
Created June 4, 2019 18:55
Collapsing a raster brick to a single categorical raster
library(raster)
library(dplyr)
# Brick from https://gis.stackexchange.com/a/167514/65349
r1 <- raster(nrow=5, ncol=5)
b <- brick(setValues(r1, runif(ncell(r1))),
setValues(r1, runif(25 ,0.6,0.9)),
setValues(r1, runif(25 ,0.2,0.4)),
setValues(r1, runif(25 ,1,2)))
@mattbk
mattbk / add_z.R
Created September 5, 2019 17:13
Convert sf point set geometry from XY to XYZ using an existing column
add_z <- function(x, z_name){
st_geometry(x) <- st_sfc(st_multipoint(cbind(st_coordinates(x),
x[[z_name]]))) %>%
st_cast("POINT")
return(x)
}