Skip to content

Instantly share code, notes, and snippets.

View verajosemanuel's full-sized avatar
💭
RRRRRRRRRRRRRRRR

Jose Manuel Vera verajosemanuel

💭
RRRRRRRRRRRRRRRR
View GitHub Profile
@verajosemanuel
verajosemanuel / split_file_by_line.sh
Last active March 25, 2021 16:55
#split #file by #lines in #bash
for file in *.txt; do split -l 1 -d --additional-suffix=${${file}%.*}_$(uuidgen).xml $file;done
# split by size
split -b 256M --additional-suffix=.csv myfile.csv splitted_
# split 5 parts taking lines
split --number=l/5 inputfile outputprefix --additional-suffix=.csv
#split keeping header
tail -n +2 operate.csv | split -l 2 - --filter='sh -c "{ head -n1 operate.csv; cat; } > $FILE"'
@verajosemanuel
verajosemanuel / add_content_plotly_tooltip.R
Last active January 31, 2021 13:45
Add #tooltip content to #plotly
# Your first question was to customize the tooltip so it displays
# some of the variables in the dataset (including those not mapped to aesthetics).
# In your UPDATE#3 you introduce:text = paste("Province:", NAME_1) into your aes.
# If you want to add a second line of custom variables or text, just keep adding it into the
# brackets:text = paste("Province:", NAME_1, "Example III:", example1)
#
# To add a line break between both add <br> in the spot where you want the break to be, like:
text = paste("Province:", NAME_1, "<br>", "Example III:", example1)
@verajosemanuel
verajosemanuel / leaflet_multiline_label.R
Created January 21, 2021 11:18
#leaflet #map add #multiline #label in #R
labs <- lapply(seq(nrow(df)), function(i) {
paste0( "<font color='purple'>",df[i, "nombre"], ', ',
df[i, "provincia"], '</font></br>',
"(",
round(df[i, "coord_lat"],2),' / ',
round(df[i, "coord_lon"],2),
")")
})
@verajosemanuel
verajosemanuel / unrar_windows_r.R
Created January 15, 2021 09:35
#uncompress #rar files in windows with #R
z7path = shQuote('C:\\Program Files\\7-Zip\\7z')
cmd <- paste(z7path, ' e ', rarfile, ' -ir!*.* -o', '"', temp_folder, '"', sep='')
system(cmd)
@verajosemanuel
verajosemanuel / rmd2Randback.R
Last active December 9, 2020 17:38
from #Rscript to #Rmd and back in #R
knitr::spin() # to Rmd
knitr::curl() # to Rscript
rmarkdown::render("analysis.R") # to html
rmarkdown::render("analysis.R", "pdf_document") # to pdf
@verajosemanuel
verajosemanuel / github_packages.R
Last active December 9, 2020 08:23
detect #github #packages in #R #library
library(tidyverse)
allmypackages <- as.data.frame(installed.packages())
allmypackages <- allmypackages %>%
filter(Priority != "base" | is.na(Priority)) %>%
select(-c(Enhances:MD5sum, LinkingTo:Suggests)) %>%
droplevels()
package_source <- function(pkg){
x <- as.character(packageDescription(pkg)$Repository)
if (length(x)==0) {
@verajosemanuel
verajosemanuel / updatePackages.R
Created November 16, 2020 08:55
#update all #packages in #R
update.packages(checkBuilt = T, ask = F, repos = "http://cran.rstudio.com/")
@verajosemanuel
verajosemanuel / add_column_name_list_df.R
Created November 3, 2020 12:55
#add #dataframe #name to a #list of dataframes in #R with #purr
library(purrr)
ans <- map_df(past_earnings_lists, ~as.data.frame(.x), .id="id")
@verajosemanuel
verajosemanuel / opml2org.py
Created January 15, 2020 13:15
#convert #feedly #opml to #org #elfeed
from bs4 import BeautifulSoup
with open("feeds.opml") as data:
soup = BeautifulSoup(data.read(), "lxml")
for feed in soup.find_all("outline"):
print(f"** [[{feed.get('xmlurl')}][{feed.get('text')}]]")
@verajosemanuel
verajosemanuel / vimplugneovim.vimrc
Created December 18, 2019 13:50
set #vim plug in #neovim
"setup vim-plug {{{
"Note: install vim-plug if not present
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
"Note: Skip initialization for vim-tiny or vim-small.
if !1 | finish | endif