Skip to content

Instantly share code, notes, and snippets.

View meefen's full-sized avatar

Bodong Chen meefen

View GitHub Profile
@meefen
meefen / server.R
Created June 22, 2014 02:47
A (to-be-fixed) demo of integrating rCharts' timeline within Shiny.
library(shiny)
library(rCharts)
shinyServer(function(input, output) {
output$timelineDemo <- renderChart({
### Copied from https://github.com/ramnathv/sachin100s
require(XML)
require(RCurl)
@meefen
meefen / fsm.Rmd
Last active February 7, 2018 07:31
Frequent Sequence Mining
========================================================
```{r knitr-options}
library(knitr)
options(width=200, digits=2)
opts_chunk$set(comment = "", warning = FALSE, message = FALSE, echo = TRUE, tidy = FALSE, size="small")
```
## Data preparation
@meefen
meefen / TwitterLoop.java
Last active December 30, 2015 21:09
This gist contains Java code for archiving tweets in MongoDB, and R code for retrieving tweets for analysis. Please note that there're a couple of dependencies: (1) You should setup your MongoDB (I used the free plan at https://mongolab.com/); (2) You should have setup your Twitter api (check https://dev.twitter.com/); (3) Java code: include twi…
package twitter_loop;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.Mongo;
import com.mongodb.MongoException;
import java.net.UnknownHostException;
import java.util.List;
@meefen
meefen / Makefile
Created November 13, 2013 01:56
Makefile and LaTeX templates for compiling Markdown documents for job application. Applicable to other situations where you need to compile a bunch of Markdown files to PDF or Word/ODT formats.
# Makefile used to compile job application documents from MarkDown to PDF or ODT
# Bodong Chen
## Files
SRC = $(wildcard *.md)
PDFS = $(SRC:.md=.pdf)
ODTS = $(SRC:.md=.odt)
## Targets
all: $(PDFS)
@meefen
meefen / lsa_mds.R
Last active September 30, 2019 20:17
Analyze Text Similarity in R: Latent Semantic Analysis and Multidimentional Scaling
# load required libraries
library(tm)
library(ggplot2)
library(lsa)
# 1. Prepare mock data
text <- c("transporting food by cars will cause global warming. so we should go local.",
"we should try to convince our parents to stop using cars because it will cause global warming.",
"some food, such as mongo, requires a warm weather to grow. so they have to be transported to canada.",
"a typical electronic circuit can be built with a battery, a bulb, and a switch.",
'''
@author Michael J Bommarito II
@date Feb 26, 2011
@license Simplified BSD, (C) 2011.
This script demonstrates how to use Python to archive historical tweets.
'''
import codecs
import csv
#@author Michael J Bommarito
#@contact michael.bommarito@gmail.com
#@date Feb 20, 2011
#@ip Simplified BSD, (C) 2011.
# This is a simple example of an R script that will retrieve
# public tweets from a given hashtag.
library(RJSONIO)
# This function loads stored tag data to determine the current max_id.
@meefen
meefen / TAGS_Stats.R
Last active December 14, 2015 03:58 — forked from psychemedia/TAGS_Stats.R
#------------------------
# Load libraries
require(stringr)
require(RCurl)
require(ggplot2)
#------------------------
# Read and return Google Spreadsheet as csv