Skip to content

Instantly share code, notes, and snippets.

View cognivator's full-sized avatar

cognivator cognivator

View GitHub Profile
@cognivator
cognivator / macos_multiple_SSH_keys.md
Last active March 28, 2024 19:32
Manage multiple SSH keys on MacOS

Situation

There are plenty of references for generating and using SSH keys on MacOS. Google for answers and they're everywhere. What is less obvious is how to use multiple SSH keys, especially for the same host, e.g. GitHub. I had multiple SSH keys and a ~/.ssh/config file, but certain of the credentials weren't being found.

Solution

The nuggets of goodness I found describe how to properly use ~/.ssh/config - (here, here, here, here... +many more). The key is actually using the resulting Host aliases!

Go figure, huh? 🤦

Example: Github - SourceTree

@cognivator
cognivator / .Insomnia_SalesforceAPI.md
Last active June 15, 2020 22:49
Insomnia template for Salesforce REST API with Oauth password flow

Install

Import the accompanying insomnia_salesforceAPI.json into Insomnia to create a workspace with sample requests that,

  • get a bearer token using Salesforce built-in Oauth password workflow
  • make REST API requests referencing the bearer token

Setup / Customize

Environment

The environment variables are stored in MyOrg folder.

@cognivator
cognivator / sourcetree_intellij_diffmerge.md
Last active September 19, 2019 23:43
Configure Sourcetree to use Intellij (Jetbrains) as external Diff or Merge tool

Summary

If the prescribed method of configuring Sourcetree using Jetbrains' command line scripts fails, here is an alternative configuration:

Diff

  • Diff Command: open -W -n -b "com.jetbrains.intellij" --args
  • Diff Arguments: diff "$LOCAL" "$PWD/$REMOTE"

Merge

  • Merge Command: open -W -n -b "com.jetbrains.intellij" --args
  • Merge Arguments: merge "$PWD/$LOCAL" "$PWD/$REMOTE" "$PWD/$BASE" "$PWD/$MERGED"
@cognivator
cognivator / git_fetch_by_hash
Created September 4, 2018 22:47
SourceTree Custom Action to FETCH the selected branch
#!/bin/bash
set -e
set -o pipefail
unset fetch_git_branch
fetch_git_branch=`git name-rev --refs=heads/* --name-only $1 | grep -oE '^[^~]+'`
echo fetching... $fetch_git_branch
@cognivator
cognivator / Hipchat_sort-and-display-people.md
Last active June 28, 2018 16:49
Hipchat - sort and display Rooms & People

Edit HipChat.app/Contents/Resources/chat.html

  1. In _getPeopleList, replace,
...
name: room.name
...

with,

// Assumes jwt-client has been loaded to define JWT global
(function expireJWT() {
JWT.defaults = {key: 'jwt', tokenPrefix: '', storage: window.localStorage, padding: false};
decodedJWT = JWT.read(JWT.get());
decodedJWT.claim.exp = (Date.now() / 1000) - 1;
JWT.keep(decodedJWT);
})();
@cognivator
cognivator / ui-router controller instantiation.md
Last active August 25, 2016 19:33
ui-router: testing for controller instantiation

Scenario

You're using ui-router to manage Angular 1.x routing states. You have a parent state that should always navigate to a child state, but without relying on ui-router-extras like $deepStateRedirect. This is to avoid deep linking into the child state. Some logins need to operate this way, for instance, so the Terms of Service acknowledgement cannot be skipped.

Configuration

This is an example ui-router state hierarchy that defines a series of states used for login pages.

$stateProvider
  .state('login', {
 url: '/login',
@cognivator
cognivator / showAllStates.md
Last active July 26, 2016 17:34
showStates - console function to extract the configured states of ui-router and print them to the console as a JSON tree.

Usage

At the Javascript console, run showAllStates() to see a JSON tree of the currently configured ui-router states as returned by $state.get().

Installation

Copy showStates code below into your Javascript console (tested with Chrome Devtools), and execute it to create the showStates function. Optionally, create similar functions in the console with the other scripts in this gist.

showAllStates = function () {
	var $injector = angular.element('html').injector(),
@cognivator
cognivator / gitignore-cache-clean.sh
Last active April 17, 2016 03:36
.gitignore cache cleaning
#!/bin/bash
# Run this from the root of a git repo - AFTER YOU COMMIT THE CHANGES YOU CARE ABOUT!
# Then, if you need to keep the deleted files in your working copy (e.g. IDE config files),
# be sure to unstage them before your next commit.
# attribution: http://www.randallkent.com/2010/04/30/gitignore-not-working/
for file in `cat .gitignore` ; do git rm -r --cached $file; done