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(magrittr) | |
#url | |
u <- 'http://pesquisajuris.tjdft.jus.br/IndexadorAcordaos-web/sistj?visaoId=tjdf.sistj.acordaoeletronico.buscaindexada.apresentacao.VisaoBuscaAcordao&controladorId=tjdf.sistj.acordaoeletronico.buscaindexada.apresentacao.ControladorBuscaAcordao&visaoAnterior=tjdf.sistj.acordaoeletronico.buscaindexada.apresentacao.VisaoBuscaAcordao&nomeDaPagina=resultado&comando=abrirDadosDoAcordao&enderecoDoServlet=sistj&historicoDePaginas=buscaLivre&quantidadeDeRegistros=20&baseSelecionada=BASE_ACORDAO_TODAS&numeroDaUltimaPagina=1&buscaIndexada=1&mostrarPaginaSelecaoTipoResultado=false&totalHits=1&internet=1&numeroDoDocumento=1005250' | |
# usei html session pra economizar codigo de escrever o form inteiro | |
s <- rvest::html_session(u) | |
form <- rvest::html_form(s)[[1]] %>% | |
rvest::set_values(comando = 'downloadInteiroTeor') | |
s <- rvest::submit_form(s, form) |
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
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip | |
# under public domain terms | |
country_bounding_boxes = { | |
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)), | |
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)), | |
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)), | |
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)), | |
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)), | |
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)), |
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
#https://github.com/ateucher/useful_code/blob/master/R/numbers2words.r | |
numbers2words <- function(x){ | |
## Function by John Fox found here: | |
## http://tolstoy.newcastle.edu.au/R/help/05/04/2715.html | |
## Tweaks by AJH to add commas and "and" | |
helper <- function(x){ | |
digits <- rev(strsplit(as.character(x), "")[[1]]) | |
nDigits <- length(digits) | |
if (nDigits == 1) as.vector(ones[digits]) |
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(caret) | |
library(tm) | |
# Training data. | |
data <- c('Cats like to chase mice.', 'Dogs like to eat big bones.') | |
corpus <- VCorpus(VectorSource(data)) | |
# Create a document term matrix. | |
tdm <- DocumentTermMatrix(corpus, list(removePunctuation = TRUE, stopwords = TRUE, stemming = TRUE, removeNumbers = TRUE)) |
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 node | |
RUN mkdir -p /usr/src/app | |
COPY index.js /usr/src/app | |
EXPOSE 8080 | |
CMD [ "node", "/usr/src/app/index" ] |
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
// XPath CheatSheet | |
// To test XPath in your Chrome Debugger: $x('/html/body') | |
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/ | |
// 0. XPath Examples. | |
// More: http://xpath.alephzarro.com/content/cheatsheet.html | |
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class |
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(shiny) | |
library(shinyjs) | |
# This would usually come from your user database. But we want to keep it simple. | |
password_hash <- bcrypt::hashpw('secret123') # Never store passwords as clear text | |
sessionid <- "OQGYIrpOvV3KnOpBSPgOhqGxz2dE5A9IpKhP6Dy2kd7xIQhLjwYzskn9mIhRAVHo" # Our not so random sessionid | |
jsCode <- ' |
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
## GUIDE TO AUTH2 Authentication in R Shiny (or other online apps) | |
## | |
## Mark Edmondson 2015-02-16 - @HoloMarkeD | http://markedmondson.me | |
## | |
## v 0.1 | |
## | |
## | |
## Go to the Google API console and activate the APIs you need. https://code.google.com/apis/console/?pli=1 | |
## Get your client ID, and client secret for use below, and put in the URL of your app in the redirect URIs | |
## e.g. I put in https://mark.shinyapps.io/ga-effect/ for the GA Effect app, |
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(shiny) | |
# WARNING: This sketch does not make proper use of the "state" parameter. | |
# Doing so usually involves using cookies, which can be done with the | |
# Rook package but I have not done that here. If you choose to use this | |
# approach in production, please check the state parameter properly! | |
APP_URL <- if (interactive()) { | |
# This might be useful for local development. If not, just hardcode APP_URL | |
# to the deployed URL that you'll provide a few lines below. |
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
## Versão do ubuntu | |
`lsb_release -a` |
OlderNewer