Skip to content

Instantly share code, notes, and snippets.

View Kumquatum's full-sized avatar

Gwenaëlle Lemoine Kumquatum

View GitHub Profile
@Kumquatum
Kumquatum / ggplot_orderingObjects.R
Created October 27, 2017 20:23
Ordering objects inside ggplot with reorder()
# Setup
library(ggplot2)
# Sample set
fruit <- matrix(c("Apple","186","Banana","93","Elderberry","48","Durian", "28","Cherry", "28"), ncol = 2, byrow = TRUE)
colnames(fruit) <- c("Name","Freq")
fruit <- as.data.frame(fruit)
fruit$Freq <- as.numeric(as.character(fruit$Freq))
# Plot graph
library(ggplot2)
ggplot(data = data.frame(a = c(1,2,3), b=c(4,5,6)), aes(x=a, y=b)) + geom_point()
@Kumquatum
Kumquatum / restart_bluetooth.sh
Created July 31, 2018 17:43
Restart bluetooth service on ubuntu
# Restart bluetooth service on ubuntu when it can be toogle on/off
sudo /etc/init.d/bluetooth restart
@Kumquatum
Kumquatum / nested_list_inside_out.R
Created September 17, 2018 17:52
Re-organising a nested list to a new list were inside lists are the outside list
library(dplyr)
library(purrr)
mini = list(
fpkm = list(
A = data.frame(x = c(1,3,4), y = c(23,634,12)),
B = data.frame(x = c(4,7,8), y = c(22,857,35))
),
counts = list(
A = data.frame(x = c(0.1,0.3,4), y = c(0.23,0.634,0.12)),
@Kumquatum
Kumquatum / tree.sh
Last active March 29, 2019 12:49
tree without install
shopt -s globstar
for file in **/*
do
slash=${file//[^\/]}
case "${#slash}" in
0) echo "├── ${file}";;
1) echo "│ ├── ${file}";;
2) echo "│ │ ├── ${file}";;
esac
done
@Kumquatum
Kumquatum / list.depth.R
Last active January 8, 2020 10:48
Get list depth
# Computes max depth of a list (recursively)
depth <- function(this) {
if (is.list(this)) {
ifelse(length(this) > 0, 1 + max(sapply(this, depth)), 0)
} else { 0 }
}
# Wrapping function to check if first point of entry is a list
list.depth <- function(my_list) {
ifelse(is.list(my_list), depth(my_list), stop("my_list have to be a list"))
# Telling git to use a specific private key
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
User git

Personnal cgroup config

Based on paranoids blog article cgroup ubuntu 18.04 howto

Installing packages

sudo apt install cgroup-bin cgroup-lite cgroup-tools cgroupfs-mount libcgroup1

Config files

# ********************************************************************* #
# Quick script to find which example is the longest to run in a package #
# ********************************************************************* #
library(magrittr)
# Getting function name
functions <- list.files("man") %>%
strsplit(".Rd")
@Kumquatum
Kumquatum / multiple_note.tex
Created November 12, 2020 19:13
Function to create notes with different counters and refer to it
\documentclass{article}
\usepackage[utf8]{inputenc}
\newcommand\note[2]{\getid{#1}\label{note:#1:#2}\textsuperscript{\ref{note:#1:#2}}}
\makeatletter
\newcommand{\getid}[1]{%
\@ifundefined{c@#1}
{% the counter doesn't exist
\newcounter{#1}\setcounter{#1}{1}%
}