Skip to content

Instantly share code, notes, and snippets.

@hafen
hafen / Howto.md
Created April 29, 2021 20:06 — forked from brentjanderson/Howto.md
SSH Tunneling with Firefox

Sometimes it is useful to route traffic through a different machine for testing or development. At work, we have a VPN to a remote facility that we haven't bothered to fix for routing, so the only way to access a certain machine over that VPN is via an SSH tunnel to a machine that is reachable over the VPN. Other times, I have used this technique to test internet-facing requests against sites I am developing. It is pretty easy, and if you don't use firefox regularly, you can treat Firefox as your "Proxy" browser and other browsers can use a normal configuration (Although you can also configure an entire system to use the proxy, other articles exists that discuss this potential).

  1. Open a terminal
library(geofacet)
library(ggplot2)
# original plot
ggplot(election, aes(candidate, votes / 1000000, fill = candidate)) +
geom_col() +
scale_fill_manual(values = c("#4e79a7", "#e15759", "#59a14f")) +
facet_geo(~ state, grid = "us_state_grid2") +
coord_flip() +
ylab("Votes (millions)")
# need to install dev version of trelliscopejs
# remotes::install_github("hafen/trelliscopejs@dev")
library(shiny)
library(dplyr)
library(tidyr)
library(ggplot2)
library(trelliscopejs)
ui <- fixedPage(
We can't make this file beautiful and searchable because it's too large.
county,state_code,date,price_sqft
Los Angeles County,CA,2010-01-01,268.328220858896
Cook County,IL,2010-01-01,188.178775653739
Harris County,TX,2010-01-01,75.4304926051459
Maricopa County,AZ,2010-01-01,99.2951353158021
San Diego County,CA,2010-01-01,246.575342465753
Orange County,CA,2010-01-01,299.92
Kings County,NY,2010-01-01,415.203213610586
Miami-Dade County,FL,2010-01-01,NA
Dallas County,TX,2010-01-01,84.6599081667261
state state_code date price_sqft
California CA 2010-01-01 210.122201268017
Texas TX 2010-01-01 85.6079404466501
New York NY 2010-01-01 180.017605633803
Florida FL 2010-01-01 119.673447576149
Illinois IL 2010-01-01 136.871508379888
Pennsylvania PA 2010-01-01 121.387283236994
Ohio OH 2010-01-01 87.530680258351
Michigan MI 2010-01-01 86.3696808510638
Georgia GA 2010-01-01 94.0489737098581
library(geofacet)
# get Connecticut county boundaries from USAboundaries package
counties <- USAboundaries::us_counties(states = "connecticut")
# convert to SpatialPolygonsDataFrame
# (will be more tolerant of different spatial types in the future)
counties <- as(counties, "Spatial")
# remove unneeded columns
@hafen
hafen / getsysreqsdb.R
Created April 19, 2018 23:24
Get R sysreqsdb content
# one time only package installation:
# install.packages(c("gh", "jsonlite", "base64enc"))
# get list of files
repo <- gh::gh("/repos/r-hub/sysreqsdb/contents/sysreqs")
# for every file, get its content, decode it, and return the data
data <- lapply(repo, function(x) {
message(x$name)
content <- gh::gh(sprintf("/repos/r-hub/sysreqsdb/contents/%s", x$path))
x y
2010-10-06 00:03:00 143
2010-10-06 00:08:00 147
2010-10-06 00:13:00 150
2010-10-06 00:18:00 152
2010-10-06 00:23:00 152
2010-10-06 00:28:00 152
2010-10-06 00:33:00 154
2010-10-06 00:38:00 155
2010-10-06 00:43:00 142
{
"57ba29691ef731fad0a64e2b6f80a258": {
"version": "0.12.6",
"title": "Bokeh Figure",
"roots": {
"root_ids": [
"94dc4a59d0f4a1255c1f25135cc15e70"
],
"references": [
{
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>box_annotation.py example</title>
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-0.12.6.min.css" type="text/css" />
<script type="text/javascript" src="https://cdn.pydata.org/bokeh/release/bokeh-0.12.6.min.js"></script>