Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@devin-petersohn
devin-petersohn / a_pandas_on_ray_blogpost_01.ipynb
Last active October 14, 2018 19:14
Pandas on Ray - Lessons learned Blog Post. Also introduces Modin, a project for unifying the APIs of computing engines.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Neurogami
Neurogami / plantext.txt
Created April 1, 2018 23:10
Bookmarklet version of javascript to get plaintext of Amazon Cloud Reader
Original code is from https://gist.github.com/aaronshaf/1346968
The instructions were to open a dev console and paste in the script.
A nicer way is to make it a bookmarklet.
1. Create a new bookmark in our browser. You should be able to edit the name and URL
2. Give it a decent name (e.g. "amz cloud plaintext")
3. Paste the following as the URL (make it all one line):
@soodoku
soodoku / get_unique_domain_names_from_comscore.py
Created February 12, 2018 02:15
Get a list of unique domain names from comScore browsing data
#
# Get All Unique Domain Names from comScore
#
# INPUT: comScore browsing data file
#
# OUTPUT: a text file containing a list of unique domains
#
# PAREMETERS:
# + INTERNET_USAGE_FILE: path to the comScore browsing data
# + FINAL_OUTPUT_FILE: path to intended output file
devtools::install_github("abresler/gdeltr2")
devtools::install_github("hafen/trelliscopejs")
library(gdeltr2)
library(dplyr)
asb_ocr <- "Brooklyn Nets"
gkg_codes <-
get_codes_gkg_themes()
imageweb_codes <- get_gdelt_codebook_ft_api(code_book = "imageweb")
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active April 16, 2024 17:37
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johnmyleswhite
johnmyleswhite / median.R
Created February 23, 2017 00:40
R's Medians as a Rabbit Hole of Type Promotions and Function Indirection
> median(FALSE)
[1] FALSE
> median(c(TRUE, FALSE))
[1] 0.5
> median(c(TRUE, FALSE, TRUE))
[1] TRUE
> f <- factor(c('a', 'b', 'c'), levels = c('a', 'b', 'c'), ordered = TRUE)
@soodoku
soodoku / rent control
Last active October 18, 2016 01:46
Rent Control
# Read the data
sf <- read.csv("sf_tenants.csv")
# Recode
sf$market_rates <- gsub("%", "", sapply(strsplit(sf$market_rate, " / "), "[", 2)) # market_rate
sf$rent_control_rates <- gsub("%", "", sapply(strsplit(sf$rent_control, " / "), "[", 2)) # market_rate
# Ratio of rent_control vs. rent_control
sf$ratio <- as.numeric(sf$rent_control_rates)/as.numeric(sf$market_rates)
@soodoku
soodoku / missing.R
Last active April 22, 2016 11:53
plotting missing
# Load libs
library(ggplot2)
# Simulate correlated data
R = matrix(cbind(1,.80, .80,1), nrow=2)
U = t(chol(R))
@soodoku
soodoku / state_various.csv
Last active April 12, 2016 22:31
US State name, 2 letter code, Alphabetical number, Census Region, ICPSR, ICPSR 2
state code num census icpsr icpsr2
Alabama AL 1 South 41 41 AL ALABAMA
Alaska AK 2 West 81 81 AK ALASKA
Arizona AZ 3 West 61 61 AZ ARIZONA
Arkansas AR 4 South 42 42 AR ARKANSAS
California CA 5 West 71 71 CA CALIFORNIA
Colorado CO 6 West 62 62 CO COLORADO
Connecticut CT 7 Northeast 1 01 CT CONNECTICUT
Delaware DE 8 South 11 11 DE DELAWARE
District of Columbia DC 9 Northeast 55 55 DC DISTRICT OF COLUMBIA