Skip to content

Instantly share code, notes, and snippets.

//Undo Commit:
svn merge -r COMMITTED:PREV .
//Revert Merge
svn revert -R .
//Revert to older revision:
svn update -r <earlier_revision_number>
@arispublic
arispublic / drush-rebuild-perms.sh
Last active August 29, 2015 14:17
Drupal: Rebuild permissions on all sites
drush @sites php-eval 'node_access_rebuild();' -y
@arispublic
arispublic / svn-revert-commit-to-prev-version.sh
Last active August 29, 2015 14:17
In Subversion, sometimes our commit is not valid/broken. We want to revert the code to previous revision. Here are the steps.
//test mode
svn merge --dry-run -r:73:68 http://my.repository.com/my/project/trunk
//merge to previous
svn merge -r:73:68 http://my.repository.com/my/project/trunk
//commit the changes.
svn commit -m "Reverted to revision 68."
@arispublic
arispublic / webscrapping.php
Last active June 4, 2018 03:47
Easy web scrapping using phpQuery (https://code.google.com/p/phpquery/)
<?php
//load phpquery library here.
require('phpQuery/phpQuery.php');
//sample URL
$url = 'http://www.b*ngg**d.com/Wholesale-Mobile-Phones-c-140.html';
// load the url using curl
$ch = curl_init();
@arispublic
arispublic / preprocess_field.php
Last active August 29, 2015 14:21
Drupal 7: Preprocess custom fields before render it
<?php
/**
* Hide first name & last name from user account (additional fields), on render it.
* @param type $vars
*/
function mymodule_preprocess_field(&$vars) {
if (in_array($vars['element']['#field_name'], array('field_first_name', 'field_last_name'))) {
$vars['items'] = array(); //remove the value
$vars['label_hidden'] = true; //hide the label
@arispublic
arispublic / truncate-tables.sh
Created June 19, 2015 05:43
Truncate all tables in a MySQL database when you don't have permission to drop and create database.
mysqldump -h[DB-HOST] -u[DB-USER] -p[DB-PASS] --add-drop-table --no-data [DB-NAME] | grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -h[DB-HOST] -u[DB-USER] -p[DB-PASS] [DB-NAME]
@arispublic
arispublic / vpsbench.sh
Created August 4, 2015 15:45
Benchmark your VPS
wget freevps.us/downloads/bench.sh -O - -o /dev/null|bash
@arispublic
arispublic / mergefile.bat
Created September 11, 2015 08:42
How to merge files into a file in windows? Please see command below
copy /b *.txt newfile.txt
@arispublic
arispublic / drush.sh
Created February 18, 2016 20:31
Drush Feature Export with additional fields and also increment the version
drush fe -y f_registration_views views_view:content_list --version-increment
@arispublic
arispublic / update-feature.sh
Created February 18, 2016 20:36
Steps to update feature in drupal
#1. recreate the feature_module with additional fields/views/menu. Don't forget to increase the version number
#2. Download the feature_module
#3. Replace the feature_module with the new one.
#4. Update the feature_module
drush fu feature_module
#5. Update module the feature_module
drush updb -y
#6. done.