Skip to content

Instantly share code, notes, and snippets.

Avatar

Geraldo Castro geraldofcneto

View GitHub Profile
View stateMock.js
angular.module('stateMock',[]);
angular.module('stateMock').service("$state", function($q){
this.expectedTransitions = [];
this.transitionTo = function(stateName){
if(this.expectedTransitions.length > 0){
var expectedState = this.expectedTransitions.shift();
if(expectedState !== stateName){
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
}
}else{
@BobNisco
BobNisco / controller.js
Last active Apr 21, 2022
onLongPress AngularJS Directive - Great for mobile!
View controller.js
// Somewhere in your controllers for this given example
// Example functions
$scope.itemOnLongPress = function(id) {
console.log('Long press');
}
$scope.itemOnTouchEnd = function(id) {
console.log('Touch end');
}
@lyoshenka
lyoshenka / search-git-history.md
Last active Nov 29, 2022
Search Git commit history for a string and see the diffs
View search-git-history.md

Searching Git commit history

This should be one of the core features of Git, but for some reason it's impossible to figure out how to search for a string in your commit history and see the diffs that that string is in. Here's the best I've come up with:

To find which commits and which files a string was added or removed in:

git log -S'search string' --oneline --name-status

To see the diff of that

@jeffdonthemic
jeffdonthemic / gist:7247654
Last active Aug 6, 2020
Passing parameters in an Angular.js Controller to a Resource
View gist:7247654
<script>
// in the html page
angular.module('config', []).constant('APIKEY',''5250738f97ce29c219000011'');
</script>
myApp.controller('JobsCtrl', ['$scope', 'Jobs', 'APIKEY', function($scope, Jobs, apiKey) {
var promise = Jobs(apiKey).query().$promise;
// do more awesome programming
}