Skip to content

Instantly share code, notes, and snippets.

View Jaesin's full-sized avatar

Jaesin Mulenex Jaesin

View GitHub Profile
@Jaesin
Jaesin / drupal.perm.admin.checkbox.js
Last active August 29, 2015 14:11
Add Select All on the drupal permissions page.
(function ($) {
var columns = $("#permissions tr.even").first().find("input.form-checkbox").length;
var heads = $("#permissions thead th");
for (var i=1; i<columns+1; i++) {
var cbToggler = $("<input type=checkbox>").data('column', i);
cbToggler.click(function(e) {
var checked = this.checked;
var allCheckboxes = $("#permissions tbody input.form-checkbox");
for (var n=$(this).data('column')-1; n<allCheckboxes.length; n+=columns) {
@Jaesin
Jaesin / drush-it-up.sh
Last active December 31, 2015 00:44
Install drushes
#!/bin/bash
# See: https://packagist.org/packages/drush/drush
# Drush 7 (Global)
composer global require "drush/drush:7.*"
# Drush 6 (Local)
mkdir -p /usr/local/share/drush/6.x
cd /usr/local/share/drush/6.x
composer require "drush/drush:6.*"
@Jaesin
Jaesin / node_export.php
Last active August 29, 2015 14:06
Export some nodes to be imported via a hook_update_N. (Drupal)
<?php
// From: http://steindom.com/articles/how-export-and-import-drupal-nodes
// Enter node NIDs to export.
$nids = array(
1991, // path/to/node/1991
2061, // path/to/node/2061
2016, // path/to/node/2016
2021, // path/to/node/2021
2026, // path/to/node/2026
2031, // path/to/node/2031
@Jaesin
Jaesin / vagrant_ssh-agent
Last active August 29, 2015 14:01
Allow ssh forwarding in Vagrant during provisioning.
# Enable agent forwarding during provisioning.
config.vm.provision :shell do |shell|
shell.inline = "touch $1 && chmod 0440 $1 && echo $2 > $1"
shell.args = %q{/etc/sudoers.d/root_ssh_agent "Defaults env_keep += \"SSH_AUTH_SOCK\""}
end
@Jaesin
Jaesin / load_and_cache_view
Created April 7, 2014 23:11
Load, cache and use fields in drupal views 7.x-3.x
// Get the view that grabs the data for this tableselect.
$view = views_get_view('view_name');
$view->init();
$view->set_display('default');
$view->set_items_per_page(0);
$view->set_arguments(array('123+1234')); // mass multiple node id's
$view->pre_execute();
$view->execute();
// Render and cache the fields for later use at $view->style_plugin->rendered_fields[$index][$field_name].