Skip to content

Instantly share code, notes, and snippets.

View hrbrmstr's full-sized avatar
💤
#tired

boB Rudis hrbrmstr

💤
#tired
View GitHub Profile
@hrbrmstr
hrbrmstr / boyermoor.py
Created April 4, 2018 13:24 — forked from jonocarroll/boyermoor.py
Boyer-Moore Implementations for @coolbutuseless' comparisons
def alphabet_index(c):
"""
Returns the index of the given character in the English alphabet, counting from 0.
"""
return ord(c.lower()) - 97 # 'a' is ASCII character 97
def match_length(S, idx1, idx2):
"""
Returns the length of the match of the substrings of S beginning at idx1 and idx2.
"""
@hrbrmstr
hrbrmstr / Ick.java
Created March 2, 2018 22:12 — forked from phlash/Ick.java
Self-executing single-file Java programs...
#!/bin/sh
# This self-executing Java program uses the following /embedded shell script/ to compile & execute itself..
# magic constant holding length of script
SKIP=26
# parse our name..
FILE=`basename $0 .java`
# get some working space, clean up old crud
@hrbrmstr
hrbrmstr / git-create-remote.sh
Created January 16, 2018 04:59 — forked from simonecorsi/git-create-remote.sh
This function will walk you through the creation of a remote repository on github without wasting your precious time going to the website :)
# This function will walk you through the creation of a remote repository on github
# without wasting your precious time going to the website :)
# how:
# - source it in your (bash|zsh)rc
# - change the alias at the bottom of the script to your needs
# - call it, follow instructions... profit
function createRemoteGitRepository() {
local RED='\033[0;31m'
local NC='\033[0m' # No Color
local GITHUB_USER=''
@hrbrmstr
hrbrmstr / Readme.md
Created January 26, 2017 11:50 — forked from timelyportfolio/Readme.md
igraph layout editing with mapedit

This is certainly not the intended purpose of mapedit, but I thought it would be fun to use some accumulated R knowledge to use mapedit and leaflet to edit an igraph layout. To run the code, make sure to run the edit_map and Shiny parts separately.

library(igraph)
library(leaflet)
library(mapedit)

karate <- graph.famous("Zachary")
igrf_layout <- layout.auto(karate)
@hrbrmstr
hrbrmstr / balloon.R
Created November 29, 2017 10:57 — forked from baptiste/balloon.R
library(grImport2)
library(grConvert)
library(egg)
convertPicture("noun_3663.svg", "balloon.svg")
balloon <- readPicture("balloon.svg")
d <- data.frame(x=1:9, y=rnorm(9),
data = I(Map(function(c, s) list(c=c,s=s),c=blues9,s=1:9)),
# Most of R, from an applied point of view anyway, is the process of creating objects and feeding them into functions to make amazing,
# new objects.
# amazing_new_object <- f(object)
x <- c(3, 4, 5)
y <- mean(x)
# This is true in the big picture sense as well
# information
@hrbrmstr
hrbrmstr / had_crut_spider_plot.R
Created May 14, 2016 11:47 — forked from jebyrnes/had_crut_spider_plot.R
R code to reproduce the awesome visualization of global temperature change from Ed Hawkins at http://www.climate-lab-book.ac.uk/2016/spiralling-global-temperatures/ using R and ggplot2 (with the animations package)
library(dplyr)
library(tidyr)
library(ggplot2)
library(animation)
#Data from https://crudata.uea.ac.uk/cru/data/temperature/
#As well as data read in script
source("read_cru_hemi.R")
temp_dat <- read_cru_hemi("./HadCRUT4-gl.dat")
#remove cover
@hrbrmstr
hrbrmstr / README.md
Created May 21, 2016 10:53 — forked from armollica/README.md
Visualizing Distributions

A few ways to visualize 1D distributions.

Swarm and pile plots show all the data points but can't be used when there are a lot of data points. Histograms and boxplots work for any number of data points since they are visualizing summary statistics. Histograms provide more information than a boxplot. Boxplots fit in small spaces, making them nice for comparing many distributions side-by-side.

Other chart types for 1D distributions: violin plot,

library(ggplot2) # devtools::install_github("hadley/ggplot2") or subtitles won't work
library(tidyr)
library(dplyr)
library(readr)
library(scales)
URL <- "https://static01.nyt.com/newsgraphics/2016/04/21/undervote/ad8bd3e44231c1091e75621b9f27fe31d116999f/data.tsv"
fil <- "nytimes_vote.tsv"
if (!file.exists(fil)) download.file(URL, fil)