Skip to content

Instantly share code, notes, and snippets.

View cmcintosh's full-sized avatar
💭
Looking For Projects

Chris McIntosh cmcintosh

💭
Looking For Projects
View GitHub Profile
$view = new view();
$view->name = 'testing';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'search_api_index_author_expert_index';
$view->human_name = 'testing';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
<?php
try {
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Load Up Magento Core
define('MAGENTO', realpath('/path/to/magento'));
require_once(MAGENTO . '/app/Mage.php');
@cmcintosh
cmcintosh / gist:e695370870dba552e21b
Created December 15, 2015 08:49
Hook_gateway_info
/**
* Implement hook_gateway_info
*/
function sms_fowiz_gateway_info() {
return array(
'sms_fowiz' => array(
'name' => 'FOWiz Gateway',
'send' => 'sms_fowiz_send',
'recieve' => TRUE,
'configure form' => 'sms_fowiz_settings',
#
# This Replaces the old Drupal 7's module .info
#
name: Todo: Make Drupal 8 Fun
type: module # Either module or theme
description: Creates our custom TODO module
core: 8.x
package: TODO
configure: entity.todo.settings # This replaces the old admin path from Drupal 7
tags: # Tags can be used as a categorization method for your modules.
public function handleAutocomplete(Request $request, $target_type, $selection_handler, $selection_settings_key) {
$matches = array();
// Get the typed string from the URL, if it exists.
if ($input = $request->query->get('q')) {
$typed_string = Tags::explode($input);
$typed_string = Unicode::strtolower(array_pop($typed_string));
// Selection settings are passed in as a hashed key of a serialized array
// stored in the key/value store.
$selection_settings = $this->keyValue->get($selection_settings_key, FALSE);
@cmcintosh
cmcintosh / validateEmailAjax
Created May 20, 2016 08:43
buildForm Example
$form['username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#ajax' => [
'callback' => '::validateEmailAjax',
'event' => 'change',
],
'#suffix' => '<span class="username-available"></span>'
);
@cmcintosh
cmcintosh / gist:93b156eccd73f68364f063bcd2d5165c
Created May 20, 2016 09:00
Custom AJAX Command for events
(function($, Drupal) {
/**
* Add new command for reading a event.
*/
Drupal.AjaxCommands.prototype.getEvents = function(ajax, response, status){
// Place content in current-msg div.
$('#event-msg h2').html(response.subject);
$('#event-msg p').html(response.content);
// Remove from unread list.
$('#event-' + response.mid).remove();
@cmcintosh
cmcintosh / CustomFieldsetDemo.php
Created July 6, 2016 01:31
Customize Fieldsets in Drupal 8
<?php
/**
* {@inheritdoc}
*/
public function buildForm ($form, $formState) {
// First define our fieldset, and add a #theme tag to our element.
// See http://www.drupalcontrib.org/api/drupal/drupal!core!includes!form.inc/function/theme_fieldset/8
// for the default implementation.
@cmcintosh
cmcintosh / Achievement Interface
Created April 28, 2017 16:00
Achievement System for Unity
interface Achievement {
int id; // Public id of this perticular achievement. used to load text.
string label; // This will be loaded and populated from the json file.
bool displayed; // Has been displayed to the user.
bool unlocked; // Has been unlocked by the user.
List<AchievementCondition> conditions[]; // A list of conditions that are required to unlock the Achievement.
void checkAcievementState();
}