Skip to content

Instantly share code, notes, and snippets.

Avatar

Berk Orbay berkorbay

View GitHub Profile
@berkorbay
berkorbay / parse_ys_gmail_threads.R
Last active May 24, 2020
Parses YS order emails and brings them under a single data frame
View parse_ys_gmail_threads.R
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)
@berkorbay
berkorbay / qnb_finansbank_api_v0.r
Created Apr 6, 2020
QNB Finansbank Rest API Methods
View qnb_finansbank_api_v0.r
# Source: https://developer.qnbfinansbank.com
# Currently in beta phase so we DO NOT use id and secret instead we use a "code" from one of the accounts.
# Go to: https://developer.qnbfinansbank.com/discovery/GettingStarted/UseTestPlatform
## Follow steps until step 5. The code you get is your token
url = "https://sandbox-api.qnbfinansbank.com/v0/accounts"
my_token = "MY_VERY_LONG_TOKEN"
resval <- httr::GET(url, httr::add_headers(Authorization = paste("Bearer", the_token, sep = " ")))
@berkorbay
berkorbay / github_desktop_ubuntu.sh
Created Feb 5, 2020
To install Github Desktop for Ubuntu
View github_desktop_ubuntu.sh
sudo wget https://github.com/shiftkey/desktop/releases/download/release-2.1.0-linux1/GitHubDesktop-linux-2.1.0-linux1.deb
sudo gdebi GitHubDesktop-linux-2.1.0-linux1.deb
@berkorbay
berkorbay / ibb_solar_panel_analysis.R
Created Jan 19, 2020
İBB Açık Veri Portalı İkitelli Güneş Enerjisi Santrali üretim verisi inceleme kodu
View ibb_solar_panel_analysis.R
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_))
@berkorbay
berkorbay / ibb_open_data_query_function.R
Created Jan 19, 2020
İBB Açık Veri Portalı'ndan veri çekme R fonksiyonu
View ibb_open_data_query_function.R
## İ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)
@berkorbay
berkorbay / ibb_open_data_ispark_query.R
Created Jan 19, 2020
İBB Açık Veri APIsini kullanarak İSPARK lokasyonlarını bir data frame'e indirip tibble'a dönüştürme kodu
View ibb_open_data_ispark_query.R
## 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()
@berkorbay
berkorbay / r_baslangic.R
Created Feb 8, 2019
R'a başlangıç için kurulması gereken paketler / R starter packages
View r_baslangic.R
## Önce aşağıdakiler linklerinden programlar indirilerek kurulmalı
# R https://cran.r-project.org/
# RStudio Desktop https://www.rstudio.com/products/rstudio/download/
# Pandoc https://pandoc.org/installing.html
# LaTeX https://www.latex-project.org/get/
# Kurulması gereken paket listesi
# Bütün kodu kopyala yapıştır ile R'a koyun Hata alınan paketler olursa bazı başka kütüphanelerin yüklenmesi gerekebilir (ör. openssl)
pti <- c("devtools","tidyverse","shiny","shinydashboard","readxl","writexl","lubridate","reticulate","stringr","openxlsx","ggiraph","rhandsontable","shinycssloaders","rmarkdown","DBI","RMySQL","shinyjs","promises","future","ggmap","rlist","anytime","xml2","jsonlite","data.table")
pti<-pti[!(pti %in% installed.packages())]
View mef_bda_503_2018_week_4.r
pti <- c("shiny","tidyverse","ggplot2movies")
pti <- pti[!(pti %in% installed.packages())]
if(length(pti)>0){
install.packages(pti)
}
##########
### Shiny starter code
##########
library(shiny)
View r_ladies_istanbul_20180608.R
install.packages(c('tinytex', 'rmarkdown','blogdown'))
tinytex::install_tinytex()
View shinyproxy_steps.txt
#See https://www.shinyproxy.io/getting-started/
sudo nano /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// -D -H tcp://127.0.0.1:2375
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker pull openanalytics/shinyproxy-demo
You can’t perform that action at this time.