Skip to content

Instantly share code, notes, and snippets.

@ozika
ozika / tmux.md
Last active August 17, 2023 09:47

Create new session tmux new -s session_name

Disattach session ctrl+b, then d

Attach session tmux a -t session_name

Start interactive session with specific memory and cpus

## add new remote
git remote add temp_origin <<remote address>>

## push/pull as needed
git push temp_origin branch-name
git pull temp_origin branch-name

## switching back (assuming usual remote is called origin, check via git remote -v
git push origin branch-name
f, ax = plt.subplots(1,1,figsize=(5,5))
cols= ["black", "red"]
for lidx, lvl in enumerate(["high", "low"]):
    ttdf = behdf.loc[behdf["TF2_PhysiolAnx_ms"].isin([lvl])]
    sns.regplot(data=ttdf, x="prob_safe", y="shnosh_diff_mflr", color=cols[lidx], ax=ax)
    corrfunc(ttdf["prob_safe"], ttdf["shnosh_diff_mflr"], tests=[ "spearman"], drop_missing=True, xanchor=0.4, yanchor=0+lidx*0.06, boxcolor=cols[lidx])

where corrfunc() is

# where m is an estimated model
pars <- parameters(m)
pars <- pars %>% mutate(sig = case_when(p<0.05 ~ "sig", 
                               p>=0.05 ~ "nonsig"))
g<- plot(pars) + scale_color_manual(values = c("black", "red")) 
# A bit hacky, one needs to set the quosure expression manually like this, this basically changes the mapping of the aes from the default (CI in plot()) to `sig`
g$mapping$colour<-quo_set_expr(g$mapping$colour, expr=expr(.data$sig))
print(g)
generate_equation <- function(dep_var, vec_to_iterate, vec_interactions, other_terms, reffs) {
   eq <- ""
   eq <- paste0(dep_var, " ~ ")
   eff1 <- paste(vec_to_iterate, sep="", collapse=" + ")
   eq <- paste0(eq, eff1)
   
   for (i in vec_interactions) {
     eff2 <- paste0(paste(vec_to_iterate, sep="+", collapse=paste0("*", i, " + ")), paste0("*", i))
 eq &lt;- paste(eq, eff2, sep=" + ", collapse=" + ")
### Split by quantile
import numpy as np
import pandas as pd
col = np.arange(17)
a = pd.DataFrame(col, columns=["tt"])
a['tricut_2'] = pd.qcut(a['tt'], [0, .33, .66, 1],labels=['low', 'mid', 'high'])
a
### Demean
## PREP STEPS
# disable sudo prompt
#sudo visudo
sudo apt install -y vim
sudo update-alternatives --config editor
sudo apt install -y curl
## UPDATE & UPGRADE ##
sudo apt update
@ozika
ozika / virtual_env.md
Last active October 2, 2024 11:02
Create virtual env using conda

Set up virtual environment in R and Python

Python

From yml file using conda. Example yml file, create this as my_python_env.yml

name: my_python_env
channels:
  - conda-forge
 - defaults
@ozika
ozika / SHH keys.md
Last active December 30, 2022 18:19
Probelms with SSH and github

Create a key

Go to user's ssh key location (normaly ~/.ssh)
ssh-keygen -t ed25519 -C "dubovy.prkno@email.com"
name it: <<local>>_2_<<remote>> (e.g. ondrej_2_gitlab this is just my silly convention)

This creates two files, the private key (which should only stay on your computer) and the public key (<<NAME>>*.pub which you will need to copy and add to the remote server).

Add to ssh agent

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/&lt;&gt;

@ozika
ozika / datalad_setup.md
Last active August 31, 2022 12:26
Setting up datalad dataset (core steps)
  • add locking

requirements

create data set from a folder

datalad create -f [folder]

to ignore a folder you can use

.gitignore