Skip to content

Instantly share code, notes, and snippets.

@davemasse
davemasse / amazon-registry.js
Last active January 26, 2017 02:37
Calculate the total dollar amount of the visible Amazon.com registry
(function ($) {
$(function () {
var total = 0;
var preg = new RegExp(/[^0-9.]/g);
$("[id^='item_price'] .a-color-price").each(function () {
total += parseFloat($(this).text().replace(preg, ""));
});
console.log(total);
});
})(jQuery);
@davemasse
davemasse / nest.py
Last active August 29, 2015 14:12
Check the away temperature of Nest thermostats and send an SMS notification via Twilio if the difference is greater than the defined number of degrees Fahrenheit
import nest_thermostat as nest
import twilio
import twilio.rest
from nest_thermostat import utils as nest_utils
import settings
def main():
sent_message_count = 0
@davemasse
davemasse / .bashrc
Created May 31, 2013 02:23 — forked from tag-dmasse/.bashrc
Change directory upwards to the first directory containing a .git directory. Helpful in quickly getting to the root of a git project.
cdg () {
CD="`~/bin/cdg.sh`"
cd $CD
}
@davemasse
davemasse / analytics_debug.js
Created March 13, 2013 15:26 — forked from davemasse-mam/analytics_debug.js
It can be difficult to tell what’s being tracked by Google Analytics with the delay between triggering actions in the browser and seeing those records in the Google Analytics dashboard. This is a quick and dirty way to track Google Analytics actions locally to make sure events are being triggered correctly before going to production.
// Debugging of Analytics calls via console.log
function _gaq_pop() {
var max = _gaq.length;
// Iterate only up to the current length of the object to prevent issues with _gaq.push being called while in the loop
for (var i = 0; i < max; i++) {
if (console && console.log) {
console.log(_gaq.shift());
}
}
@davemasse
davemasse / main.py
Created September 8, 2012 01:59
Set Dropcam status based on Alarm.com arming status
import requests
from pyquery import PyQuery
import settings
if __name__ == '__main__':
# Log in to Alarm.com page
payload = {
'JavaScriptTest': '1',
'cookieTest': '1',
@davemasse
davemasse / postgis.sh
Created October 3, 2011 13:35
Creating a postgis-enabled database for geocoding
#!/bin/bash
DATABASE=''
POSTGISPATH=''
USER=''
sudo -u postgres createdb -O $USER $DATABASE
sudo -u postgres psql -d $DATABASE -f $POSTGISPATH/postgis/postgis.sql
sudo -u postgres psql -d $DATABASE -f $POSTGISPATH/spatial_ref_sys.sql
bash $POSTGISPATH/extras/tiger_geocoder/tiger_2010/create_geocode.sh
@davemasse
davemasse / gist:1203577
Last active September 27, 2015 03:18
jQuery bookmarklet using Ben Alman's generator
// Makes local newspaper pages accessible by undoing poorly written JavaScript protections
doWall = function(){};
$('#cboxOverlay').remove();
$('#colorbox').remove();
$('#pagination1').find(':hidden').show();
@davemasse
davemasse / gist:1199557
Last active October 12, 2015 01:36
jQuery bookmarklet using Ben Alman's generator
// Makes local newspaper archives accessible by altering archive links (PDFs are not password-protected!)
(function($) {
monthArray = {
January: '01',
February: '02',
March: '03',
April: '04',
May: '05',
June: '06',