Skip to content

Instantly share code, notes, and snippets.

View ryanbehdad's full-sized avatar
🏃‍♂️

Ryan Behdad ryanbehdad

🏃‍♂️
View GitHub Profile
@ryanbehdad
ryanbehdad / tech_media.md
Last active July 12, 2019 05:01
Podcasts and Blogs
@ryanbehdad
ryanbehdad / decorators.py
Last active August 27, 2020 05:20
Python decorators
import functools
import time
def readable_time(t):
a = ''
if t < 1:
a = f'{t:.2f} sec'
elif t < 60:
a = f'{t:.0f} sec'
elif t < 3600:
@ryanbehdad
ryanbehdad / R in VS Code.md
Last active April 27, 2022 03:59
Coding in R using Visual Studio Code
@ryanbehdad
ryanbehdad / VS Code Keyboard Shortcuts.md
Last active June 26, 2020 05:06
VS Code Keyboard Shortcuts

Useful VS Code Keyboard Shortcuts

  • Ctrl + R Switching workspaces
  • Ctrl + P Go to file
  • Ctrl+B Toggle Sidebar Visibility
  • F4 Focus Next Search Result
  • Shift+F4 Focus Previous Search Result
  • Ctrl+` Toggle Integrated Terminal
  • Ctrl+Space Auto-complete
  • Crtl + Alt + up (or down): repeat cursor
  • ALT + CLICK — Repeat cursor
@ryanbehdad
ryanbehdad / venv.md
Created June 29, 2020 06:32
Python venv cheat sheet

Python venv virtual environment cheat sheet

Create a venv

To create a virtual environment, go to the root of your project and run

python -m venv venv

It will create a virtual environment called venv

Activate venv

.\venv\Scripts\activate

@ryanbehdad
ryanbehdad / venv.md
Last active May 3, 2024 10:10
Python venv cheat sheet

Python venv virtual environment cheat sheet

Create a venv

To create a virtual environment, go to the root of your project and run

python -m venv venv

It will create a virtual environment called venv

Activate venv

.\venv\Scripts\activate

@ryanbehdad
ryanbehdad / rstudio in docker.md
Last active March 3, 2021 06:49
Running RStudio in docker

Running RStudio in docker

Run docker

To start the docker container, run the following command:

docker run -d -p 8787:8787 -v C:\source:/home/rstudio -e ROOT=TRUE -e PASSWORD=rstudio rocker/rstudio

In the above command, I'm mounting "C:\source" to "/home/rstudio", thus providing the container access to all the contents of "C:\source".

If you want to mount multiple paths use -v multiple time. Example:

@ryanbehdad
ryanbehdad / bash.md
Last active July 10, 2020 01:31
bash commands

bash commands

mkdir

Make directory mkdir folder_name

Can create multiple directories in one command

mkdir Jan Feb Mar

@ryanbehdad
ryanbehdad / conda.md
Last active April 5, 2024 07:04
Conda cheat sheet

Conda cheat sheet

Setup a conda environment

  conda create --name ds python=3.11 numpy pandas scikit-learn matplotlib seaborn jupyter plotly ipykernel pyodbc

Activate the environment

activate ds

@ryanbehdad
ryanbehdad / df_summary.py
Last active August 11, 2020 09:40
Print a summary of a pandas dataframe and its columns
# =======================================================================
# Print a summary of a pandas dataframe and its columns
# =======================================================================
def df_summary(df):
print(f'Dataframe has {df.shape[0]:,} rows and {df.shape[1]:,} columns')
if len(df) > 1:
summary = pd.DataFrame(df.dtypes, columns=['dtype']).reset_index()
summary.rename(columns={'index': 'feature'}, inplace=True)
summary['missing'] = df.isnull().sum().values
summary['uniques'] = df.nunique().values