Skip to content

Instantly share code, notes, and snippets.

View deepakramani's full-sized avatar

Deepak Ramani deepakramani

View GitHub Profile
@deepakramani
deepakramani / git_commands.md
Last active March 2, 2022 09:02
Git commands
git config -l # for local config
git config --global -l # for global config
git config --global user.name "name"
git config --global user.email "email address"
git config --global credential.helper cache # store login credentials
git add remote https://repo_here # add new remote repo
git remote -v # list of remote repo
@deepakramani
deepakramani / ssh_key_to_agent.md
Last active February 8, 2022 15:30
Adding SSH key to agent(for Mac OS)

SSH config

The interaction between github and local system can be configured using a file called config inside ~/.ssh/. Here each host can be given specific setting to act accordingly.

Adding Host

For github host can be defined as Host github.com. More general setting can be added under Host *.

Adding ssh key to agent

Adding keys to the agent is done through AddKeysToAgent yes. In Mac OS, it is possible to store even the passphrase to their secure keychain password management system. With UseKeychain yes that setting is enabled. In the case of git-lfs for a push or fetch operation, passphrase must be entered more than once.

@deepakramani
deepakramani / git_first_steps.md
Last active June 16, 2022 07:27
First steps with Git
  1. Install Git appropriate for the platform
  2. Stow git folder from dotfiles repo. .gitconfig and .gitignore file should be stowed. Change the contents if necessary.
    git config --global user.name "Mona Lisa"
    git config --global user.email "john@xyx.com"
    
    If the email needs to be private, check out this link
  3. Stow ssh from dotfiles repo. It should show .ssh/config file. Modify if needed.
  4. Create ssh key and sync with github. Generate using ssh-keygen with appropriate key requirement. Since AddKeysToAgent yes entry is present within Host * field in config file, we can use ssh-add to add the private key we created to the ssh-agent. This allows the agent to take care of autheticating at every communication with the remote url.
  5. Goto github profile settings, ssh an
@deepakramani
deepakramani / postgres-cheatsheet.md
Created January 19, 2022 16:40 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)

Nix on macOS Catalina

I'm writing this gist for my own records but it might help someone else too.

Installing Nix

Support for Catalina has improved a lot since the update was first rolled out.

Note: See the NixOS manual for discussion of the --darwin-use-unencrypted-nix-store-volume option.

@deepakramani
deepakramani / gist:3a66b58dcb1e45d6775805a6286f1b39
Created August 18, 2021 17:21
Combine GroupFold and Stratified Fold
def stratified_group_k_fold(X, y, groups, k, seed=None):
"""Source: https://www.kaggle.com/jakubwasikowski/stratified-group-k-fold-cross-validation """
labels_num = np.max(y) + 1
y_counts_per_group = collections.defaultdict(lambda: np.zeros(labels_num))
y_distr = collections.Counter()
for label, g in zip(y, groups):
y_counts_per_group[g][label] += 1
y_distr[label] += 1
y_counts_per_fold = collections.defaultdict(lambda: np.zeros(labels_num))