Skip to content

Instantly share code, notes, and snippets.

View berkorbay's full-sized avatar
🏄

Berk Orbay berkorbay

🏄
  • Tideseed
  • Istanbul, Turkey
  • 01:03 (UTC +03:00)
View GitHub Profile
@berkorbay
berkorbay / cognito_r_direct_query.R
Created February 17, 2021 07:35
AWS Cognito Simple Authentication with R
#######
#### 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
@berkorbay
berkorbay / parse_ys_gmail_threads.R
Last active May 24, 2020 11:58
Parses YS order emails and brings them under a single data frame
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 April 6, 2020 19:03
QNB Finansbank Rest API Methods
# 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.md
Last active September 7, 2025 08:56
To install Github Desktop for Ubuntu

IMPORTANT

See the following links for further updates to Github Desktop for Ubuntu. These are official instructions. (also mentioned by fetwar on Nov 3, 2023)

For the sake of "maintaining the tradition" here is the updated version.

@berkorbay
berkorbay / ibb_solar_panel_analysis.R
Created January 19, 2020 18:56
İBB Açık Veri Portalı İkitelli Güneş Enerjisi Santrali üretim verisi inceleme kodu
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 January 19, 2020 18:52
İBB Açık Veri Portalı'ndan veri çekme R fonksiyonu
## İ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 January 19, 2020 13:51
İBB Açık Veri APIsini kullanarak İSPARK lokasyonlarını bir data frame'e indirip tibble'a dönüştürme kodu
## 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 February 8, 2019 07:44
R'a başlangıç için kurulması gereken paketler / R starter packages
## Ö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())]
@berkorbay
berkorbay / mef_bda_503_2018_week_4.r
Last active April 3, 2019 12:20
Week 4 preparation
pti <- c("shiny","tidyverse","ggplot2movies")
pti <- pti[!(pti %in% installed.packages())]
if(length(pti)>0){
install.packages(pti)
}
##########
### Shiny starter code
##########
library(shiny)
install.packages(c('tinytex', 'rmarkdown','blogdown'))
tinytex::install_tinytex()