Skip to content

Instantly share code, notes, and snippets.

@steveharoz
steveharoz / index.html
Last active August 29, 2015 14:24 — forked from mbostock/.block
<!DOCTYPE html>
<meta charset="utf-8">
<canvas style="width:100%; height:100%"></canvas>
<script>
/* https://github.com/d3/d3-timer Copyright 2015 Mike Bostock */
"undefined"==typeof requestAnimationFrame&&(requestAnimationFrame="undefined"!=typeof window&&(window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame)||function(e){return setTimeout(e,17)}),function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.timer={})}(this,function(e){"use strict";function n(){r=m=0,c=1/0,t(u())}function t(e){if(!r){var t=e-Date.now();t>24?c>e&&(m&&clearTimeout(m),m=setTimeout(n,t),c=e):(m&&(m=clearTimeout(m),c=1/0),r=requestAnimationFrame(n))}}function i(e,n,i){i=null==i?Date.now():+i,null!=n&&(i+=+n);var o={callback:e,time:i,flush:!1,next:null};a?a.next=o:f=o,a=o,t(i)}function o(e,n,t){t=null==t?Date.now():+t,null!=n&&(t+=+n),l.callback=e,l.time=t}function u(e){e=nu
@steveharoz
steveharoz / README.md
Last active September 22, 2015 23:18
transition example

hello markdown

@steveharoz
steveharoz / standard error.R
Last active November 26, 2015 10:52
Standard Error for R
# r doesn't have a standard error function
stderr = function(x) sqrt(var(x,na.rm=TRUE)/length(na.omit(x)))
ci = function(x, confidence.interval=0.95) stderr(x) * qnorm(1 - (1-confidence.interval)/2)
@steveharoz
steveharoz / index.html
Last active November 30, 2015 01:49
HTML Canvas boilerplate
<!DOCTYPE HTML>
<html>
<body>
<canvas id="myCanvas" width="1000" height="1000"></canvas>
<script>
function drawImage() {
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var imageWidth = canvas.width = Math.min(canvas.width, window.innerWidth);
var imageHeight = canvas.height = Math.min(canvas.height, window.innerHeight);
library(ggplot2)
yDistribution <- function(x) { return(1/x) }
xSampleDistribution <- function(x) { return((2 ^ x) * 10) }
x <- c()
y <- c()
for (i in 0:8) {
sampleCount <- xSampleDistribution(i)
x <- c(x, rep(i, sampleCount))
@steveharoz
steveharoz / README.md
Created October 24, 2013 21:45 — forked from mbostock/.block
@steveharoz
steveharoz / packages.R
Last active January 2, 2016 18:39
R Setup - run after a new install of R
install.packages('Cairo')
install.packages('data.table')
install.packages('extrafont')
install.packages('ggplot2')
install.packages('lubridate')
install.packages('plyr')
install.packages('dplyr')
install.packages('rjson')
install.packages('stringr')
install.packages('XML')
@steveharoz
steveharoz / gist:8444541
Created January 15, 2014 20:59
A simple small CSV
Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38
@steveharoz
steveharoz / Welcome to dates.R
Last active January 16, 2016 23:57
Learning how to make a sequence along a time axes
mydate1 = as.Date("2000-01-01")
mydate2 = as.Date("2000-03-01")
# EASY: sequence with every other int
seq(1, 60, by=2)
# HARD: sequence with every other day
seq(mydate1, mydate2, by=???) # day?
# pretend you're new to R
# you don't know about lubridate or POSIX