This file contains 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
var times = { | |
Schedule: { | |
"2014-09-26T00:00:00": [1,23], | |
"2014-09-27T00:00:00": [9,14] | |
} | |
}; | |
function formatHour(hour) { | |
return hour > 12 ? |
This file contains 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
// ripped directly from http://www.airpair.com/angularjs/posts/top-10-mistakes-angularjs-developers-make | |
(function () { var root = $(document.getElementsByTagName('body')); var watchers = []; var f = function (element) { if (element.data().hasOwnProperty('$scope')) { angular.forEach(element.data().$scope.$$watchers, function (watcher) { watchers.push(watcher); }); } angular.forEach(element.children(), function (childElement) { f($(childElement)); }); }; f(root); console.log(watchers.length); })(); |
This file contains 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
# if you're interested, you can follow the conversation around how to make `populate_wildcards` | |
# more idiomatic on /r/ruby: | |
# https://www.reddit.com/r/ruby/comments/2iyzab/is_there_a_more_idiomatic_andor_functional_way_to/ | |
# my initial approach | |
def populate_wildcards(a,b) | |
a.merge(b) { |key, left, right| | |
if left.is_a? Hash | |
populate_wildcards(left, right) |
This file contains 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
# from http://blog.crowdint.com/2013/06/14/testing-rails-with-minitest.html | |
# config/initializers/generators.rb | |
Rails.application.config.generators do |g| | |
g.helper false | |
g.assets false | |
g.view_specs false | |
end |
This file contains 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
# see http://jsfiddle.net/xfgh6yew/ | |
#outer-0 { | |
/* | |
separating `position:relative` from `overflow: hidden` | |
allows the `position: absolute` overflow to happen | |
*/ | |
position: relative; | |
} |
This file contains 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 watchFactoryValue(localValue, factoryGetter) { | |
$scope.$watch(factoryGetter, function () { | |
localValue = factoryGetter(); | |
}); | |
}; |
This file contains 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
def get_nested_hash_keys(hash) | |
# there must be a more clever way to do this using reduce/inject... | |
hash.map { |key, value| | |
if value.is_a? Hash | |
[key, get_nested_hash_keys(value)] | |
else | |
key | |
end | |
}.flatten.sort |
This file contains 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
require 'json' | |
package = File.open 'package.json', 'r' | |
json = JSON.parse package.read() | |
deps = json['dependencies'].keys | |
versions = deps.map { |dep| `npm list --depth=0 | grep #{dep}` }.map { |version| version.split(/.?\s(.+)/)[1] } |
This file contains 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
$(document).ready(function(){ | |
countdown(); | |
setInterval(countdown, 1000); | |
function countdown () { | |
var now = moment(), // get the current moment | |
// May 28, 2013 @ 12:00AM | |
then = moment([2013, 4, 28]), | |
// get the difference from now to then in ms | |
ms = then.diff(now, 'milliseconds', true); | |
// If you need years, uncomment this line and make sure you add it to the concatonated phrase |
This file contains 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
# assumes some.directive.js/some.directive.spec.js naming convention | |
directives = (`find . -name *.directive.js`).split(/\r\n|\n/) | |
directive_specs = (`find . -name *.directive.spec.js`).split(/\r\n|\n/).map { |directive| directive.gsub(/\.spec/, '') } | |
directives_without_specs = directives - directive_specs | |
puts directives_without_specs | |