Skip to content

Instantly share code, notes, and snippets.

View danhawkins's full-sized avatar

Danny Hawkins danhawkins

View GitHub Profile
@danhawkins
danhawkins / gist:405e1dc3fa22ef4b3a2c
Created November 19, 2015 12:46
Angular watch snipped
window.countWatchers = function () {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
angular.forEach(['$scope', '$isolateScope'], function (scopeProperty) {
if (element.data() && element.data().hasOwnProperty(scopeProperty)) {
angular.forEach(element.data()[scopeProperty].$$watchers, function (watcher) {
watchers.push(watcher);
@danhawkins
danhawkins / compare.rb
Created May 14, 2014 20:35
Compare Script
matched_in_staging = 0
matched_in_files = 0
unmatched = []
total = 0
Dir['prod/decision/doc_file/**/*.doc'].each do |file|
total += 1
staging_check_path = file.gsub('prod/','staging/')
if File.exists?(staging_check_path)
matched_in_staging += 1
def resolve_postcode_position(code)
cache_key = "postcode:geo:#{code.gsub(' ','')}"
coords = Rails.cache.fetch(cache_key) do
postcode_uri = URI.encode "https://maps.googleapis.com/maps/api/geocode/json?address=#{code},UK&sensor=false&key=#{CONFIG[:google][:api_key]}"
response = HTTParty.get(postcode_uri)
begin
response['results'].first['geometry']['location']
rescue
false