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
install.packages(c('tinytex', 'rmarkdown','blogdown')) | |
tinytex::install_tinytex() |
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
## Rule 0: strings as factors!!! | |
options(stringsAsFactors=FALSE) | |
## To avoid quaint time zone issues, set to UTC if you are working on a single timezone | |
Sys.setenv(TZ="UTC") | |
## on_sys_locale_problems | |
sudo defaults write org.R-project.R force.LANG en_US.UTF-8 #Mac Terminal | |
Sys.setlocale("LC_ALL", 'en_US.UTF-8') #Linux R Console | |
Sys.setlocale(locale="Turkish_Turkey.1254") #Windows |
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
pti <- c("shiny","tidyverse","ggplot2movies") | |
pti <- pti[!(pti %in% installed.packages())] | |
if(length(pti)>0){ | |
install.packages(pti) | |
} | |
########## | |
### Shiny starter code | |
########## | |
library(shiny) |
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
## İlgili veri setinde önizleme'ye tıklayın çıkan url adresinde "/resource/"tan sonraki kodu kopyalayın (data_id) | |
ibb_data_pull <- function(data_id="e1e2b771-b4de-49d3-b779-17b4bba10fb7"){ | |
ibb_query_url <- paste0("https://data.ibb.gov.tr/api/3/action/datastore_search_sql?sql=SELECT%20*%20from%20%22",data_id,"%22") | |
json_query_response <- jsonlite::fromJSON(ibb_query_url) | |
return_df <- json_query_response$result$records %>% rename_all(~gsub("^_","",.)) %>% rename_all(~gsub(" |\\(|\\)|/","_",.)) %>% tbl_df() | |
return(return_df) |
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(tidyverse) | |
library(lubridate) | |
library(jsonlite) | |
library(devtools) | |
#https://data.ibb.gov.tr/dataset/ikitelli-gunes-enerjisi-santrali-elektrik-uretim-miktarlari/resource/52afa9a3-2ea1-420b-a783-505cfe635ece | |
devtools::source_gist("https://gist.github.com/berkorbay/493e82b3d48245317c57a5d0c334492e") | |
raw_df <- ibb_data_pull("52afa9a3-2ea1-420b-a783-505cfe635ece") | |
wip_df <- raw_df %>% transmute(dt = as_datetime(Tarih),production=as.numeric(Uretim__kWh_)) |
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
## Paketler yüklü değilse install.packages kullanın | |
## install.packages(c("tidyverse","jsonlite"),repos="https://cran.r-project.org") | |
library(tidyverse) | |
library(jsonlite) | |
ispark_query_url <- "https://data.ibb.gov.tr/api/3/action/datastore_search_sql?sql=SELECT%20*%20from%20%22c3eb0d72-1ce4-4983-a3a8-6b0b4b19fcb9%22" | |
raw_value <- fromJSON(ispark_query_url) | |
raw_df <- raw_value$result$records %>% rename_all(~gsub("^_","",.)) %>% rename_all(~gsub(" |\\(|\\)|/","_",.)) %>% tbl_df() |
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
options(stringsAsFactors=FALSE) | |
library(tidyverse) | |
library(rvest) | |
library(gmailr) | |
## FOLLOW AUTH INSTRUCTIONS FROM HERE https://gmailr.r-lib.org/articles/gmailr.html | |
parse_order_table <-function(my_msg,full_info_list=FALSE){ | |
my_info <- read_html(gm_body(my_msg)) %>% html_nodes(xpath="/html/body/table/tr/td/center/table[1]/tr[2]/td") %>% html_children() %>% `[[`(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
####### | |
#### This gist is a very quick way to implement just authentication function. This is a minimal example. | |
#### You need an AWS IAM account and your AWS Cognito User Pool set up. | |
#### Check the steps in the description of https://github.com/chi2labs/cognitoR | |
#### After creating your user pool on the left sidebar under General Settings, click on App clients | |
### Make sure "Enable username password based authentication (ALLOW_USER_PASSWORD_AUTH)" is checked | |
### Create a user from the interface for testing purposes. Let username be "usertest" and password be "passtest". | |
####### | |
#### Variables |
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 python:3.9.6 | |
RUN pip install --no-cache-dir streamlit | |
EXPOSE 8501 | |
ENTRYPOINT [ "streamlit" ] | |
CMD ["hello"] | |
## FOR ANY APPLICATION | |
ENTRYPOINT [ "streamlit", "run"] | |
CMD ["my_streamlit_file.py"] |
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 is an example docker run command to run streamlit which will include an ortools model | |
# -m 12g will keep the memory at 12GB | |
# --oom-kill-disable will prevent the container to go under because of out of memory sigkill | |
docker run -dp 80:8501 --oom-kill-disable -m 12g <image_name> |