Skip to content

Instantly share code, notes, and snippets.

View abresler's full-sized avatar

Alex Bresler abresler

View GitHub Profile
@jamesob
jamesob / gist:2819803
Created May 28, 2012 15:48
Scraping Chase for CC transactions
from selenium import webdriver
import time
def get_chase_amazon_driver(username, password):
"""Return a logged-in Chase Amazon card selenium driver instance."""
driver = webdriver.Firefox()
driver.get("http://www.chase.com")
time.sleep(2)
@ddd1600
ddd1600 / CIKgetter.R
Created October 22, 2012 20:39
get SEC CIK number from ticker symbol
getCIK = function(ticker) {
stopifnot(is.character(ticker))
uri = "http://www.sec.gov/cgi-bin/browse-edgar"
response = getForm(uri,CIK=ticker,action="getcompany")
html = htmlParse(response)
CIKNode = getNodeSet(html, "//acronym[@title=\"Central Index Key\"][text() = \"CIK\"]")
CIKNodeText = sapply(CIKNode, function(x) xmlValue(getSibling(getSibling(x))))
CIK = sub(" .*","",CIKNodeText)
CIK = sub("^0*","",CIK)
@benmarwick
benmarwick / PDF-2-text-or-CSV.r
Last active July 18, 2022 03:48
Convert PDFs to text files or CSV files (DfR format) with R
# Here are a few methods for getting text from PDF files. Do read through
# the instructions carefully! NOte that this code is written for Windows 7,
# slight adjustments may be needed for other OSs
# Tell R what folder contains your 1000s of PDFs
dest <- "G:/somehere/with/many/PDFs"
# make a vector of PDF file names
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)
library("RCurl")
library("jsonlite")
library("ggplot2")
library("RColorBrewer")
library("scales")
library("gridExtra")
api.key <- "yourAPIkey"
rt <- getURI(paste0("http://api.rottentomatoes.com/api/public/v1.0/lists/dvds/top_rentals.json?apikey=", api.key, "&limit=50"))
@andrie
andrie / pagerank.R
Last active April 16, 2021 01:50
Analyze R packages for popularity, using pagerank algorithm
## Analyze R packages for popularity, using pagerank algorithm
# Inspired by Antonio Piccolboni, http://piccolboni.info/2012/05/essential-r-packages.html
library(miniCRAN)
library(igraph)
library(magrittr)
# Download matrix of available packages at specific date ------------------
@yihui
yihui / README.md
Last active March 15, 2017 18:35
A Shiny app based on annyang that responds to voice input
@andrie
andrie / cran-package-communities.R
Last active August 29, 2015 14:11
Determine CRAN package clusters (communities)
## Determine CRAN package clusters (communities)
library(miniCRAN)
library(igraph)
library(magrittr)
# Download matrix of available packages at specific date ------------------
@timelyportfolio
timelyportfolio / code.R
Created January 8, 2015 19:34
use twitter text javascript in R with V8
# devtools::install_github("jeroenooms/curl")
# devtools::install_github("jeroenooms/V8")
library(V8)
ct = new_context()
# get source and remove anonymous function wrapper
t = readLines(
"https://raw.githubusercontent.com/twitter/twitter-text/master/js/twitter-text.js"
@jeroen
jeroen / cheerio.R
Created January 13, 2015 00:01
V8 cheerio rvest example
# Proof of concept of using V8 to parse HTML in R
# Example taken from rvest readme
# Jeroen Ooms, 2015
library(V8)
stopifnot(packageVersion("V8") >= "0.4")
# Get Document
html <- paste(readLines("http://www.imdb.com/title/tt1490017/"), collapse="\n")
@hrbrmstr
hrbrmstr / tempanomaly.R
Created January 18, 2015 14:25
NASA GISS’s Annual Global Temperature Anomaly Trends
library(httr)
library(magrittr)
library(dplyr)
library(ggplot2)
# data retrieval ----------------------------------------------------------
pg <- GET("http://data.giss.nasa.gov/gistemp/tabledata_v3/GLB.Ts+dSST.txt",
user_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"))