This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // trigger a digest manually | |
| $scope.$apply(function() { | |
| contactsService | |
| .getCommon('todd@conspire.com') | |
| .then(success, failure); | |
| }); | |
| // zero-delay $timeout | |
| $timeout(function() { | |
| contactsService |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('commonContactsModule').factory('contactsService', [ | |
| '$q', | |
| '$http', | |
| function($q, $http) { | |
| function getCommon(targetEmail) { | |
| var url = 'https://www.conspire.com/commonContacts?email=' + encodeURIComponent(targetEmail); | |
| var promise; | |
| // want the cache to be global so it can be shared amongst all widgets | |
| if (typeof commonContactsCache === 'undefined') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('commonContactsModule').factory('contactsService', [ | |
| '$q', | |
| '$http', | |
| function($q, $http) { | |
| function getCommon(targetEmail) { | |
| var url = 'https://www.conspire.com/commonContacts?email=' + encodeURIComponent(targetEmail); | |
| var promise; | |
| // want the cache to be global so it can be shared amongst all widgets | |
| if (typeof commonContactsCache === 'undefined') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('focusOnClick', function() { | |
| var button; | |
| var $testInput; | |
| beforeEach(function() { | |
| module('gmail'); | |
| inject(function($compile, $rootScope) { | |
| button = $compile('<button focus-on-click="#test-input"></button>')($rootScope.$new()); | |
| $testInput = $('<input id="test-input" type="text">'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('gmail').directive('focusOnClick', [ | |
| function() { | |
| return { | |
| restrict: 'A', | |
| link: function($scope, $el, attrs) { | |
| function focusOnClick() { | |
| // Note: selector must uniquely identify the element in the page | |
| $(attrs.focusOnClick).focus(); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Schema for a draft table to hold all of the picks | |
| CREATE TABLE IF NOT EXISTS draft | |
| ( | |
| year smallint(4) unsigned, | |
| pick smallint(3) unsigned, | |
| name varchar(255), | |
| team varchar(255), | |
| position varchar(5), | |
| school varchar(255) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getDimensions(str) { | |
| for (var height = Math.floor(Math.sqrt(str.length)); height > 0; height--) { | |
| if (str.length % height === 0) { | |
| break; | |
| } | |
| } | |
| return { | |
| height: height, | |
| width: str.length / height |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/bash | |
| START_TIME=$SECONDS | |
| # erase file so it can be re-run | |
| > results.txt | |
| get_record() { | |
| record=$(curl --silent http://www.baseball-reference.com/teams/NYY/$1.shtml | ack -o 'content="\d+-\d+' | sed s/content=\"//g | uniq) | |
| echo "$i: $record" >> results.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sync { | |
| default.rsyncssh, | |
| source="/home/toddbranch/work/mywedding", | |
| host="dev", | |
| targetdir="/www/dev-env/tbranchflower/www/virtual/mywedding/current", | |
| delete="running", | |
| exclude={ ".*", | |
| "*.tmp", | |
| "mywedding/src/fonts", | |
| "assets", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Code snippets from 8facd2c613eee0c81581e840c33b1d5a4770d935 | |
| // No need to understand how they work, just need to know that: | |
| // removeArticle is the interface that client-side code uses | |
| // removeArticleFromTemplate and getTemplateFromProduct are internal helper functions | |
| /** | |
| * Remove an article at the specified index | |
| * | |
| * @param index |