Skip to content

Instantly share code, notes, and snippets.

View thieled's full-sized avatar

Daniel Thiele thieled

View GitHub Profile
@bobthecat
bobthecat / Rcpp_cosine.r
Created June 9, 2012 23:29
Rcpp cosine similarity
require(inline)
require(RcppArmadillo)
## extract cosine similarity between columns
cosine <- function(x) {
y <- t(x) %*% x
res <- 1 - y / (sqrt(diag(y)) %*% t(sqrt(diag(y))))
return(res)
}
@hadley
hadley / .gitignore
Last active February 25, 2024 02:10
Benchmark different ways of reading a file
.Rproj.user
.Rhistory
.RData
*.Rproj
*.html
@rtt
rtt / tinder-api-documentation.md
Last active October 17, 2024 17:55
Tinder API Documentation

Tinder API documentation

Note: this was written in April/May 2014 and the API may has definitely changed since. I have nothing to do with Tinder, nor its API, and I do not offer any support for anything you may build on top of this. Proceed with caution

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

@tjvananne
tjvananne / process GloVe pre-trained word vector.R
Created May 4, 2017 14:45
How to read and process a downloaded pre-trained GloVe word vector (turn it into a data.frame) in base R
#' A word vector is a giant matrix of words, and each word contains a numeric array that represents the semantic
#' meaning of that word. This is useful so we can discover relationships and analogies between words programmatically.
#' The classic example is "king" minus "man" plus "woman" is most similar to "queen"
# function definition --------------------------------------------------------------------------
# input .txt file, exports list of list of values and character vector of names (words)
proc_pretrained_vec <- function(p_vec) {
@jaeddy
jaeddy / rstudio_ami_guide.md
Last active May 6, 2024 09:13
steps for creating and configuring a new AMI with RStudio Server

Building a new RStudio Server AMI

The steps below can be followed to create a new AMI for use with Amazon EC2 instances that includes the latest versions of R, RStudio, and RStudio Server. The idea is inspired by the work of Louis Aslett, who creates and hosts his own public AMIs for RStudio. My own goal was to create an AMI with RStudio v1.0.0 or higher, such that I could use the recent R Notebooks feature. However, the instructions should generally apply for whenever you might be impatient accessing the latest version of R-related software on AWS (via an interactive browser interface...).

Getting started

  1. Create a new EC2 instance with the latest Ubuntu AMI (should be fine to do with Spot); based on Louis Aslett's AMI, I opted to include a general purpose SSD EBS volume with 10GB of storage space
  2. SSH into the instance

Downloading/installing RStudio Server

---
title: "Using Gensim in R"
author: "Adam Lauretig"
date: "3/17/2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@strengejacke
strengejacke / ggpredict_glmmTMB.R
Created December 23, 2020 21:41
ggpredict and glmmTMB
library(glmmTMB)
library(ggeffects)
data("Salamanders")
m1 <- glmmTMB(
count ~ mined + (1 | site),
zi = ~ mined,
family = poisson,
data = Salamanders
)
@travisbrown
travisbrown / withheld.csv
Last active September 29, 2023 11:28
Twitter accounts withheld in specific countries
We can't make this file beautiful and searchable because it's too large.
5663832,AliAsifPTI,277,IN
7071762,cdf,1319,ID
7316382,TheSuperFFreak,4455,ID
8056732,andresobreiro_,2531,ID
8671052,CPorgyUniverse,490837,ID
12883902,TaxWiser,111,TR
13140962,WildCuddler,30097,ID
14181996,kevincubschgo,953,ID
14231320,recentpoker,6088,RU
14331162,hekanaho,1296,TR