Skip to content

Instantly share code, notes, and snippets.

View vkareh's full-sized avatar

Victor Kareh vkareh

View GitHub Profile
@vkareh
vkareh / gist:3406759
Created August 20, 2012 19:04
module_invoke_last()
function module_invoke_last($hook) {
$args = func_get_args();
// Remove $hook from the arguments.
unset($args[0]);
$result = null;
foreach (module_implements($hook) as $module) {
$function = $module . '_' . $hook;
if (function_exists($function)) {
$result = call_user_func_array($function, $args);
}
@vkareh
vkareh / mcard_handler_field_node_radioactivity.inc
Created November 27, 2012 19:34 — forked from kevinchampion/mcard_handler_field_node_radioactivity.inc
Simple views field handler for radioactivity.
/**
* Field handler to provide simple renderer that calls function to record
* radioactivity of the node being viewed.
*/
class mcard_handler_field_node_radioactivity extends views_handler_field_node {
function render($values) {
if (module_exists('radioactivity')) {
radioactivity_node_user_node_view($values->nid);
}
return $this->render_link(check_plain($values->{$this->field_alias}), $values);
diff --git a/servers/Route.bones.js b/servers/Route.bones.js
index b78dc77..67fc8b5 100644
--- a/servers/Route.bones.js
+++ b/servers/Route.bones.js
@@ -95,7 +95,7 @@ server.prototype.loadCollection = function(req, res, next) {
req.collection = new this.models[name]([], req.query);
var options = {
success: function(collection, resp) {
- res.send(resp, headers);
+ res.send(resp, _.extend(_.result(model, 'headers') || {}, headers));
<?php
/**
* Implements hook_form_FORM_ID_alter() for views_exposed_form.
*/
function MODULE_form_views_exposed_form_alter(&$form, &$form_state) {
$form['#after_build'] = array('_MODULE_apply_js');
}
function _MODULE_apply_js($form, &$form_state) {
function MODULE_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'views_exposed_filters') {
$form['field_date_value_year']['#attributes']['autocomplete'] = 'off';
$form['field_date_value_month']['#attributes']['autocomplete'] = 'off';
}
}
/**
* Hook to register the CKEditor plugin - it would appear in the plugins list on the profile setting page.
*/
function hook_ckeditor_plugin() {
return array(
'plugin_name' => array(
// Name of the plugin used to write it.
'name' => 'plugin_name',
// Description of the plugin - it would be displayed in the plugins management section of profile settings.
'desc' => t('Plugin description'),
@vkareh
vkareh / console.js
Last active December 18, 2015 05:09
console.log() of object snapshots... needs jQuery
var consoleLog = console.log;
console.log = function() {
consoleLog.apply(this, $.map(arguments, function(obj) {
return $.isPlainObject(obj) ? $.extend(true, {}, obj) : obj;
}));
}
@vkareh
vkareh / passport-drupal-middleware.js
Last active December 19, 2015 07:28
passport-drupal express middleware
var passport = require('passport')
, express = require('express')
, app = express();
// Passport session setup.
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(user, done) {
done(null, user);
if (!('indexOf' in Array.prototype)) {
Array.prototype.indexOf= function(find, i) {
if (i===undefined) i= 0;
if (i<0) i+= this.length;
if (i<0) i= 0;
for (var n= this.length; i<n; i++)
if (i in this && this[i]===find)
return i;
return -1;
};
--langdef=Css
--langmap=Css:.css
--langmap=Css:+.less
--langmap=Css:+.scss
--regex-Css=/^[ \t]*(.+)[ \t]*\{/\1/f,functions/
--regex-Css=/^[ \t]*(.+)[ \t]*,[ \t]*$/\1/f,functions/
--regex-Css=/^[ \t]*([#.]*[a-zA-Z_0-9]+)[ \t]*$/\1/f,functions/
--langdef=Html
--langmap=Html:.html