Skip to main content

Posts

Showing posts from January, 2023

Working with Git from Existing Repo to New Repo

 git clone existing repo in IDE  git clone https://github.com/org/repo.git make necessary changes in the files  git remote -v it list all the remote urls in the local system IDE origin https://github.com/org/repo.git (fetch) origin https://github.com/org/repo.git (push) git rename existing origin url to new old-orign git remote rename origin old-origin git add new repo url to origin git remote add origin https://github.com/org/repo2.git verify origin urls git remote -v should get 4 urls 2 for old-origin(old repo) and 2 for (new repo) origin  git reinitialize  git init .   Reinitialized existing Git repository in C:/repo/.git/ git add all files git add . commit the changes  git commit -m "Initial" git remove .idea files  git rm -r --cached .idea  removes already tracked files in git rm -r .idea  this deletes all .idea files including the folder locally git push -u origin --all git remote remove old-origin

Code Snippet for Using Impersonation

Spanner  from google.cloud import spanner import google.auth from google.auth import impersonated_credentials credentials ,project = google.auth.default() #get default credentials and project target_credentials = impersonated_credentials.Credentials(source_credentials=credentials,  target_principals = impersonate_sa_to, #give sa to which you want to impersonate  target_scopes=["https://www.googleapis.com/auth/cloud-platform"] ) spanner_client=spanner.Client(credentials=target_credentials) instance = spanner_client.instance(instance_id) database=instance.database(database_id)

Registering Custom Python Environment in Jupyter Notebook

 Setting up of custom python Environment in Notebook  Refer  RStudio  for using virutalenv Below is the process to setup using conda  from a terminal in Jupiter ,create and activate a new conda environment conda create -n <env-name> conda activate <env-name> (Switch to bash to enable conda) in that new activated environment , install package ipykernel conda install ipykernal Register conda environment python -m ipykernal install --name python-env --display-name "Conda Python Env" --user Refresh the launcher to see new kernel which you created in above process