Skip to content

Instantly share code, notes, and snippets.

View brodieG's full-sized avatar

Brodie Gaslam brodieG

View GitHub Profile
@baptiste
baptiste / fixedar.r
Last active December 4, 2019 19:26
library(ggplot2)
set.seed(1221)
dat <- data.frame(x=rnorm(100), y=rnorm(100), type=rep(1:2, each=50))
p <- ggplot(dat) + geom_point(aes(x, y)) +
facet_wrap(~type) + coord_fixed() +
theme(plot.background = element_rect(fill='red'))
# inspired by
# egg::set_panel_size
@TysonStanley
TysonStanley / dplyr_datatable_memory.R
Created October 12, 2019 17:34
Using `profmem` package to understand data summaries by group for both `data.table` and `dplyr`
library(bench) # assess speed and memory
library(data.table) # data.table for all of its stuff
library(dplyr) # compare it to data.table
library(profmem) # assess the process of R functions
set.seed(84322)
# Example Data
d <- data.table(
grp = sample(c(1,2), size = 1e6, replace = TRUE) %>% factor,
library(USAboundaries)
library(sf)
library(dplyr)
library(elevatr)
library(raster)
# Get map of lower 48 states
usa_l48 <- us_boundaries() %>%
filter(state_abbr != "HI" &
state_abbr != "AK" &
@dpseidel
dpseidel / default_aes.md
Last active February 12, 2021 17:08
Default ggplot2 aesthetics table

Default ggplot2 aesthetics by geom.

geom alpha angle colour family fill fontface height hjust lineheight linetype shape size stroke vjust weight width xmax xmin ymax ymin
GeomAbline NA black 1 0.5
GeomAnnotationMap NA NA grey20 1 0.5
GeomArea NA NA grey20 1 0.5
GeomBar NA NA grey35 1 0.
@eliocamp
eliocamp / relief-shade.R
Last active January 25, 2018 16:20
Relief Shade in R
library(data.table)
library(ggplot2)
data(volcano)
volcano <- as.data.table(melt(volcano, varnames = c("x", "y"),
value.name = "h"))
volcano[, c("dx", "dy") := metR::Derivate(h ~ x + y)] # from my package. It calculates directional derivatives.
volcano[, angle := atan2(-dy, -dx)]
@tskaggs
tskaggs / OSX-Convert-MOV-GIF.md
Last active May 6, 2024 13:07
Creating GIFs from .MOV files in OSX using FFmpeg and ImageMagick

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!

Preparation

Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@ndarville
ndarville / diff.mdown
Created July 23, 2012 20:33
Paul Heckel's Diff Algorithm

[Isolating Differences Between Files][paper]

Advantage over Other Algorithms

The diff output is more specific:

[I]f a whole block of text is moved, then all of it, rather than just the beginning and end, is detected as changed.

>The algorithm described here avoids these difficulties. It detects differences that correspond very closely to our intuitive notion of difference.