This is a SCRIPT-8 cassette.
This file contains hidden or 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(data.table) | |
| library(dplyr) | |
| library(tidyr) | |
| # Lê os arquivos de candidatos das diferentes eleições. | |
| # Os arquivo estão disponíveis no repositório do tse -> https://www.tse.jus.br/eleicoes/estatisticas/repositorio-de-dados-eleitorais-1/repositorio-de-dados-eleitorais | |
| # Onde esta o "~/devel/blablabla" você troca pelo lugar onde o arquivo esta salvo no seu computador. | |
| # O parametro "sep" é para definir o separador, que no caso dos arquivos do TSE é ; | |
| # O parametro encoding é a codificação dos acentos (isso esta detalhado no PDF que vem junto com os arquivos) |
This file contains hidden or 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(data.table) | |
| library(dplyr) | |
| library(DescTools) | |
| library(ggplot2) | |
| candidatos2020 <- fread("~/devel/datasets/eleicoes/2020/candidatos/consulta_cand_2020_BRASIL.csv", encoding = 'Latin-1') | |
| recursos2020 <- fread("~/devel/datasets/eleicoes/2020/contas/receitas/receitas_candidatos_2020_BRASIL.csv", encoding="Latin-1", dec=",", sep=";") %>% | |
| mutate(ORIGEM=ifelse(DS_ORIGEM_RECEITA=="Recursos de partido político","PARTIDO_2020","PRIVADO_2020")) %>% | |
| group_by(SQ_CANDIDATO, ORIGEM) %>% | |
| summarise(TOTAL=sum(VR_RECEITA)) %>% |
This file contains hidden or 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
| # Script para verificar candidatas que já se candidataram em 16 e 18 e calcula número de votos. | |
| # Baixar RStudio https://rstudio.com/products/rstudio/download/#download e R https://cran.rstudio.com/bin/windows/base/ | |
| # Carrega as bibliotecas necessárias. | |
| # data.table -> tem uma função para ler arquivos csv grandes mais rapidamente | |
| # dplyr -> tem o pipe ( %>% ) que permite encadear manipulações de dados e funções como group_by, select e filter para manipular os dados | |
| # Para instalar você usa 'install.packages("nomedopacote")' | |
| library(data.table) | |
| library(dplyr) |
This file contains hidden or 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
| #!/bin/bash | |
| URL="rtsp://192.168.0.33:554/user=admin&password=senhasecreta&channel=2&stream=.sdp" | |
| ARGS="-s 1280x720 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -vf fps=25" | |
| ffmpeg -r 30 -i "$URL" $ARGS -f v4l2 /dev/video2 |
This file contains hidden or 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
| #!/bin/sh | |
| MODULE="v4l2loopback" | |
| VIDEO=${1:-lula.mp4} | |
| ARGS="-s 1280x720 -vcodec rawvideo -pix_fmt yuv420p -threads 0" | |
| if lsmod | grep "$MODULE" &> /dev/null ; then | |
| sudo modprobe $MODULE exclusive_caps=1 | |
| else | |
| echo "$MODULE is loaded!" | |
| fi |
This file contains hidden or 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
| pay_taxes <- function(income, brackets){ | |
| # for each bracket, subtract x reais from income | |
| taxes_total <- 0 | |
| income_left <- income | |
| for(i in 1:nrow(brackets)){ | |
| # get taxed reais and tax rate | |
| reais_taxed <- brackets[i,]$reais - | |
| ifelse(i==1,0,brackets[i-1,]$reais) | |
This file contains hidden or 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 lxml.html import parse | |
| from urllib import request | |
| import csv | |
| def get_info_autor(autor): | |
| soup = parse(request.urlopen(autor['url'])).getroot() | |
| p = soup.cssselect("#infoGeral")[0] | |
| autor['partido'] = p.xpath('.//label[text()=" Partido "]')[0].getnext().text.strip() | |
| return autor |
This file contains hidden or 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 lxml.html import parse | |
| from urllib import request | |
| import csv | |
| def get_info_autor(autor): | |
| soup = parse(request.urlopen(autor['url'])).getroot() | |
| p = soup.cssselect("#infoGeral")[0] | |
| autor['partido'] = p.xpath('.//label[text()=" Partido "]')[0].getnext().text.strip() | |
| return autor |
This file contains hidden or 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
| #!/bin/bash | |
| API=API_KEY | |
| for i in *.jpg; do | |
| CMD="curl -H 'X-API-Key: ${API}' -F 'image_file=@$(pwd)/${i}' -f https://api.remove.bg/v1.0/removebg -o 'nobg_${i}.png'" | |
| $CMD | |
| done | |