Skip to content

Instantly share code, notes, and snippets.

View sumanthkumarc's full-sized avatar

Sumanth Reddy sumanthkumarc

View GitHub Profile
#Put Following Lines in httpd.conf
#Checks if mod_env is loaded and then sets a unconditional Environment variable called "X_Environment"
# Use SetEnvIF for conditional var setting, requires mod_setenvif.c to be loaded
<IfModule mod_env.c>
SetEnv X_Environment Local
</IfModule>
#Checks if mod_headers is loaded and then sets a Response Header called MyHeader with value of environment varuable "X_Environment" set above
# Use http://httpd.apache.org/docs/current/mod/mod_headers.html link for reference

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@sumanthkumarc
sumanthkumarc / filename_sanitizer.php
Created July 12, 2016 08:10
PHP function to sanitize the file name to be url safe
/*
* Function to sanitize the file name for url and file name safe.
*
* @param string $filename
* The unsafe filename is taken as input
*
* @return string
* The safe file name is returned.
*/
function filename_sanitizer($unsafeFilename){
@sumanthkumarc
sumanthkumarc / omniture_tracking_functions.js
Created July 12, 2016 08:16
Omniture functions for custom tracking
function trackLink(obj, name) {
var s=s_gi(s_account);
s.linkTrackVars='prop40';
s.prop40 = "Custom tracking text";
s.tl(obj,'o',s.prop40);
s.prop40 = "";
s.linkTrackVars='None';
s.linkTrackEvents='None';
@sumanthkumarc
sumanthkumarc / useful_linux_commands.txt
Last active September 15, 2016 06:10
Some linux commands
# For starting xdman
java -jar xdman.jar
#for editing hosts file
sudo gedit /etc/hosts
#For wget
wget http://file_url
#For resuming the previously interupted file download
wget -c http://file_url
@sumanthkumarc
sumanthkumarc / ajax_before_submit.txt
Last active August 11, 2016 10:53
Drupal - Control ajax call on submit button by returning true or false in beforesubmit function
// Get all the elements in the DOM with ajax enabled
for (var ajax_element in Drupal.ajax) {
if (typeof Drupal.ajax[ajax_element] !== 'undefined') {
// Drupal.ajax[ajax_elements].ajaxing = false;
// Get the actual jquery object for the submit button
var $ajax_el_obj = jQuery(Drupal.ajax[ajax_element].element);
// Check if it's reqd. button and then call beforesubmit for that
@sumanthkumarc
sumanthkumarc / drush_commands.txt
Created August 11, 2016 10:52
Some Drush commands Drupal
============================================
Using drush to get a list of enabled modules
============================================
If you just wanted to make a list of all the modules which are installed in your instance. Don't waste time, be smart write a command using drush. - See more at: http://drupaltonight.com/drupal-articles/using-drush-get-list-enabled-modules#sthash.b10DQqN5.dpuf
List all modules and themes :
drush pm-list
List only modules :
@sumanthkumarc
sumanthkumarc / resetting a mysql root pass
Last active August 18, 2016 08:17
resetting a mysql root pass(Assuming Ubuntu and new mysql version)
# Stop running myslq server
sudo /etc/init.d/mysql stop
#Restart mysql server in safe mode with no grant table(no security)
sudo mysqld_safe --skip-grant-tables &
#Login to muysql as root
mysql -uroot
#Change to mysql database
@sumanthkumarc
sumanthkumarc / simple configuration api usage D8
Last active August 19, 2016 05:53
simple configuration api usage Druapl 8(D8)
# Taken from :https://www.drupal.org/developing/api/8/configuration/simple
//Immutable Config (Read Only)
$config = \Drupal::config('system.performance');
//Mutable Config (Read / Write)
$config = \Drupal::service('config.factory')->getEditable('system.performance');
// To read contents
$message = \Drupal::config('system.maintenance')->get('message'); //gets only particular key value, or array if data in next levels
@sumanthkumarc
sumanthkumarc / gist:a5e3c8d84e742db9969e35dd25a459f1
Created August 22, 2016 11:51 — forked from wardbekker/gist:964146
Naive parallel import of Compressed MYSQL dump file
# Split MYSQL dump file
zcat dump.sql.gz | awk '/DROP TABLE IF EXISTS/{n++}{print >"out" n ".sql" }'
# Parallel import using GNU Parallel http://www.gnu.org/software/parallel/
ls -rS *.sql | parallel --joblog joblog.txt mysql -uXXX -pYYY db_name "<"