Skip to content

Instantly share code, notes, and snippets.

View ao5357's full-sized avatar
๐Ÿ™‚
Probably near my computer, probably something with emails

Brad Czerniak ao5357

๐Ÿ™‚
Probably near my computer, probably something with emails
View GitHub Profile
@ao5357
ao5357 / main.gs
Created March 30, 2018 00:10
Quick sentiment analysis macros for Google Sheets
/**
* @file
* Macros for getting sentiment scores and categories for NLP.
*/
// Google API Key for making a call to the NLP API.
var GoogleAPIKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
/**
* Sheets custom function for getting text out of a range, concatenating the text,
@ao5357
ao5357 / template.php
Created January 31, 2019 22:06
Override how a Drupal Page is Displayed Based on Content Type
<?php
/**
* Implements TEMPLATE_preprocess_page().
*/
function THEMENAME_preprocess_page(&$vars, $hook) {
$template_files = array();
foreach ($vars['template_files'] as $file) {
$template_files[] = $file;
if ($file == 'page-node') {
$template_files[] = 'page-'. $vars['node']->type;
@ao5357
ao5357 / example1.js
Created February 4, 2019 20:28
Google Analytics Events in Drupal
_gaq.push(['_trackEvent', Category, Action, Label, Value]);
@ao5357
ao5357 / example.module
Created February 4, 2019 22:08
Drupal's Front Page
<?php
/**
* Implements hook_menu().
*/
function MYMODULE_menu() {
$items = array();
$items['admin/content/frontpage'] = array(
'title' => 'Front page content',
@ao5357
ao5357 / Plugin.php
Created February 6, 2019 19:22
Placecage example code
<?php
$plugin = array(
'title' => t('Placecage'),
'class' => 'PlacecageProvider',
);
@ao5357
ao5357 / snippet1.js
Created February 6, 2019 23:32
Abstracting GA event codes into a helper function
_gaq.push(['_trackEvent', Category, Action, Label, Value]);
@ao5357
ao5357 / _mymodule.module
Created February 7, 2019 00:11
Drupal Webforms With Dynamic Select Boxes Tutorial
<?php
/**
* Pull a list of years from the database.
*/
function _mymodule_get_years() {
$year = Array();
// SELECT DISTINCT Year FROM <code>table</code> ORDER BY Year
$result = db_query( 'SELECT DISTINCT Year ' .
@ao5357
ao5357 / multi_widget_remove_tabledrag_field_widget_form_alter.php
Created February 8, 2019 15:03
How to remove tabledrag rearranging from multiple-value field widgets
<?php
/**
* Implements hook_field_widget_form_alter().
*/
function multi_widget_remove_tabledrag_field_widget_form_alter(&$element, &$form_state, $context) {
if (isset($element['#field_name'])) {
switch ($element['#field_name']) {
case 'field_long_test':
$element['#nodrag'] = TRUE;
@ao5357
ao5357 / local_env.php
Created February 8, 2019 15:32
A 5 Step Guide To Easier File and Database Syncing with Drush
<?php
$aliases['dev'] = array(
'uri' => 'local.dev',
'root' => '/path/to/site',
'path-aliases' => array(
'%files' => 'sites/default/files',
),
);
@ao5357
ao5357 / MYMODULE_entity_info_alter.php
Created February 8, 2019 16:11
Lean Drupal with content view modes and Views
<?php
/**
* Implements hook_entity_info_alter().
*/
function MYMODULE_entity_info_alter(&$entity_info) {
// Nodes.
$entity_info['node']['view modes']['grid'] = array(
'label' => t('Grid'),
'custom settings' => TRUE,