Skip to content

Instantly share code, notes, and snippets.

View rer145's full-sized avatar

Ron Richardson rer145

View GitHub Profile
@rer145
rer145 / positive_dracula.R
Last active November 8, 2017 19:42
How to plot the top 10 positive words in a large set of text
library(gutenbergr)
library(tidytext)
library(dplyr)
library(ggplot2)
# Using Dracula as our example text, download it from Project Gutenberg
dracula<-gutenberg_download(345)
# Split each line of text into individual words
dracula<-dracula%>%
@rer145
rer145 / basic_unittest.py
Created November 8, 2017 21:02
How to do a simple unit test in python
# Our function to test
def above_freezing(celcius):
""" (int) -> boolean
Return True if celcius is above zero, and False if not
"""
return celcius > 0
@rer145
rer145 / ggplot_facet_wrap.R
Created November 11, 2017 00:53
Using facet_wrap in ggplot to compare plots side by side.
# Import the libraries used
library(gutenbergr)
library(tidytext)
library(dplyr)
library(ggplot2)
# Download text from Project Gutenberg
dracula<-gutenberg_download(345)
# Split the lines of text into words
@rer145
rer145 / python_sorting.py
Last active November 11, 2017 01:11
Different sorting methods in python
def bubble_sort(L):
for i in range(len(L)-1, 0, -1):
for j in range(i):
if L[j] > L[j+1]:
temp = L[j]
L[j] = L[j+1]
L[j+1] = temp
def selection_sort(L):
@rer145
rer145 / wordcloud2.R
Created November 16, 2017 02:18
Using wordcloud2 to make dynamic wordclouds
library(gutenbergr)
library(tidytext)
library(dplyr)
library(wordcloud2)
dracula<-gutenberg_download(345)
dracula$gutenberg_id<-NULL
dracula<-dracula%>%
unnest_tokens(word, text)
@rer145
rer145 / comparision_cloud.R
Last active November 16, 2017 02:19
Creating a comparison cloud in R with wordcloud
library(gutenbergr)
library(tidytext)
library(dplyr)
library(wordcloud)
dracula<-gutenberg_download(345)
dracula$gutenberg_id<-NULL
dracula<-dracula%>%
unnest_tokens(word, text)
@rer145
rer145 / latex_slides.Rnw
Last active November 20, 2017 17:35
Creating a slide presentation with beamer and latex
\documentclass{beamer}
\begin{document}
\title{Positive and Negative Words in Dracula}
\author{Ron Richardson}
\begin{frame}
\titlepage
@rer145
rer145 / setup_scala.sh
Created March 28, 2018 23:47
Setting up Scala on Google Cloud Shell
#!/bin/bash
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get install sbt