Skip to content

Instantly share code, notes, and snippets.

Avatar

Luis Sevillano LuisSevillano

View GitHub Profile
@LuisSevillano
LuisSevillano / node.md
Last active Oct 30, 2019
Regex to replace commas to points in gedit
View node.md

How to use a regex to replace commas with points using gedit: Having a csv like following:

c,m,p2019,p2016,p2015,p2011
w,x,"75.74","77.50","74.98","78.14"
g,f,"76.80","71.99","71.97","77.75"
i,b,"69.41","64.28","62.95","69.20"
b,h,"80.00","77.41","74.58","80.13"
@LuisSevillano
LuisSevillano / script.R
Created Sep 30, 2019
Extract data from ggplot plot
View script.R
plot <- ggplot(data = pf, aes(x = age, y = df)) +
geom_point(alpha = 1/100,
position = position_jitter(h = 0),
color = "darkred")
ggplot(data = layer_data(plot, 1), aes(x = x, y = y)) +
geom_point(alpha = 1/20)
@LuisSevillano
LuisSevillano / .block
Last active Oct 19, 2019
New composite border in es-atlas
View .block
border:none
height:696
license:MIT
View autonomous_regions.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@LuisSevillano
LuisSevillano / .block
Last active Sep 13, 2019
d3-composite-projections test
View .block
border:none
height:700
@LuisSevillano
LuisSevillano / combineHeaders.R
Last active Aug 8, 2019
A R function to deal with datasets with a double header
View combineHeaders.R
library(tidyverse)
library(ggplot2)
library(janitor)
library(readxl)
filePath <- "data/4247.xlsx"
csv <- read_xlsx(filePath, skip = 6)
# This function fills empty cells with previous values to the right and then combine them with the row above
@LuisSevillano
LuisSevillano / .block
Last active May 23, 2019
Rivers of Spain
View .block
border: none
height: 650
@LuisSevillano
LuisSevillano / query.sql
Created Feb 28, 2019
Add new column in PostgreSQL with a subquery and set a NOT NULL constraint
View query.sql
BEGIN;
ALTER TABLE table1 ADD COLUMN exp_id text;
UPDATE table1
SET exp_id = temp_query.exp_id
FROM (
SELECT t2.exp_id FROM table2 t2 JOIN table1 t1 on t2.gid = t1.gid
) AS temp_query;
@LuisSevillano
LuisSevillano / script.sh
Created Jan 21, 2019
Bash script to process frames and convert then to a video format with ffmpeg
View script.sh
#!/usr/bin/env bash
# https://askubuntu.com/questions/610903/how-can-i-create-a-video-file-from-a-set-of-jpg-images
ffmpeg -framerate 30 -i \
path_to_file_%04d.jpeg \
-c:v libx264 \
-profile:v high \
-crf 18 \
-pix_fmt yuv420p \
output.mp4
@LuisSevillano
LuisSevillano / close.sql
Created Dec 6, 2018
Close all connections from a Postgres database
View close.sql
SELECT *, pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'database';
You can’t perform that action at this time.