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
# Generate 10 schools | |
schools <- 1:10 | |
# Sample 100 books of 20 types | |
books <- sample(1:20, size = 100, replace=T) | |
books_per_school <- length(books) / length(schools) | |
# Kid in school | |
kids_in_school <- rbinom(100, size = length(schools), prob = 0.5) | |
#hist(kids_in_school) |
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
## Assuming we already have the model describe on page 246 - 247 | |
## Here is a possible way to get the graph describe on figure 8.5 from Statistical Rethinking Figure 8.4 | |
plot(NULL, xlim=c(0,1), ylim=c(0.5, 1.5), xlab="rudgeness", ylab="gdp log std") | |
points(dd$rugged_std[dd$cont_africa==1], dd$log_gdp_std[dd$cont_africa==1], col="blue") | |
points(dd$rugged_std[!dd$cont_africa], dd$log_gdp_std[!dd$cont_africa], col="black") | |
lines(rudge_seq, mu.NotAfrica_mu) | |
shade(mu.NotAfrica_ci, rudge_seq) |
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
p <- c(0.3, 0.7 ) | |
N = 1000 | |
qs <- cbind( seq(0, 1, length.out = N), seq(1, 0, length.out = N) ) | |
kldivergence <- function(q1, q2) {p <- c(0.3, 0.7 ); sum( p*log(p/c(q1,q2)))} | |
kldivergence_results <- mapply(kldivergence, qs[,1], qs[,2]) | |
plot(qs[,1], kldivergence_results, pch=20, col='blue') |
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
num_weeks <- 1e5 | |
position <- rep(0, num_weeks) | |
current <- 10 | |
for (i in 1:num_weeks) { | |
position[i] <- current | |
proposal <- current + sample( c(-1, 1), size = 1) | |
if (proposal < 1) proposal <- 10 | |
if (proposal > 10) proposal <- 1 | |
prob_move <- proposal/current |
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
# Get PR number for a specific commit | |
local pr_number=$(git log --reverse --ancestry-path <commit_id>..master --grep="Merge pull request" --oneline | head -n 1 | awk '{print $5}' | sed -E 's/#//g') | |
# Open PR in the browser | |
open "https://github.tumblr.net/TumblrMobile/android2/pull/$pr_number" |
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
cat <module_name>/build/intermediates/merged_manifest/celrayDebug/out/AndroidManifest.xml | pbcopy |
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
# List all the tables using a profile | |
aws dynamodb list-tables --profile <profile_name> | jq | |
# Get all item in a table using a profile (expensive) | |
aws dynamodb scan --table-name <table_name> --profile <profile_name> | jq | |
# Get an specific item based on id using a profile | |
aws dynamodb get-item --key '{"id":{"S":"009871"}}' --table-name <table_name> --profile <profile_name> | jq | |
# Create an item using a profile |
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
# Find the largest residual of 2 digits number that can be divided by the sum of itself | |
# maxres(ab/(a+b)) | |
library(tidyr) | |
count <- 0 | |
max_index <- 0 | |
for( i in 10:99) { | |
digits <- as.integer(substring(i, seq(nchar(i)), seq(nchar(i)))) | |
aplusb <- digits[1] + digits[2] |
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
# Get all numbers 3 digits, divisible by 3 that follow this formula | |
# a + 3b + c where a != 0 | |
library(tidyr) | |
count <- 0 | |
n <- c() | |
for( i in 100:999) { | |
digits <- as.integer(substring(i, seq(nchar(i)), seq(nchar(i)))) | |
formula <- (digits[1] + 3*digits[2] + digits[3]) |
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
library(readr) | |
library(skimr) | |
library(dplyr) | |
library(stringr) | |
data <- readr::read_csv('data.csv') | |
skimr::skim(data) | |
data_cleaned <- data %>% filter(!stringr::str_detect(Page, "@powertofly\\.com")) %>% | |
mutate(Registrations = |
NewerOlder