Skip to content

Instantly share code, notes, and snippets.

View ATGardner's full-sized avatar

Noam Gal ATGardner

View GitHub Profile
@ATGardner
ATGardner / master2main.sh
Last active June 21, 2020 06:08
A script to convert all personal GitHub repos' default branch from 'master' to 'main'
#! /bin/bash
# The script requires jq (https://stedolan.github.io/jq/) and gh-cli (https://cli.github.com/) > 0.10
# It assumes the current user is already logged into their GitHub account, and that they have SSH access set up
# with `gh config set git_protocol ssh`
#
# The script goes over all (up to 100) personal, non-archived, non-forked repositories, that currently has 'master' as
# their default branch and replaces it with NEW_DEFAULT (defined as 'main', but can be easily changed)
#
# It clones a new local repo from each one, creates a NEW_DEFAULT branch in it, pushes it, and also sets it as the
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
function alg(n) {
const array = [...Array(n).keys()];
shuffleArray(array);

Keybase proof

I hereby claim:

  • I am atgardner on github.
  • I am noamg (https://keybase.io/noamg) on keybase.
  • I have a public key ASA-95PEdmS2ayMKme0vb9_-MbiYLnZ65fcN5vzsi108jwo

To claim this, I am signing this object:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache"/>
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
// placed in /src folder
import 'babel-polyfill';
const rsLowerC = `[a-c\\xdf-\\xf6]`;
const rsUpperC = `[A-C\\xc0-\\xd6]`;
const working1 = rsLowerC + '+' + '(?=' + rsUpperC + ')';
const reWorking1 = RegExp(working1, 'g');
const rsLowerZ = `[a-z\\xdf-\\xf6]`;
const rsUpperZ = `[A-Z\\xc0-\\xd6]`;