Skip to content

Instantly share code, notes, and snippets.

sqdemon () {
a=0
while [[ $a != 1 ]]; do
date
squeue -u achateigner
a=$(squeue -u achateigner | wc -l)
echo $a
sleep ${1:-10}
nblines=$(echo "$a + 2" | bc)
#############################################################################
## Function to Calculate Monthly Mortgage Payments and Amortization Tables ##
#############################################################################
# Author: Thomas Girke
# Last update: Feb 27, 2007
# Utility: Calculates monthly and annual loan or mortgage payments, generates amortization tables and plots the results
# How to run the script:
# source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/mortgage.R")
# Definitions:
manhattanPlus <- function (x, chr = "CHR", bp = "BP", p = "P", snp = "SNP",
col = c("gray10", "gray60"), chrlabs = NULL,
suggestiveline = -log10(1e-05),
genomewideline = -log10(5e-08), highlight = NULL,
logp = TRUE, annotatePval = NULL, annotateTop = TRUE,
otherColors = rev(viridis::viridis(3)[1:2]),
otherDataColName = FALSE, otherCatName = FALSE,
...)
{
CHR = BP = P = index = NULL
excelRemoveProtection(){
echo "Usage: exelRemoveProtection fichier.xlsx"
unzip "$1" -d tmp
cd tmp/xl/worksheets/
for i in "$(ls *.xml)" ; do
sed -i 's/Protection password="[A-Za-z0-9]*"/Protection password=""/' $i
echo "Hacked $i"
done
cd ..
sed -i 's/Protection workbookPassword="[A-Za-z0-9]*"/Protection workbookPassword=""/' workbook.xml
loadAllChunksCache <- function(fileContainingChunks,
pathForCache = paste0(sub(".Rmd", "", fileContainingChunks),
"_cache/",
names(which(sapply(c("html", "pdf", "word"),
function(x)dir.exists(paste0(sub(".Rmd", "", fileContainingChunks), "_cache/", x, "/")))))[1],
"/")){
lignesDeNomDeChunk <- grep("^```{r", readLines(fileContainingChunks), perl = TRUE, value = TRUE)
nomsDeChunks <- sapply(strsplit(
sapply(strsplit(
sapply(strsplit(lignesDeNomDeChunk, "{r ", perl = TRUE), function(x) x[[2]]),
@achateigner
achateigner / tin.R
Last active October 11, 2017 07:25
`%tin%` <- function(x, y) {
mapply(assign, as.character(substitute(x)[-1]), y,
MoreArgs = list(envir = parent.frame()))
invisible()
}
@achateigner
achateigner / ipak.R
Last active August 29, 2017 12:22 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
# if install fails, try bioconductor
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg)){
if (! any(grep("BiocInstaller", search()))){
source("https://bioconductor.org/biocLite.R")
library(BiocInstaller)
@achateigner
achateigner / ipak.R
Created August 29, 2017 12:20 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
@achateigner
achateigner / captions_and_crossrefs.rmd
Created April 21, 2017 09:26 — forked from benmarwick/captions_and_crossrefs.rmd
Auto-numbering and cross-referencing of figures and tables in rmarkdown
---
title: "Auto-numbering and cross-referencing of figures and tables in rmarkdown"
output: html_document
---
TODO: check this out: https://github.com/adletaw/captioner
Here's how to use:
1. Copy and paste the first two code chunks in this document to the top of your document