Skip to content

Instantly share code, notes, and snippets.

View msankhala's full-sized avatar
🎯
Focusing

mahesh sankhala msankhala

🎯
Focusing
View GitHub Profile
SELECT 'ColName1', 'ColName2', 'ColName3'
UNION ALL
SELECT ColName1, ColName2, ColName3
FROM YourTable
INTO OUTFILE '/path/outfile'
<?php
global $user;
$original_user = $user;
$old_state = drupal_save_session();
drupal_save_session(FALSE);
$user = user_load(1);
// Take your action here where you pretend to be the user with UID = 1 (typically the admin user on a site)
// If your code fails, it's not a problem because the session will not be saved
$user = $original_user;
drupal_save_session($old_state);
  • Exception
    • ErrorException
    • LogicException
      • BadFunctionCallException
        • BadMethodCallException
      • DomainException
      • InvalidArgumentException
      • LengthException
      • OutOfRangeException
  • RuntimeException
@msankhala
msankhala / cancel_ajax_js
Created June 25, 2015 10:16
Cancel all ajax request in progress
<input type="button" id="cancelBtn" value="Cancel All AJAX" />
$.xhrPool.abortAll = function() {
$(this).each(function(idx, jqXHR) {
jqXHR.abort();
});
$.xhrPool = [];
};
@msankhala
msankhala / ampersand-before-php-function-names.php
Last active June 13, 2022 14:15
Understanding Ampersand Before PHP Function Names – Returning By Reference
<?php
// You may have wondered how a PHP function defined as below behaves:
function &config_byref()
{
static $var = "hello";
return $var;
}
// the value we get is "hello"
$byref_initial = config_byref();
@msankhala
msankhala / laravel-multiple-env-setup.php
Last active February 29, 2024 04:53
Setup Multiple Environment for Laravel 5 Developers Way
<?php
/*
|--------------------------------------------------------------------------
| Follow this instructions:
|--------------------------------------------------------------------------
|
| Laravel takes a dead simple approach to your application environments
| so you can just specify a machine name for the host that matches a
| given environment, then we will automatically detect it for you.
<?php
function YOURTHEME_preprocess_PANEL_LAYOUT(&$variables) {
$variables['messages'] = theme('status_messages');
}
@msankhala
msankhala / preprocess-panels-pane.php
Created September 9, 2015 10:24
How to figure out the appropriate name for your panels content pane template https://www.drupal.org/node/1678810
<?php
function YOURTHEME_preprocess_panels_pane(&$variables) {
// dpm('type: ' . $variables['pane']->type);
if ($variables['pane']->type == 'block') {
dpm('subtype: ' . $variables['pane']->subtype);
}
}
?>
@msankhala
msankhala / alter-feild-cardinality.php
Created September 10, 2015 14:04
Alter field cardinality to one.
<?php
// Just alter the cardinality selection with this hook and provide only one value
function _form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
if ($form['#field']['type'] == '<your field type>') {
$form['field']['cardinality']['#options'] = array(1);
}
}
@msankhala
msankhala / drush-clear-cache-php-eval.php
Created September 11, 2015 15:13
drush-cache-clear-php-eval.php
drush php-eval 'cache_clear_all("*", "cache", TRUE);'`​