Skip to content

Instantly share code, notes, and snippets.

View msankhala's full-sized avatar
🎯
Focusing

Mahesh Sankhala msankhala

🎯
Focusing
View GitHub Profile
@msankhala
msankhala / drupal-7--fapi_multifield.php
Created November 23, 2016 12:46 — forked from yann-yinn/drupal-7--fapi_multifield.php
Creat multiple field (add more buttons) for form api elements
<?php
/**
* @file
* Re-usable stuff.
*
* @FIXME multifield function seems not to work in included several times in the same page.
*/
/**
* Implements hook_theme()
@msankhala
msankhala / what-forces-layout.md
Created November 18, 2016 10:51 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@msankhala
msankhala / default.conf
Created October 26, 2016 10:48 — forked from cbmd/default.conf
nginx config - dynamic virtual hosts
server {
index index.php;
set $basepath "/var/www";
set $domain $host;
# check one name domain for simple application
if ($domain ~ "^(.[^.]*)\.dev$") {
set $domain $1;
set $rootpath "${domain}";
@msankhala
msankhala / drush-turn-off-aggregate-assets.txt
Last active January 2, 2023 08:18 — forked from chrisl8888/drush-turn-off-aggregate-assets.txt
drush disable js/css aggregation
Drupal 7
// To turn on JS Aggregation
drush vset preprocess_js 1 --yes
// To clear all Cache
drush cc all
// To disable JS Aggregation
drush vset preprocess_js 0 --yes
@msankhala
msankhala / gist:93a4328f1229756cd3598b453e65a530
Created July 27, 2016 07:35 — forked from cecilemuller/gist:1973201
Programmatically change the active theme in Drupal 7
<?php
/**
* Defines a theme callback function per registered path.
*/
function MODULENAME_menu_alter(&$items) {
$items['node/%node']['theme callback'] = 'MODULENAME_default_node_theme';
$items['node/%node/edit']['theme callback'] = 'MODULENAME_edit_node_theme';
$items['node/%node/edit']['theme arguments'] = array(1);
}
@msankhala
msankhala / .inputrc
Created January 30, 2016 10:50 — forked from gregorynicholas/.inputrc
OSX .inputrc to make terminal way better. and by better i mean i'm naked
"\e[1~": beginning-of-line
"\e[4~": end-of-line
“\e[5~”: history-search-backward
“\e[6~”: history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
@msankhala
msankhala / gist:b4acbde558e4f679d8ca
Created December 14, 2015 18:44 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@msankhala
msankhala / ansi-color.php
Created December 1, 2015 07:15 — forked from superbrothers/ansi-color.php
ANSI color terminal output module for php
<?php
/**
* php-ansi-color
*
* Original
* https://github.com/loopj/commonjs-ansi-color
*
* @code
* <?php
* require_once "ansi-color.php";
@msankhala
msankhala / gist:a5a592eacf92b5344299
Created October 22, 2015 06:55 — forked from Steven-Rose/gist:3943830
VI: Select all + delete, select all + copy
Select all and delete (actually move to buffer)
:%d
Select all and copy to buffer
:%y
Use p to paste the buffer.
<?php
function themename_menu_link(&$variables) {
$element = $variables['element'];
$sub_menu = '';
$element['#attributes']['data-menu-parent'] = $element['#original_link']['menu_name'] . '-' . $element['#original_link']['depth'];
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}