var Stars = function (props) { | |
var rating = props.rating || 0; // rating from 0 to 5, inclusive, in increments of 0.5 | |
var label = props.label || null; // a label to describe the contents (for accessibility) | |
var src = "./img/stars_" + rating + ".svg"; | |
return <img src={src} width="78" height="13" aria-label={label} data-tooltip={label}/>; | |
}; | |
module.exports = Stars; |
[diff "word"] | |
binary = true | |
textconv = docx-to-txt.rb -t |
# We first start by creating a way of escaping the characters that have special | |
# meaning for html, while making sure we don't end up double-escaping at any | |
# point. The easiest way to do this is to create an S3 class that allows us to | |
# distinguish between regular text (that needs escaping) and html (that | |
# doesn't). | |
# | |
# We then write an escape method that leaves html unchanged and escapes the | |
# special characters (&, <, >) in ordinary text. We also add a method for lists | |
# for convenience |
#' Finds the local maxima (peaks) in the given vector after smoothing the data | |
#' with a kernel density estimator. | |
#' | |
#' First, we smooth the data using kernel density estimation (KDE) with the | |
#' \code{\link{density}} function. Then, we find all the local maxima such that | |
#' the density is concave (downward). | |
#' | |
#' Effectively, we find the local maxima with a discrete analogue to a second | |
#' derivative applied to the KDE. For details, see this StackOverflow post: | |
#' \url{http://bit.ly/Zbl7LV}. |
#Unbelievable clickme d3 straight from R
I deserve no credit for this. Go to clickme for the guy that deserves all the credit. I just simply put it in Gist form for it to show up on bl.ocks.org
#!/usr/bin/env python | |
# A simple Python script to convert csv files to sqlite (with type guessing) | |
# | |
# @author: Rufus Pollock | |
# Placed in the Public Domain | |
import csv | |
import sqlite3 | |
def convert(filepath_or_fileobj, dbpath, table='data'): | |
if isinstance(filepath_or_fileobj, basestring): |
Have you ever seen these scatterplots that report a significant correlation between X and Y, but it looks like it's just the one point to the upper-right driving the correlation? Thanks to this interactive tool, you too can do this at home. Click anywhere in the picture, and the red dot will move. The sliding bar displays the resulting correlation coefficient. The grey interval are non-significant values: place the red dot right to get a significant result.
Data are generated from two standard independent gaussian (N=15). Test values are from the asymptotic Fisher transformation test that's on Wikipedia (two-sided, alpha = 5%). Code: R and d3.js.
#!/bin/bash | |
# Usage: interleave_fastq.sh f.fastq r.fastq > interleaved.fastq | |
# | |
# Interleaves the reads of two FASTQ files specified on the | |
# command line and outputs a single FASTQ file of STDOUT. | |
# | |
# Can interleave 100 million paired reads (200 million total | |
# reads; a 2 x 22Gbyte files), in memory (/dev/shm), in 6m54s (414s) | |
# | |
# Latest code: https://gist.github.com/4544979 |
#!/bin/sh | |
exec <"$0" || exit; read v; read v; exec /usr/bin/osascript - "$@"; exit | |
-- the above is some shell trickery that lets us write the rest of | |
-- the file in plain applescript | |
tell application "Google Chrome" | |
activate | |
tell application "System Events" | |
tell process "Google Chrome" |