Skip to content

Instantly share code, notes, and snippets.

View ltrgoddard's full-sized avatar

Louis Goddard ltrgoddard

View GitHub Profile
# Takes an ordered vector of numeric values and returns a small bar chart made
# out of Unicode block elements. Works well inside dplyr mutate() or summarise()
# calls on grouped data frames.
sparkbar <- function(values) {
span <- max(values) - min(values)
if(span > 0 & !is.na(span)) {
steps <- round(values / (span / 7))
blocks <- c('▁', '▂', '▃', '▄', '▅', '▆', '▇', '█')
paste(sapply(steps - (min(steps) - 1), function(i) blocks[i]), collapse = '')
#!/usr/bin/env python
# This is a simple script to set up a Twitter 'bot' based on a character-level recurrent neural network. Clone sherjilozair's
# char-rnn-tensorflow (https://github.com/sherjilozair/char-rnn-tensorflow) and train it on the material of your choice.
# Then drop this script into the main directory, create a Twitter account and Twitter app for the bot and enter the
# relevant authentication information at the commented points below. Run this script and whenever somebody
# @mentions the bot it will reply with a sample from your neural network.
# Louis Goddard <louisgoddard@gmail.com>