This file contains hidden or 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
'Add Microsoft Word XX.0 Object Library in Tools >> References | |
Public Sub FormatSelectedText() | |
Dim objItem As Object | |
Dim objInsp As Outlook.Inspector | |
Dim objWord As Word.Application | |
Dim objDoc As Word.Document | |
Dim objSel As Word.Selection | |
On Error Resume Next | |
This file contains hidden or 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
import os | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import pandas as pd | |
import numpy as np | |
import time | |
from itertools import groupby | |
def scroll(driver, timeout): |
This file contains hidden or 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
prop_model <- function (data = c(), prior_prop = c(1, 1), n_draws = 10000, show_plot = TRUE) { | |
library(tidyverse) | |
library(purrr) | |
library(ggjoy) | |
data <- as.logical(data) | |
proportion_success <- c(0, seq(0, 1, length.out = 100), 1) | |
data_indices <- round(seq(0, length(data), length.out = min(length(data) + 1, 20))) | |
post_curves <- map_dfr(data_indices, function(i) { | |
value <- ifelse(i == 0, "Prior", ifelse(data[i], "Success", "Failure")) | |
label <- paste0("n=", i) |
This file contains hidden or 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(tidyverse) | |
library(ggrepel) | |
library(scales) | |
results <- read_csv("results.csv") | |
# add GDP rank, winning candidate, chart labels | |
results <- results %>% | |
arrange(desc(GDP)) %>% | |
mutate(GDPRank = 1:51) %>% | |
mutate(Win = ifelse(ClintonNum>TrumpNum, "Clinton", "Trump")) %>% |
This file contains hidden or 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
# http://www.bnosac.be/index.php/blog/57-new-rstudio-add-in-to-schedule-r-scripts | |
install.packages('knitr') | |
install.packages('data.table') | |
install.packages('shiny') | |
install.packages('miniUI') | |
install.packages("taskscheduleR", repos="http://www.datatailor.be/rcube", type="source") |
This file contains hidden or 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
# Martingale Betting System | |
# initialize parameters --------------------------------------------------- | |
init_start <- 12800 | |
init_goal <- init_start + 1000 | |
init_bet <- 100 # initial bet value | |
prob_win <- 0.47 # probability of win | |
n <- 500000 # simulation count | |
# run simulation ---------------------------------------------------------- |
This file contains hidden or 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
# create dummy data ------------------------------------------------------- | |
set.seed(1) | |
d <- data.frame(col1 = sample(letters[1:3], 10, replace=T), | |
col2 = sample(letters[24:26], 10, replace=T), | |
col3 = runif(10) * 10, | |
stringsAsFactors = FALSE) | |
d$col1 <- as.factor(d$col1) | |
d$col4 = d$col3 + runif(10) |
This file contains hidden or 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
require(dplyr) | |
require(rvest) | |
options(stringsAsFactors = FALSE) | |
url_base <- "http://securities.stanford.edu/list-mode.html?page=" | |
tbl.clactions <- data.frame( | |
"Filing.Name" = character(0), | |
"Filing.Date" = character(0), | |
"District.Court" = character(0), |
This file contains hidden or 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
require(ggplot2) | |
# prepare south park data ------------------------------------------------- | |
d2 <- data.frame(member=c(rep("Eric",5), | |
rep("Kyle",5), | |
rep("Stan",5), | |
rep("Kenny",5)), | |
shade=c("EricPants","EricShirt","Skin","EricHat","EricPomPom", | |
"KylePants","KyleShirt","Skin","KyleHatBottom","KyleHatTop", | |
"StanPants","StanShirt","Skin","StanBottom","StanHatTop", |
This file contains hidden or 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
require(ggplot2) | |
# prepare simpsons data --------------------------------------------------- | |
# code from http://suehpro.blogspot.com/2016/03/the-simpsons-as-chart.html | |
d1 <- data.frame(member=c(rep("Homer",3), | |
rep("Marge",3), | |
rep("Bart",3), | |
rep("Lisa",2), | |
rep("Maggie",2)), | |
shade=c("HomerPants","HomerShirt","Skin", |
NewerOlder