This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Twitter Topic Modeling Using R | |
# Author: Bryan Goodrich | |
# Date Created: February 13, 2015 | |
# Last Modified: April 3, 2015 | |
# | |
# Use twitteR API to query Twitter, parse the search result, and | |
# perform a series of topic models for identifying potentially | |
# useful topics from your query content. This has applications for | |
# social media, research, or general curiosity | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created by Bryan Goodrich | |
# Version 0.1 | |
# | |
# Title: List Out Of Lambda [in R] | |
# | |
# An adaptation of Steve Losh's JavaScript exploration[1] with a hat tip to | |
# Hadley Wickham's Advanced R Programming[2] that led me there. | |
# | |
# References | |
# [1] http://stevelosh.com/blog/2013/03/list-out-of-lambda/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Execute a round of the Game of Life | |
#' | |
#' I want to play a game. Specifically, Conway's Game of Life. | |
#' | |
#' @param x a matrix populated with 0s and 1s. | |
#' @param birth a vector indicating the birthing rule. Defaults to 3. | |
#' @param stay a vector indicating the stay alive rule Defaults to c(2,3). | |
#' @return a matrix representing an updated input matrix according to the rules | |
#' @references \url{http://en.wikipedia.org/wiki/Conway's_Game_of_Life} | |
#' @author Bryan Goodrich |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################### | |
# Lesson 1 - R Basics | |
# | |
# Learning Objectives | |
# 1. R Data Types | |
# 2. Indexing | |
# 3. Boolean Logic and Filtering | |
# 4. Importing/Exporting | |
# 5. The R Environment | |
######################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# Author: Bryan Goodrich | |
# Created: Sometime 2012? Earlier? | |
# | |
# These functions allowed direct querying and mapping capabilities to the Bureau | |
# of Labor Statistics (BLS) Special Requests data through their FTP site. The | |
# data were stored in fixed-width text files. | |
# | |
# This code is non-functional in that the BLS no longer supports this FTP access. | |
# Additionally, the specific Local Area (LA) statistics utilized are also not |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************* | |
* Compilation: g++ -std=c++11 map.cpp -o map.exe | |
* Execution: map.exe < input.txt | |
* | |
* Output the contents of a sorted map | |
* | |
* This is a toy code snippet for using C++11 types to handle | |
* an input stream, store the incoming data columns by line, | |
* and sort the output list according to length of key, | |
* with ties broken by string sort order (map default). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************* | |
* Compilation: g++ grid.cpp -o grid.exe | |
* Execution: grid.exe < input.txt | |
* | |
* Input and rotate a grid | |
* | |
* This is a toy code snippet for handling informational | |
* input (integer size of grid), importing multiple | |
* columns, and exporting with formatted output. Nothing | |
* amazing, but can provide a basis for this sort of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************* | |
* Compilation: g++ grid_file.cpp -o grid_file.exe | |
* Execution: grid_file.exe input.txt | |
* | |
* Input and rotate a grid | |
* | |
* This is a toy code snippet for handling informational | |
* input (integer size of grid), importing multiple | |
* columns, and exporting with formatted output. This | |
* example uses C++ approaches to file and string input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************* | |
* Compilation: g++ -std=c++11 reverse.cpp -o reverse.exe | |
* Execution: reverse.exe < input.txt | |
* | |
* Reverse an integer text input stream | |
* | |
* This is a toy code snippet for using C++11 types to handle | |
* an input stream, store the incoming data by line, and reverse | |
* it while printing to standard output. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import array | |
class WeightedQuickUnion: | |
def __init__(self, N): | |
self.count = N | |
self.id = array.array('i', range(N)) | |
self.size = array.array('i', [1] * N) | |
def connected(self, p, q): | |
return self.find(p) == self.find(q) |
NewerOlder