Skip to content

Instantly share code, notes, and snippets.

View cognivator's full-sized avatar

cognivator cognivator

View GitHub Profile
@cognivator
cognivator / exd_noclutter
Created April 4, 2016 22:45
Prevent OSX clutter on external storage
#!/bin/bash
# protect an ext drive (USB, memcard, etc) from the following files:
# .Spotlight-V* (Spotlight index)
# .Trashes (Deleted files)
# .fseventsd/* (journaling)
# .DS_Store (finder prefs... not implemented, yet)
# run this from the root of the drive that should be protected
@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
@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 / 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',
// 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 / 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,

@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 / 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 / .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.