Skip to content

Instantly share code, notes, and snippets.

View lindacmsheard's full-sized avatar

Linda Sheard lindacmsheard

  • Microsoft
View GitHub Profile
@lindacmsheard
lindacmsheard / dealing_with_merge_conflicts.md
Created December 3, 2020 20:08
Dealing with merge conflicts in Git - the short and simple explanation

Dealing with merge conflicts

Merge conflicts are not scary. Any good text editor like VSCode for example will help with buttons and visualisations of what you need to do. But here's the gist...

When a merge conflict occurs, git will actually insert some lines in the file to mark the spot and show both versions of lines that are conflicting:

<<<<<<< HEAD
my current text in the file
=======

Disclaimer: There are many subtleties to using git - this is a very basic workflow. Discuss in your team how you want to work!

Pre-req

This gist assumes that you have authorisation to clone/pull/push from your repo. Either it is public, or you have set up ssh authentication.

Git basics

git clone <http or ssh link from git portal>
# change into the folder that is created as a result of the cloning.
cd <repo name>
@lindacmsheard
lindacmsheard / bashaliases.md
Last active December 3, 2020 20:14
cool aliases for bash

Note: these are tested on WSLv2 - add them to ~/.bash_aliases or other bash profile file.

Open sites in browser

alias newgist='wslview https://gist.github.com'
alias newgit='wslview https://github.com'
alias ap='wslview https://portal.azure.com'

# go to current repo web page - requires cli.github.com (ref [1])
alias gg='gh repo view --web'
@lindacmsheard
lindacmsheard / amlcheck-currentsubscription.sh
Last active October 30, 2020 10:58
Azure ML Management: use the Azure cli to check for running AML compute instances
#!/bin/bash
########################################################################################
# Check for or stop all running Azure ML compute instances within the current #
# subscription or specified workspace #
# * uses the azure resource graph to check for resources across resource groups #
# * assumes Azure CLI is installed and a default subscription is set (az account set) #
# * use the -h option to see usage #
########################################################################################

Here’s a scala notebook cell to run an arbitrary TSQL batch using JDBC:

%scala

import java.util.Properties
import java.sql.DriverManager

val jdbcUsername = dbutils.secrets.get(scope = "kv", key = "sqluser")
val jdbcPassword = dbutils.secrets.get(scope = "kv", key = "sqlpassword")

Using Device Login with Azure ML when working with multiple tenants.

The Device login routine used by the AML Python SDK uses the default tenant associated with the login account. This can create issues when working with AML instances in other tenants.

Use the simple login if your AML workspace is within your default tenant. Use the alternative login to force login into a specific tenant.

Simple login to workspace:

This uses the config.json file in the directory structure of the local system. For an AML-provisioned compute VM, this file is located at the root /config.json. If you get an error here as a result of logging into the wrong tenant, use the alternative below.

from azureml.core import Workspace
ws.Workspace.from_config()

Working with Conda

Generic badge

Conda helps you manage python environments on your local machine, keeping your system python free of packages that you may need for your python experiments.

Install Miniconda on Linux or WSL

-> See this gist

@lindacmsheard
lindacmsheard / WSL-install-miniconda.md
Last active November 23, 2022 16:57
Install miniconda on WSL

Install Miniconda on Linux or WSL

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# yes yes
source ~/.bashrc
rm Miniconda3-latest-Linux-x86_64.sh

# to ensure WSL can start normally without an active conda env