Skip to content

Instantly share code, notes, and snippets.

View joedougherty's full-sized avatar

Joe Dougherty joedougherty

View GitHub Profile
@joedougherty
joedougherty / j5_growl.js
Created January 17, 2014 22:23
Node version of Notifier
var growl = require('growl');
var five = require('johnny-five'),
board, button;
board = new five.Board();
board.on("ready", function() {
button = new five.Button(8);
function cheat_plus_one($num) {
return eval('return ' . $num .' '. eval('return chr(43);') . ' 1;');
}
import requests
from bs4 import BeautifulSoup
# Set the URL to download
endpoint = 'http://grants.nih.gov/searchGuide/Search_Guide_Results.cfm?Activity_Code=&Expdate_On_After=&OrderOn=ExpirationDate&OrderDirection=ASC&NoticesToo=0&OpeningDate_On_After=&Parent_FOA=All&PrimaryIC=Any&RelDate_On_After=&Status=1&SearchTerms=HIV&PAsToo=1&RFAsToo=1'
# Pull down the HTML from that URL
r = requests.get(endpoint)
page = r.content
@joedougherty
joedougherty / gist:4063888
Created November 13, 2012 04:11
Example template.php to add js just to front page
<?php
// Be sure to replace THEME_NAME with the name of the current theme
function THEME_NAME_preprocess_html(&$variables) {
if ( drupal_is_front_page() ) {
drupal_add_js( 'path/to/file' );
}
}
@joedougherty
joedougherty / gist:2252807
Created March 30, 2012 16:51
SEPTA API sales_locations item Object Structure
/*
Example: to access a location's address, call item.sales_data.ADDRESS;
*/
item
distance: float
location_id: int // ex: 928044
location_lat: string // ex: "39.9562551"
@joedougherty
joedougherty / ascendDOMLevels.js
Created March 8, 2012 19:48
Ascend the DOM in jQuery with succinct notation
/*
I found myself needing to traverse the DOM tree upward more than just a few levels in a recent project (mostly due to heavy element nesting).
This function takes two arguments: the element in question and the number of levels to ascend.
Finally, it returns the element that's n levels above the initial element.
Ex: $(this).parent().parent().parent().parent().parent() could be more concisely expressed as ascendDOMLevels($(this), 5).
*/