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
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import time | |
import random | |
import pandas as pd | |
def get_github_activities(keywords): | |
''' | |
Getting search results of activities from GitHub | |
keywords: an iterable of the key-words to search on GitHub, e.g. ['TensorFlow', 'Pytorch'] |
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
import plotly | |
plotly.offline.init_notebook_mode() | |
trace_rep = plotly.graph_objs.Bar(x = dl_activities.repositories, y = dl_activities.keyword, name = "Repositories", orientation = 'h', marker = dict(color = 'rgba(0, 0, 255, 1)')) | |
trace_commits = plotly.graph_objs.Bar(x = dl_activities.commits, y = dl_activities.keyword, name = "Commits", orientation = 'h', marker = dict(color = 'rgba(255, 165, 0, 1)')) | |
trace_issues = plotly.graph_objs.Bar(x = dl_activities.issues, y = dl_activities.keyword, name = "Issues", orientation = 'h', marker = dict(color = 'rgba(0, 255, 0, 1)')) | |
trace_wikis = plotly.graph_objs.Bar(x = dl_activities.wikis, y = dl_activities.keyword, name = "Wikis", orientation = 'h', marker = dict(color = 'rgba(255, 0, 0, 1)')) | |
data = [trace_rep, trace_commits, trace_issues, trace_wikis] | |
updatemenus = list([ | |
dict( |
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(RSelenium) | |
# Define function | |
get_zipped_csv <- function(x) { | |
for (indicator in x) { | |
remDr$navigate("https://data.worldbank.org/") | |
query_box <- remDr$findElement(using = 'css', "#selector") | |
# Keyboard input | |
query_box$sendKeysToElement(list(indicator)) | |
Sys.sleep(5) |
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(tidyr) | |
library(magrittr) | |
library(dplyr) | |
get_tidy_df <- function(x) { | |
setwd(x) | |
ex_dir <- paste0(x, "/world_bank_csv") | |
zipfiles <- c("API_NY.GDP.PCAP.CD_DS2_en_csv_v2.zip", "API_SP.DYN.LE00.IN_DS2_en_csv_v2.zip", "API_SP.POP.TOTL_DS2_en_csv_v2.zip") | |
for (zipfile in zipfiles) { | |
unzip(zipfile, exdir = ex_dir) |
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
region_list <- tidy_df$Region %>% | |
unique() | |
# Define UI for application that mimics a Gapminder visualization | |
shinyUI(fluidPage( | |
# Application title | |
titlePanel("Gapminder Replica"), | |
# Sidebar with a slider input for year |
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
# Define server logic required to draw a Gapminder visualization | |
shinyServer(function(input, output) { | |
tidy_data <- reactive( | |
tidy_df %>% | |
filter(Region %in% input$regions) | |
) | |
output$bubble <- renderPlotly({ | |
# draw the bubble chart with the specified continents or year |
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
# global.R template for Plotly/Shiny apps | |
library(plotly) | |
library(shiny) | |
library(magrittr) | |
library(dplyr) | |
py <- plot_ly(username="rAPI", key="yu680v5eii") | |
tidy_df <- read.csv("data/tidy_df.csv", stringsAsFactors = FALSE) | |
bubble_radius <- sqrt(tidy_df$pop / pi) |
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
#This script is necessary in the app folder | |
#but the user should not have to edit it | |
#Output Graph Function | |
graphOutput <- function(inputId, width="100%", height="550px") { | |
tagList( | |
singleton(tags$head( | |
tags$script(src="plotlyGraphWidget.js") | |
)), | |
tags$iframe(id=inputId, src="https://plot.ly/~playground/7.embed", |
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
var binding = new Shiny.OutputBinding(); | |
binding.find = function(scope) { | |
// not sure what this function does, or | |
// why its necessary... | |
console.log('binding.scope'); | |
return $(scope).find('.graphs'); | |
}; | |
binding.renderValue = function(el, messages) { |
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
def get_runner_record(url): | |
driver.get(url) | |
odd_even_l = ['OL', 'EL'] | |
odd_even_r = ['OR', 'ER'] | |
runner_record = { | |
'bib_num': [], | |
'name': [], | |
'cate': [], | |
'official_time': [], | |
'rank_all': [], |
OlderNewer