Skip to content

Instantly share code, notes, and snippets.

$ node test.js
Express app started on port 3000
Uploading: %1
/Users/bryce/Projects/app/test.js:30
next(err);
^
TypeError: object is not a function
at Object.CALL_NON_FUNCTION (native)
at /Users/bryce/Projects/app/test.js:30:7
at IncomingForm.<anonymous> (/Users/bryce/.node_libraries/.npm/formidable/0.9.11/package/lib/formidable/incoming_form.js:96:9)
#IfWinActive Terraria:
#MaxThreadsPerHotkey 3
$F1::
#MaxThreadsPerHotkey 1
if ClickSpam
{
ClickSpam := false
return
}
ClickSpam := true
@amoeba
amoeba / anscombe-ggplot.r
Last active October 6, 2019 08:57
Anscombe's Quartet with ggplot2
library(ggplot2)
theme_set(theme_bw(base_size=18))
anscombe_m <- data.frame()
for(i in 1:4)
anscombe_m <- rbind(anscombe_m, data.frame(set=i, x=anscombe[,i], y=anscombe[,i+4]))
ggplot(anscombe_m, aes(x, y)) + geom_point(size=5, color="red", fill="orange", shape=21) + geom_smooth(method="lm", fill=NA, fullrange=TRUE) + facet_wrap(~set, ncol=2)
setwd("~/src/amoeba.github.io/")
# Ensure we're in a Jekyll folder
# Do this by ensuring there's a _posts folder
if(!("_posts" %in% list.files(".", "*")))
{
cat("This script is not being run from a Jekyll blog directory.\n")
cat("Change directories and re-run.\n")
quit()
}
task :knit do
sh "Rscript knit-all.r"
end
task :knitall do
sh "Rscript knit-all.r --all"
end
task :build => [:knit] do
sh "bundle exec jekyll build"
@amoeba
amoeba / hexclock.r
Last active August 29, 2015 14:02
Hexclock in R
# hexclock
# after http://www.jacopocolo.com/hexclock/
# written by Bryce Mecum (@brycem)
while(TRUE)
{
hextime <- paste0("#", format(Sys.time(), "%I%M%S"))
plot(NA, xlim=c(0,1), ylim=c(0,1), axes=F, xlab="", ylab="")
rect(0, 0, 1, 1, col=hextime)
@amoeba
amoeba / pyramid.ani.R
Created January 3, 2015 02:17
Pyramid Pie Chart Animation in ggplot2
library("ggplot2")
library("animation")
saveGIF({
for(shadyside in 1:39)
{
sides <- c("Sky", "Sunny side of pyramid", "Shady side of pyramid")
amounts <- c(150, 40 - shadyside, shadyside)
@amoeba
amoeba / index.html
Created February 5, 2015 23:50
Random Right-Angled Trees
<!DOCTYPE html>
<meta charset="utf-8">
<h1>Random Trees</h1>
<p>Written by <a href="http://brycemecum.com/">Bryce Mecum</a></p>
<p>Code adapted from <a href="http://www.jasondavies.com/">Jason Davies</a> for generating right-angled trees and <a href="https://github.com/yuanyan/">yuanyan</a> for the Poisson distribution code.</p>
<p>
<button id="start" onclick="start()">Start</button>
<button id="stop" onclick="stop()">Stop</button>
</p>
@amoeba
amoeba / steps
Last active August 29, 2015 14:17
Steps to switch a 0-degree meridinal map to 180-degree meridinal
Note: These instructions assume the extent is -180 - 180, and -90 - 90. Use gdalinfo to check beforehand. They also assume our spatial file is longlat-projected.
For raster:
1. Grab a raster file
2. Decide upon how we'd like to trim. Below, we trim to -180:-120x30:90 and then 120:180x30:90
2. Trim: gdalwarp -te -180 30 -120 90 {SPATIAL_FILE_PATH} {OUTPUT_FILE_PATH}
3. Trim: gdalwarp -te 120 30 180 90 {SPATIAL_FILE_PATH} {OUTPUT_FILE_PATH}
4. Reproject: gdaltransform -s_srs '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' -t_srs '+proj=longlat +ellps=WGS84 +pm=360 +datum=WGS84 +no_defs'
@amoeba
amoeba / ggplot-disconnected.R
Created April 3, 2015 18:41
ggplot2 geom_line() example with disconnected lines for NA values
# ggplot2 example
# Show how geom_line() does not connect the line through NA values
library(ggplot2)
# Make some fake data
mydata <- data.frame(x = 2000:2010, y = rnorm(11, 5, 2))
# First plot, all lines are connected correctly
ggplot(mydata, aes(x, y)) + geom_line()