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
| import asyncio | |
| from typing import Coroutine, List, Sequence | |
| def _limit_concurrency( | |
| coroutines: Sequence[Coroutine], concurrency: int | |
| ) -> List[Coroutine]: | |
| """Decorate coroutines to limit concurrency. | |
| Enforces a limit on the number of coroutines that can run concurrently in higher |
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
| # Ben Fasoli | |
| library(sp) | |
| library(rgdal) | |
| shape <- readOGR(dsn = 'data', layer = 'four_samples') | |
| head(shape@polygons[[1]]@Polygons[[1]]@coords) | |
| # [,1] [,2] | |
| # [1,] -111.6227 40.75247 |
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 | |
| # SOCKS proxy via ssh tunnel for MacOS | |
| # Install to /usr/local/bin/tunnel with: | |
| # curl https://gist.githubusercontent.com/benfasoli/543c14c90a4909e0305180bd8423969e/raw/ > /usr/local/bin/tunnel && chmod +x /usr/local/bin/tunnel | |
| TARGET=$1 | |
| if [ -z "$TARGET" ]; then | |
| echo -n "SSH target (e.g. name@server.com): " | |
| read TARGET | |
| fi |
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/bin/env Rscript | |
| options(dplyr.summarise.inform = F) | |
| library(data.table) | |
| library(htmlwidgets) | |
| library(leaflet) | |
| library(tidyverse) | |
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/bin/env Rscript | |
| library(htmlwidgets) | |
| library(leaflet) | |
| library(raster) | |
| library(viridis) | |
| path <- 'example-footprint.nc' | |
| footprint <- brick(path) | |
| footprint |
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(ggplot2) | |
| library(metR) | |
| time <- Sys.time() | |
| n <- 50 | |
| data <- data.frame( | |
| time = seq(time - 3600, time, length.out = n), | |
| direction = seq(0, 359, length.out = n), | |
| magnitude = 5 * sin(seq(0, 2 * pi, length.out = n)) | |
| ) |
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/bin/env python3 | |
| import io | |
| import pandas as pd | |
| api_response_csv = """ | |
| x, y, z | |
| 1, 2, 3 |
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 | |
| set -e | |
| if [[ "$HOSTNAME" == "notchpeak"* ]]; then | |
| CLUSTER="np" | |
| elif [[ "$HOSTNAME" == "kingspeak"* ]]; then | |
| CLUSTER="kp" | |
| else | |
| echo "Unable to determine cluster from hostname: $HOSTNAME" > /dev/stderr | |
| exit 1 |
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
| // Ben Fasoli | |
| const int n = 6; | |
| const int pins[n] = {A0, A1, A2, A3, A4, A5}; | |
| const float slope[n] = {1, 1, 1, 1, 1, 1}; | |
| const float intercept[n] = {0, 0, 0, 0, 0, 0}; | |
| // Board reference voltage measured on aref pin | |
| const float refVoltage = 4.93; // V |
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/bin/env Rscript | |
| # Ben Fasoli | benfasoli@gmail.com | |
| # Return number of R processes currently running for active user | |
| get_process_count <- function(x = NA) { | |
| as.integer(system('pgrep -U $USER R | wc -l', intern = T)) | |
| } | |
| N_FORKS <- 2 |
NewerOlder