Skip to content

Instantly share code, notes, and snippets.

@sahilseth
sahilseth / .Rprofile
Created March 9, 2021 18:33
Rprofile
cat .Rprofile
# setup R lib path ---------
#.libPaths("/home/sseth/R/x86_64-pc-linux-gnu-library/4.0")
vs = version
rver = paste0(vs$major, ".", strsplit(vs$minor, split = "\\.")[[1]][1])
# utils::osVersion
sess = utils::sessionInfo()
os = switch(sess$running,
@sahilseth
sahilseth / gglegend
Last active September 16, 2022 16:51
ggplot examples
override legend
# get it inside the plot, and remove alpha
theme(legend.position = c(0, 0.2),
legend.background = element_blank()) +
guides(colour = guide_legend(override.aes = list(alpha = 1)))
@sahilseth
sahilseth / .screenrc
Created June 24, 2020 19:09 — forked from joaopizani/.screenrc
A killer GNU Screen Config
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
@sahilseth
sahilseth / linux tips
Last active September 4, 2023 22:10
Linux Tips
## cursor size:
settings >> universal access
@sahilseth
sahilseth / lsf_tips.sh
Last active March 25, 2019 23:30
lst_tips
# job details
bhist -l 707919
# prioritize jobs, move them to the TOP
top_jobs=$(bjobs | grep shrna | grep PEND | awk '{print $1}')
for job in $top_jobs; do btop $job; done
# change the resources (change cpu reqt to 4)
bmod -R span[ptile=4] -n4 707919
yesno <- function(...) {
yeses <- c("Yes", "Definitely", "For sure", "Yup", "Yeah",
"I agree", "Absolutely")
nos <- c("No way", "Not yet", "I forget", "No", "Nope", "Uhhhh... Maybe?")
qs <- c(sample(yeses, 1), sample(nos, 2))
rand <- sample(length(qs))
cat(paste0(..., collapse = ""))
menu(qs[rand]) == which(rand == 1)
@sahilseth
sahilseth / expand_grid.R
Created December 19, 2017 22:36
expand_grid
#' expand_grid
#' @export
expand_grid <- function(x, y, remove_diag = TRUE){
x1 <- seq_along(x)
y1 <- seq_along(y)
ex <- expand.grid(x1, y1)
ex <- ex[ex[,2]>=ex[,1],]
@sahilseth
sahilseth / cols_20.R
Last active December 17, 2017 05:24
ggplot color bar
col20 = list("Red" = c("#e6194b", "(230, 25, 75)", "(0, 100, 66, 0)"),
"Green" = c("#3cb44b", "(60, 180, 75)", "(75, 0, 100, 0)"),
"Yellow" = c("#ffe119", "(255, 225, 25)", "(0, 25, 95, 0)"),
"Blue" = c("#0082c8", "(0, 130, 200)", "(100, 35, 0, 0)"),
"Orange" = c("#f58231" , "(245, 130, 48)", "(0, 60, 92, 0)"),
"Purple" = c("#911eb4" , "(145, 30, 180)", "(35, 70, 0, 0)"),
"Cyan" = c("#46f0f0" , "(70, 240, 240)", "(70, 0, 0, 0)"),
"Magenta" = c("#f032e6" , "(240, 50, 230)", "(0, 100, 0, 0)"),
"Lime" = c("#d2f53c" , "(210, 245, 60)", "(35, 0, 100, 0)"),
"Pink" = c("#fabebe" , "(250, 190, 190)", "(0, 30, 15, 0)"),
@sahilseth
sahilseth / ggplot_legend.R
Created December 1, 2017 18:55
ggplot2 legend
# get it inside the plot, and remove alpha
theme(legend.position = c(0, 0.2),
legend.background = element_blank()) +
guides(colour = guide_legend(override.aes = list(alpha = 1))) +
@sahilseth
sahilseth / re_install_r_pkgs.R
Last active July 17, 2017 16:06
Re-install R packages
#source("https://gist.githubusercontent.com/sahilseth/5dcc71cf2b563edca9b56e2d920543be/raw/re_install_r_pkgs.R")
pkgs = unlist(read.table("~/Dropbox/misc/Rpkgs.txt", stringsAsFactors = FALSE))
# idea1 (works)
ins = installed.packages()[, 1]
need_pkgs = pkgs[which(is.na(match(pkgs, ins)))]
length(need_pkgs)
need_pkgs