Skip to content

Instantly share code, notes, and snippets.

View yatharthranjan's full-sized avatar
👨‍💻
Codes are a puzzle. A game, just like any other game.

Yatharth Ranjan yatharthranjan

👨‍💻
Codes are a puzzle. A game, just like any other game.
View GitHub Profile
@yatharthranjan
yatharthranjan / update-all-collaborator-permissions-org.sh
Last active December 19, 2024 19:26
A bash script for updating permissions of all the outside collaborators (not organisation members) to read for all public repositories in an organisation and remove them in case of private repositories.
#!/usr/bin/env bash
# Ask for GitHub organization name
read -p "Enter GitHub organization name: " org
# Ask for GitHub token
read -sp "Enter GitHub token: " token
echo
# Set the number of repositories to fetch per page
@yatharthranjan
yatharthranjan / fork-or-sync-all-repos-between-2-orgs.sh
Created December 19, 2024 12:47
A bash script to fork all repositories from one organisation to other. If repo already exists in destination org, then it creates a PR for the default branch to sync the changes if any.
#!/usr/bin/env bash
# Ask for user input
read -p "Enter the source organization: " source_org
read -p "Enter the destination organization: " dest_org
read -p "Enter the GitHub token: " gh_token
read -p "Enter the repositories to exclude (comma-separated): " excluded_repos_input
# Convert comma-separated excluded repositories to an array
IFS=',' read -r -a excluded_repos <<< "$excluded_repos_input"
@yatharthranjan
yatharthranjan / top_correlation.py
Last active September 19, 2021 11:25
Get top correlation pair in a very large number of variables in Pandas Dataframe
def get_top_correlations_blog(df, threshold=0.4):
"""
df: the dataframe to get correlations from
threshold: the maximum and minimum value to include for correlations. For eg, if this is 0.4, only pairs haveing a correlation coefficient greater than 0.4 or less than -0.4 will be included in the results.
"""
orig_corr = df.corr()
c = orig_corr.abs()
so = c.unstack()
@yatharthranjan
yatharthranjan / Redis
Last active September 18, 2020 11:38
Redis Cheatsheet
Redis Cheatsheet for commands- https://cheatography.com/tasjaevan/cheat-sheets/redis/
@yatharthranjan
yatharthranjan / rsync.md
Last active September 1, 2020 11:04
Rsync commands

To sync files from remote to local

rsync -avz --stats --dry-run --relative -e "ssh -i path/to/somekey" "[email protected]:/remote/path/./data/*/datatype/" ~/local/path/data/datatype/

Replace the local and remote path as per your requirements. This is for getting data from the datatype folder for all folders within the data folder. Put path to your ssh key in place of path/to/somekey and replace [email protected] with your connection string for your remote machine.

This does the following-

  1. --stats shows the progress and other statistics
  2. --dry-run performs a check run but does not tranfer any data. Remove it to actually intiate the data transfer