Skip to content

Instantly share code, notes, and snippets.

@iampuma
iampuma / create-db-user.mysql
Created September 1, 2015 13:57
create db and user
create database dev;create user dev;grant all on dev.* to 'dev'@'localhost' identified by 'dev';
@iampuma
iampuma / git-color.txt
Created August 31, 2015 13:29
git color
git config --global color.ui auto
@iampuma
iampuma / drush-dir-loop.txt
Created August 31, 2015 10:22
drupal dir drush loop
#!/bin/bash
# Get all Drupal sites
sites=`find . -maxdepth 1 -type d -print | grep -v '/all$' | grep -v '/default$' | grep -v '\.$'`
echo $sites
echo "Choose the commande to execute : "
echo "1. update"
echo "2. put sites offline"
@iampuma
iampuma / php-5.5-array-map-alternative-array-column.txt
Created August 19, 2015 14:13
array_map alternative for array_column PHP 5.5
// PHP >= 5.5 - Get all term ids.
if ($term_field = $entity->field_term[LANGUAGE_NONE]) {
$term_tids = array_column($entity->field_term[LANGUAGE_NONE], 'first_name');
}
// PHP < 5.5 - Get all term ids.
if ($term_field = $entity->field_term[LANGUAGE_NONE]) {
$term_tids = array_map(function($term) { return $term['tid']; }, $term_field);
}
jQuery('select[multiple]').hover(function() { jQuery(this).css('height', '500px'); }, function() { jQuery(this).css('height', '80px'); } );
#!/usr/bin/env drush
<?php
#
# This script removes all drupal users with uid > 1 (e.g., skips
# admin user) and reassigns their content to anonymous.
#
// check if we can bootstrap
$self = drush_sitealias_get_record('@self');
if (empty($self)) {
drush_die("I can't bootstrap from the current location.", 0);
@iampuma
iampuma / jquery.css
Created June 27, 2013 21:59
JS: jquery.min 2013/06/27
/*! jQuery v1.10.1 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery.min.map
*/
(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.1",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",