Skip to content

Instantly share code, notes, and snippets.

View ianmcook's full-sized avatar

Ian Cook ianmcook

View GitHub Profile
@ianmcook
ianmcook / vcpkg_arrow_cpp_deps_install.txt
Last active January 25, 2021 16:25
output of vcpkg install arrow cpp dependencies
C:\Users\ian>vcpkg install --clean-after-build --triplet x64-windows --x-manifest-root C:\Users\ian\arrow\cpp
A suitable version of cmake was not found (required v3.19.2). Downloading portable cmake v3.19.2...
Downloading cmake...
https://github.com/Kitware/CMake/releases/download/v3.19.2/cmake-3.19.2-win32-x86.zip -> C:\vcpkg\downloads\cmake-3.19.2-win32-x86.zip
Extracting cmake...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Downloading 7zip...
https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> C:\vcpkg\downloads\7-zip.commandline.18.1.0.nupkg
Extracting 7zip...
A suitable version of nuget was not found (required v5.5.1). Downloading portable nuget v5.5.1...
@ianmcook
ianmcook / tx_la_weather_alerts.R
Created August 26, 2020 15:17
Map of active weather alerts for Texas and Louisiana
remotes::install_github("ianmcook/weatherAlerts")
remotes::install_github("ianmcook/weatherAlertAreas")
library(weatherAlerts)
library(leaflet)
alerts <- getAlerts(c("TX", "LA")) # takes about 45 seconds
severity <- alerts@data$severity
colorMap <- c(Minor = "green",
@ianmcook
ianmcook / nc_tornado_warnings_map.R
Last active March 18, 2021 22:07
Create map of North Carolina tornado alert polygons and home location
install.packages(c("ggmap", "leaflet", "sp"))
devtools::install_github("ianmcook/weatherAlerts")
devtools::install_github("ianmcook/weatherAlertAreas")
# geocode home address
library(ggmap)
register_google("ENTER_GCP_GEOCODING_API_KEY_HERE")
home <- geocode("University of North Carolina at Chapel Hill")
# or specify coordinates of home
@ianmcook
ianmcook / nc_tornado_warnings.R
Last active October 31, 2019 23:57
Map of active tornado warnings for North Carolina
library(weatherAlerts)
library(leaflet)
alerts <- getAlerts("NC") # takes a few seconds
alerts <- alerts[alerts$event == "Tornado Warning",]
leaflet() %>%
addTiles() %>%
addPolygons(data = alerts, color = "black", fillColor = "magenta", weight = 1)
@ianmcook
ianmcook / one_chess_set.csv
Last active October 4, 2019 21:53
Scatterplot of chess piece dimensions with ggplot2
piece base_diameter height weight
King 37.3086 95.1557 50.2774
King 36.9878 95.3598 51.5528
King 37.6846 94.8507 50.7298
King 37.4201 96.2158 50.9344
King 36.7413 95.5326 51.9347
King 36.8166 96.0273 51.2393
King 37.5822 95.8491 50.8103
King 37.4132 95.2667 52.2267
King 37.7643 94.9941 51.2417
@ianmcook
ianmcook / vented_box_equations.R
Created February 12, 2019 15:36
Vented box loudspeaker equations
# vented box loudspeaker equations
Qts <- 0.40 # property of driver
fs <- 19 # property of driver
Vas <- 260 # property of driver
# you choose an alignment,
# choose a QL (assume 7 for starters),
# then look up the following values
# in the appropriate table on LDC p.58-62:
@ianmcook
ianmcook / closed_box_equations.R
Created February 12, 2019 15:35
Closed box loudspeaker equations
# closed box loudspeaker equations
Qtc <- 0.707 # you choose this; see LDC p.24
Qts <- 0.40 # property of driver
fs <- 19 # property of driver
Vas <- 260 # property of driver
alpha <- (Qtc/Qts) ^ 2 - 1
fc <- (Qtc * fs) / Qts
@ianmcook
ianmcook / column_references_in_spark_dataframe_methods.py
Created September 14, 2018 20:05
Column references in Spark DataFrame methods
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StructField, IntegerType, StringType, FloatType
from pyspark.sql.functions import col, round
spark = SparkSession.builder.master('local').getOrCreate()
games = spark.createDataFrame(
[
(1, 'Monopoly', 'Elizabeth Magie', 1903, 8, 2, 6, 19.99),
(2, 'Scrabble', 'Alfred Mosher Butts', 1938, 8, 2, 4, 17.99),
@ianmcook
ianmcook / hive-jdbc-example.R
Last active April 26, 2021 05:51
Query Apache Hive from R using JDBC
# Copyright 2018 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@ianmcook
ianmcook / fl_weather_alerts.R
Last active September 10, 2017 17:04
Map of active weather alerts for Florida
devtools::install_github("ianmcook/weatherAlerts")
devtools::install_github("ianmcook/weatherAlertAreas")
library(weatherAlerts)
library(leaflet)
alerts <- getAlerts("FL") # takes about 30 seconds
severity <- alerts@data$severity
colorMap <- c(Minor = "green",