Skip to content

Instantly share code, notes, and snippets.

Avatar

Jordi jrosell

View GitHub Profile
@jrosell
jrosell / puppeteer-fetch-and-render-docker.js
Created Oct 27, 2020
Fetch and render using an specific google chrome version. We'll use appropiate zenika/alpine-chrome docker image.
View puppeteer-fetch-and-render-docker.js
// puppeteer-fetch-and-render-docker.js
// Fetch and render using an specific google chrome version
// We'll use appropiate zenika/alpine-chrome docker image. More information: https://github.com/Zenika/alpine-chrome
// Run:
// $ docker run -it --mount src="$(pwd)",target=/myproject,type=bind zenika/alpine-chrome:76-with-puppeteer /bin/sh
// /usr/src/app# cp /myproject/puppeteer-fetch-and-render.js .
// /usr/src/app# node puppeteer-fetch-and-render.js
// /usr/src/app# cp screenshot.png /myproject
// /usr/src/app# exit
@jrosell
jrosell / conflicted.R
Created Jul 31, 2020
Como visualizar y resolver los conflictos entre distintos paquetes en R usando el paquete conflicted.
View conflicted.R
if(!require(tidyverse)) install.packages("tidyverse")
if(!require(conflicted)) install.packages("conflicted")
tidyverse_update()
library(tidyverse)
library(MASS)
library(conflicted)
conflict_scout()
Cars93 %>% dplyr::select(Origin)
@jrosell
jrosell / trello-to-pdf.Rmd
Last active Jul 28, 2020
Código de ejemplo de generación de un PDF a partir de un board de Trello. En este caso https://trello.com/b/NoiWfLdi/trello-backend-example-public
View trello-to-pdf.Rmd
---
title: "Trello to PDF"
author: "jrosell"
date: "2020-07-28"
output: pdf_document
---
## R Markdown
This is an R Markdown document. It gets Trello cards and its attachments from specific list on a public board and build a PDF document from it.
View comunicar.R
if(!require(tidyverse)) install.packages("tidyverse")
if(!require(patchwork)) install.packages("patchwork")
library(patchwork)
library(tidyverse)
library(lubridate)
# Añadir anotaciones
ggplot(mpg, aes(displ, hwy)) +
geom_point(aes(color = class)) +
geom_smooth(se = FALSE) + labs(
View eurostat.Rmd
---
title: "Impuestos y sueldos por país en Europa"
author: "Jordi Rosell"
date: "2020-06-08"
output:
html_document:
df_print: paged
---
```{r setup, include=FALSE}
View procesar.R
if(!require(tidyverse)) install.packages("tidyverse")
if(!require(patchwork)) install.packages("patchwork")
if(!require(nycflights13)) install.packages('nycflights13')
if(!require(tidymodels)) install.packages("tidymodels")
if(!require(modelr)) install.packages("modelr")
library(tidymodels)
library(nycflights13)
library(patchwork)
library(tidyverse)
library(lubridate)
View ordenar.R
if(!require(tidyverse)) install.packages("tidyverse")
library(tidyverse)
# Alargar filas fundiendo columnas
relig_income
longer <- relig_income %>% pivot_longer(-religion, names_to = "income", values_to = "count") %>% print()
# Ensanchar columnas proyectando filas
us_rent_income
wider <- us_rent_income %>% pivot_wider(names_from = variable, values_from = c(estimate, moe)) %>% print()
View importar.R
if(!require(tidyverse)) install.packages("tidyverse")
if(!require(feather)) install.packages("feather")
if(!require(RSQLite)) install.packages("RSQLite")
library(tidyverse)
library(hms)
library(haven)
library(feather)
library(readxl)
library(DBI)
@jrosell
jrosell / magento_api.php
Last active Jul 2, 2020
From Magento 2 admin panel, create a new user with a new role with sales, customers and catalog permisions. Change baseURL, username and password lines 9-11. Change example order id, customer id and product sku if needed (lines 31, 38, 45). Run from cli: php magento_api.php
View magento_api.php
<?php
class Runner {
public $baseURL;
public $username;
public $password;
public $token_string;
function __construct() {
$this->baseURL = "https://domain.com/index.php";
$this->username = "magento_api";
View explorar.R
if(!require(tidyverse)) install.packages("tidyverse")
if(!require(patchwork)) install.packages("patchwork")
if(!require(nycflights13)) install.packages('nycflights13')
if(!require(tidymodels)) install.packages("tidymodels")
if(!require(modelr)) install.packages("modelr")
library(tidymodels)
library(modelr)
library(tidymodels)
library(patchwork)
library(tidyverse)