Skip to content

Instantly share code, notes, and snippets.

View nkgokul's full-sized avatar

Gokul N K nkgokul

View GitHub Profile
@nkgokul
nkgokul / replace_all_occurances_of_a_word_in_a_folder
Created February 27, 2015 09:40
Replace all occurances of a word in a folder
find foldername -type f | xargs sed -i 's/old_string/new_string/g'
@nkgokul
nkgokul / import_mails_from_a_particular_label.js
Created March 18, 2015 20:36
Import Mails that have particular label
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@nkgokul
nkgokul / get_field_types.js
Last active August 29, 2015 14:17
Getting Field types and its keys from content creation page in Drupal 8
var options = '';
jQuery('.form-item-new-storage-type select option').each(function(){
options = options + (jQuery(this).text() + '<<' + jQuery(this).val() + '\n');
});
console.log(options);
/**
* Copy paste the output from console.log to Google Spreadsheet
* You can use =SPLIT(A1,"<<"); function to split the key value pairs.
* /
@nkgokul
nkgokul / comment_view.php
Created May 30, 2015 10:43
Comment View Export
$view = new view();
$view->name = 'testcomments';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'comment';
$view->human_name = 'Test Comments';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@nkgokul
nkgokul / drupal8installation
Last active April 16, 2016 06:16
Drupal 8 Installation file permissions
mkdir sites/default/files
chmod a+w sites/default/files
cp sites/default/default.settings.php sites/default/settings.php
cp sites/default/default.services.yml sites/default/services.yml
cp example.gitignore .gitignore
chmod a+w sites/default/settings.php
chmod a+w sites/default/services.yml
@nkgokul
nkgokul / for_all_content_types_in_drupal.sh
Created August 5, 2015 11:30
For all content types in drupal
#!/bin/bash
drush sqlq "select type from node_type" | while read content_type;
do
echo "Changing comment settings for $content_type"
drush vset comment_default_mode_$content_type 0
drush vset comment_default_per_page_$content_type 50
drush vset comment_$content_type 2
drush vset comment_form_location_$content_type 1
drush vset comment_preview_$content_type 0
drush vset comment_subject_field_$content_type 0
@nkgokul
nkgokul / Fixing Git issues
Last active June 23, 2016 11:27
Fixing Git issues
#Goto the root of git repo
cd .git
sudo chgrp -R users .
sudo chmod -R g+rwX .
sudo find . -type d -exec chmod g+s '{}' +
git config core.sharedRepository group
@nkgokul
nkgokul / missing_node_ids.sql
Created June 28, 2016 11:04
Missing nids from node table
SELECT (t1.nid + 1) as gap_starts_at,
(SELECT MIN(t3.nid) -1 FROM node t3 WHERE t3.nid > t1.nid) as gap_ends_at
FROM node t1
WHERE NOT EXISTS (SELECT t2.nid FROM node t2 WHERE t2.nid = t1.nid + 1)
HAVING gap_ends_at IS NOT NULL
@nkgokul
nkgokul / Git Force Clearn
Last active July 25, 2016 13:10
Git Force Clean local and pull from server
sudo git clean -df && sudo git stash && git status
drush en --y admin_menu admin_views ckeditor context entityreference features module_filter reldate strongarm pathauto globalredirect chosen devel eazylaunch date admin_menu_toolbar
drush ckeditor-download
drush chosenplugin
drush dis toolbar
drush cc all