Skip to content

Instantly share code, notes, and snippets.

View dasginganinja's full-sized avatar

Tom Donahue dasginganinja

  • Lehigh University
  • Bethlehem, PA
View GitHub Profile
@dasginganinja
dasginganinja / FSARetrieval.js
Last active August 29, 2015 13:58
Canadian FSA Retrieval from WIkipedia. Provides a comma delimited list. Example URL: http://en.wikipedia.org/wiki/List_of_B_postal_codes_of_Canada
(function($) {
var fsas = [];
$('table td:not([style]) b').each(
function() {
var val = $(this).text();
if (val.length == 3) {
fsas.push(val);
}
});
var csv = fsas.sort().join(',');
@dasginganinja
dasginganinja / PFMChooser.js
Created July 2, 2014 19:46
I didn't like the pager on a website so I created this.
if ($('.chooser').length == 0) {
var pagearr = [];
var $pageSel = $('<select class="chooser">').hide();
var pageMax = parseInt($('.pager').data('pages'));
var pageCur = parseInt($('.pager').data('currentpage'));
for(i=0;i<pageMax;++i) {
if (i < 5 || i >= (pageMax-5) || (i+1)%10 == 0 || ((i > pageCur-5) && (i < pageCur + 5))) {
pagearr.push({ val: i+1, text: (i+1)+" / "+pageMax });
}
}
@dasginganinja
dasginganinja / showTranslationsLinks.js
Created August 13, 2014 17:49
Drupal Field Translation links (from fields list in admin)
@dasginganinja
dasginganinja / km_hydraulics_sales_directory.module
Created January 26, 2015 18:14
Drupal 7 hook_menu local task troubles. Trying to add a local task to import/sales_person_importer/prepare_csv.
Feeds Paths:
Feeds Import -> import/%/ path definitions -> http://cgit.drupalcode.org/feeds/tree/feeds.module#n293
Feeds UI -> admin/structure/feeds/% path definitions -> http://cgit.drupalcode.org/feeds/tree/feeds_ui/feeds_ui.module#n46
@dasginganinja
dasginganinja / template.php
Created January 28, 2015 15:35
Drupal 7 Remove Breadcrumb and Title from homepage
function east_penn_trucks_20141222_preprocess_page(&$vars, $hook) {
// Remove the Breadcrumb and Title from the homepage
if ($vars['is_front']) :
$vars['breadcrumb'] = '';
$vars['title'] = '';
endif;
}
@dasginganinja
dasginganinja / template.php
Created July 8, 2015 13:52
Customizing Page Title for User View pages
/**
* Implements hook_menu_alter().
*/
function MYTHEME_menu_alter(&$items) {
$items['user/%user']['title callback'] = 'MYTHEME_user_page_title';
}
/**
* Custom Callback for setting page title.
*/
@dasginganinja
dasginganinja / gallery-export.sql
Last active August 29, 2015 14:28
ShepNet Gallery Export (all images on one line for import into D7)
@dasginganinja
dasginganinja / Shipping Rate - PA Tax Component Rules
Last active August 29, 2015 14:28
Drupal Commerce Sales Tax for Taxable Items & Shipping
{ "commerce_tax_rate_pa_sales_tax" : {
"LABEL" : "Calculate PA Sales Tax",
"PLUGIN" : "rule",
"OWNER" : "rules",
"TAGS" : [ "Commerce Tax", "sales_tax" ],
"REQUIRES" : [ "commerce_order", "rules", "commerce_tax" ],
"USES VARIABLES" : { "commerce_line_item" : { "label" : "Line item", "type" : "commerce_line_item" } },
"IF" : [
{ "commerce_order_compare_address" : {
"commerce_order" : [ "commerce-line-item:order" ],
@dasginganinja
dasginganinja / check-status.sh
Created October 29, 2015 16:27
HTTP Status checking
# Check for number of urls with 200 statuses
grep 200 out.txt | wc -l
@dasginganinja
dasginganinja / sis_site.install.php
Last active November 4, 2015 21:14
Drupal 7 Enable theme in hook_install
<?php
/**
* Implements hook_install().
*/
function sis_site_install() {
// Do some things on install, like setting the module weight.
// Setup the Adminimal theme
$themes = list_themes();