Skip to content

Instantly share code, notes, and snippets.

View dcooley's full-sized avatar

Dave dcooley

View GitHub Profile
library(tidyverse)
library(sf)
library(mapview)
library(furrr)
library(raster)
plan(multiprocess)
ex = extent(c(xmin=-112,xmax=155,ymin=-44,ymax=-10))
@adamgraham
adamgraham / UIColor+YUV.swift
Last active June 21, 2021 22:47
An extension of the iOS class UIColor to provide conversion to and from YUV colors.
/// An extension to provide conversion to and from Y′UV colors.
extension UIColor {
/// The Y′UV components of a color - luma (Y′) and chroma (U,V).
struct YUV: Hashable {
/// The luma component of the color, in the range [0, 1] (black to white).
var Y: CGFloat
/// The blue-difference chroma component of the color, in the range [-0.436, 0.436].
var U: CGFloat
@totocaster
totocaster / StringSanitize.swift
Last active June 6, 2023 09:00
Function that "sanitizes" string to safe filename string that can be used on Mac, Linux and Windows.
var str = "2018/12/06 12:28 \\ - Ourdoor Run: Making a habbit.fgworkout"
extension String {
func sanitized() -> String {
// see for ressoning on charachrer sets https://superuser.com/a/358861
let invalidCharacters = CharacterSet(charactersIn: "\\/:*?\"<>|")
.union(.newlines)
.union(.illegalCharacters)
.union(.controlCharacters)
@anvarazizov
anvarazizov / printTime.swift
Created October 13, 2017 01:03
print time in swift with milliseconds
func printDate(string: String) {
let date = Date()
let formatter = DateFormatter()
formatter.dateFormat = "HH:mm:ss.SSSS"
print(string + formatter.string(from: date))
}
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / app.R
Last active March 21, 2023 15:16
Shiny dynamic UI - observers & lapply
# An example based on http://shiny.rstudio.com/articles/dynamic-ui.html
library(shiny)
ui = basicPage(
fluidRow(
actionButton(inputId = "add_buttons", label = "Add 5 Buttons")
),
uiOutput("more_buttons") # this is where the dynamically added buttons will go.
)