Skip to content

Instantly share code, notes, and snippets.

View n3ssuno's full-sized avatar

Carlo Bottai n3ssuno

View GitHub Profile
@n3ssuno
n3ssuno / pull_labels.R
Created November 30, 2022 16:40
Function to extract the "label" attribute from each variable in a data frame (e.g., useful to read the labels of data stored in a dta-type file)
pull_labels <- function(data, as_list = FALSE) {
var_labels <- df %>%
purrr::map(~ attr(.x, "label")) %>%
purrr::map_dfr(~ tibble(label = .x), .id = "name")
if (as_list) {
var_labels <- as.list(spread(var_labels, name, label))
}
return(var_labels)
}
@n3ssuno
n3ssuno / publications.js
Created September 26, 2021 18:05
JavaScript functions to transform a JSON containing bibliographic information, in an HTML string thought to be included in a personal website.
/*
Author: Carlo Bottai - carlo.bottai@gmail.com
Copyright (c) 2020 - Carlo Bottai
Licence: MIT
Date: 2020-01-21
This group of functions transform a JSON (generated by the bibtexParse function
used by ORCID from a BibTeX file) that contains bibliographic information,
in an HTML string thought to be included in a personal website.
@n3ssuno
n3ssuno / scoring_squares.tex
Last active September 26, 2021 10:12
Visual scores for a CV in LaTeX. Use \score{x}{Y} to add Y squares of which x colored and the others white to your CV. You can use it in combination with https://github.com/xdanaux/moderncv, adding this file in your local folder and \include{scoring_squares} into the top-matter of your document. If you are planning to use it in other classes, un…
\usepackage{tikz}
% \definecolor{color1}{rgb}{0.76, 0.13, 0.28}
\usetikzlibrary{shapes.geometric}
\newcommand\score[2]{
\pgfmathsetmacro\pgfxa{#1+1}
\tikzstyle{score_squares}=[draw, rectangle, minimum width=6.5pt]
\begin{tikzpicture}[baseline]
\foreach \i in {1,...,#2} {