Use Python to:
- send a plain text email
- send an email with attachment
- receive and filter emails according to some criteria
library(maptools) | |
library(maps) | |
library(mapdata) | |
library(rjson) | |
library(stringr) | |
library(RCurl) | |
library(ggplot2) | |
GetDirections <- function(from, to) { |
require(MASS) | |
require(ggplot2) | |
require(scales) | |
require(gridExtra) | |
pca <- prcomp(iris[,-5], | |
center = TRUE, | |
scale. = TRUE) | |
prop.pca = pca$sdev^2/sum(pca$sdev^2) |
library(cartography) | |
library(sp) | |
library(sf) | |
# Load data | |
data(nuts2006) | |
# Save image | |
sizes <- getFigDim(x = nuts0.spdf, width = 700, mar = c(0,0,0,0), res = 100) | |
png('./img/map8.png', width = sizes[1], height = sizes[2], res = 100) |
Use Python to:
Earlier this year, I was lucky enough to get my hands on one of the Google AIY Voice Kits for the Raspberry Pi 3. With the kit and some walk-through coding, the kit is a developer example of accessing the Google Assistant and turning a Raspberry Pi into a makeshift Google Home. The project was cool, but I already had a Google Home, so I decided to mess around with the hardware instead.
Eventually, I decided to turn the device into a small, offline jukebox as a gift for my mom, who is a big fan of 80s music. When you hit the button on the top, a random 80s song starts playing. A knob on the side allows for volume adjustment. (Unfortunately, once the song starts playing, it can't easily be stopped. The volume knob can also click in like a button, which I intended to use to stop the music by stopping the music script and immediately restarting it. However, when I was messing with the knob, the button got jammed in, and so I abandoned that idea. Instead, the user can just turn the volume down to zero.)
The hard
library("sf") | |
library("dplyr") | |
library("hexbin") | |
# Linux libertine fint "sf", converted to path with Inkscape, | |
# added points between existing points 2 times, then turned all segments into straight lines. | |
# Saved as SVG with absolute coordinates (Preferences > SVG Output > Path Data). | |
# Loaded coords from SVG source code, remove letters from start and end, and replace " " with "," | |
coords_f <- c(218.1169,163.46992,215.56952,177.96334,213.51976,189.84421,211.82546,200.33884,210.34442,210.67351,208.24728,226.35176,205.51032,243.54066,201.92029,259.27223,197.26391,270.57846,195.45112,272.90665,193.28288,274.70167,190.97247,275.85687,188.73314,276.26564,187.03291,276.03164,185.79476,275.38887,184.84097,274.42619,183.99382,273.23248,182.45947,271.13533,180.24976,269.10927,177.54243,267.58084,174.51519,266.97658,171.25987,267.58973,169.08867,269.18036,167.87718,271.37526,167.501,273.8012,168.44294,277.0032,171.48203,279.79643,176.93817,281.77214,185.13126,282.52154,191.01986,281.80176,196.83737,279.60686,202.29944, |
# started with `foghorn`, but that comes with dependencies and | |
# slows down R startup. `browseURL` just barely slows startup, | |
# even if actual page is slow to load. | |
check_cran_old <- function(email) { | |
utils::browseURL( | |
sprintf( | |
"https://cran.r-project.org/web/checks/check_results_%s.html", | |
gsub("[^A-Za-z0-9_:.-]", "_", sub("@", "_at_", email)) | |
) ) } |
library(tidyverse) | |
library(sf) | |
library(tigris) | |
# start by picking a state from https://github.com/Microsoft/USBuildingFootprints | |
# WARNING: these files can be pretty big. using arizona for its copious subdivisions and reasoanable 83MB. | |
url_footprint <- "https://usbuildingdata.blob.core.windows.net/usbuildings-v1-1/Arizona.zip" | |
download.file(url_footprint, "Arizona.zip") | |
unzip("Arizona.zip") |
# Download earth data first | |
# https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_land.zip | |
library(sf) | |
library(lwgeom) | |
library(dplyr) | |
library(ggplot2) | |
library(mapview) | |
# Read the data |
library(tidyverse) | |
library(sf) | |
library(sfnetworks) | |
library(cluster) | |
library(crsuggest) | |
library(tidygraph) | |
library(ggspatial) | |
# library(gganimate) | |
crsuggest::suggest_crs(roxel) | |
net <- roxel %>% |