1. Before Install Packages
sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev zlib1g-dev
sudo apt-get install libmysqlclient-dev
sudo apt-get install libsodium-dev
sudo apt-get libfontconfig1-dev
sudo apt-get install unixodbc-dev
sudo apt-get install libpq-dev
sudo apt install libpng-dev
2. set repos
options(repos='http://cran.rstudio.com/')
3. edit Rprofile
file.edit(file.path("~", ".Rprofile"))
4. read_tsv with encoding and default col_types
readr::read_tsv('file',
locale = locale(encoding = 'gbk'),
col_types = cols(.default = 'c'))
5. shinyproxy get username
as.list(Sys.getenv())$SHINYPROXY_USERNAME
6. vscode pipe shortcut
[{
"key": "ctrl+shift+m",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus editorLangId == 'r'",
"args": {
"snippet": " |> "
}
}]
7. fidelius
title: "Fidelius Config"
output:
fidelius::html_password_protected:
output_format:
rmarkdown::html_document:
toc: true
toc_float: true
password: 'pw123'
preview: false
style:
header_text: 'My Report'
placeholder_text: 'plz input password'
button_text: 'confirm'
library(fidelius)
charm(
'app.rmd',
password = '',
style = stylize(
header_text = 'Welcome!'
placeholder_text = 'Enter your password',
button_text = 'Confirm',
),
output = 'app.html'
)
8. connect wps webhook
reticulate::py_run_string(r"(
def connect_wps(token,webhook):
import http.client
conn = http.client.HTTPSConnection("www.kdocs.cn")
payload = "{\"Context\":{\"argv\":{}}}"
headers = {
'Content-Type': "application/json",
'AirScript-Token': token
}
conn.request("POST", webhook, payload, headers)
res = conn.getresponse()
data = res.read().decode("utf-8")
return data
)")
reticulate::py$connect_wps(
"token",
"https://www.kdocs.cn/api/v3/ide/file/xx/script/xx/sync_task"
)
readWps <- function(token,webhook){
http <- reticulate::import('http.client')
conn = http$HTTPSConnection('www.kdocs.cn')
payload = "{\"Context\":{\"argv\":{}}}"
headers =
list(
`Content-Type` = "application/json",
`AirScript-Token`= token
)
conn$request('POST',
webhook,
payload, headers)
res = conn$getresponse()
dt <- jsonlite::fromJSON(
res$read()$decode('utf-8'))$data$result$abc
dt <- setNames(data.frame(dt[-1,]),dt[1,])
return(dt)
}