Skip to content

Instantly share code, notes, and snippets.

View micahredding's full-sized avatar

Micah Redding micahredding

View GitHub Profile
@micahredding
micahredding / snippet.php
Created December 11, 2013 20:50
EntityFieldQuery
$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'client')
->propertyCondition('status', 1)
->fieldCondition('field_client_user', 'value', $user->uid, 'EQUALS')
->execute();
@micahredding
micahredding / Gruntfile.js
Last active December 31, 2015 01:29
Gruntfile, with package.json. Handles sass, coffeescript, and image optimization. You should probably add .sass-cache and node_modules to .gitignore.
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
sass: {
files: ['assets/scss/**/*.{scss,sass}','assets/scss/_partials/**/*.{scss,sass}'],
tasks: ['sass:dist']
},
coffee: {
files: ['assets/coffee/*.coffee'],
@micahredding
micahredding / script.coffee
Created December 11, 2013 11:47
Coffeescript that didn't work for some reason, with the Javascript that did
# namespace jQuery
(($) ->
# Document.ready
$ ->
switchColorbox = () ->
if $(window).width() < 1000
$.colorbox.remove()
else
@micahredding
micahredding / gist:7795335
Created December 4, 2013 20:54
Block examples
# New Code, which includes configure and variable set
function psod_settings_block_info() {
$blocks = array();
$blocks['trainers'] = array(
'info' => 'Trainers',
'cache' => DRUPAL_NO_CACHE,
);
$blocks['employees'] = array(
'info' => 'Employees',
'cache' => DRUPAL_NO_CACHE,
@micahredding
micahredding / template.php
Last active December 30, 2015 00:49
A simple hook_form_alter
function urgentteam_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'views_exposed_form' && $form['#id'] == 'REPLACE THIS') {
dpm($form);
}
}
@micahredding
micahredding / test.go
Created December 1, 2013 17:08
Go Function to Return MacOS X created time (birthtime)
package main
import (
"fmt"
"log"
"os"
"syscall"
"time"
)
@micahredding
micahredding / gist:7533931
Created November 18, 2013 19:34
Add a page content type template suggestion
if (isset($vars['node'])) {
$vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
<?php
function states_submit($form, &$form_state) {
$i = 0;
while(isset($form_state['values']['states_' . $i])) {
variable_set('state_' . $i, $form_state['values']['states_' . $i]);
$i++;
}
}
# IF THE BROWSER IS INTERNET EXPLORER 10
ieten = (navigator.appVersion.indexOf("MSIE 10") != -1)
if(ieten)
$('html').addClass('ie10')
Starting Drupal installation. This takes a few seconds ... [ok]
WD php: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'developer' for key 'name': INSERT INTO {role} (name, weight) VALUES [error]
(:db_insert_placeholder_0, :db_insert_placeholder_1); Array
(
[:db_insert_placeholder_0] => developer
[:db_insert_placeholder_1] => 2
)
in drupal_write_record() (line 7166 of /Users/micah/Sites/SITENAME/includes/common.inc).
WD php: Warning: Cannot modify header information - headers already sent by (output started at /usr/local/Cellar/drush/5.9/libexec/includes/output.inc:37) in drupal_send_headers() [warning]
(line 1216 of /Users/micah/Sites/SITENAME/includes/bootstrap.inc).