Drupal remove deleted fields from database

Install and enable Field SQL norevisions, and use it to delete any revisions you don't need. Also set it to disable revisions for content/entity types that you don't want revisions being made.

Note: For entity content types, drupal will automatically make revisions for each update, but won't allow you to revert to any of these revisions, so this is pretty pointless; plus for very large databases this can degrade performance.

Tags: Drupal drush

How to mass delete ALL twitter users you are following via Google Chrome

Step 1.

In Google Chrome, go to https://twitter.com/following

Step 2.

For PC hit Ctrl + Shift + J 
For Mac hit Cmd + Opt + J

Step 3.

Paste this code into the chrome console, hit enter, and wait for it to finish:

setInterval(
function()
{
	t=$(".Grid .Grid--withGutter").find(".user-actions-follow-button");
	for(i=0;true;i++)
	{
		if(i>=t.length)
		    {
			window.scrollTo(0,$(document).height());
			return
			}
			$(t[i]).trigger("click").remove()
	}
}
,2000
)
Tags: twitter

How to diagnose slow mysql performance

If you're experiencing slow mysql performance--top showing mysqld high cpu usage. This command will help you track down what's going on at that specific time.

mysql -e "show processlist"

Of course you should also check your log files:

/var/lib/mysql/mysql-slow.log
/var/lib/mysql/mysql-error.log

You'll also want to optimize your /etc/my.cnf: For a pretty good quick start, you can use this tool, Percona Configuration Wizard for MySQL

Tags: mysql Server Linux

How to convert database from innodb to InnoDB in phpMyAdmin?

In phpMyAdmin, click the "SQL" tab and paste the following in there--changing your_database to the actual database you want to change.

SET @DATABASE_NAME = 'your_database';

SELECT  CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM    information_schema.tables AS tb
WHERE   table_schema = @DATABASE_NAME
AND     `ENGINE` = 'innodb'
AND     `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;

Or if that doesn't work, do the following under SSH (change your_database to your actual database name)

Tags: mysql Server admin

How to install drush on Godaddy cPanel hosting

If you're using godaddy cpanel hosting, you have 2 options of installing drush

1. drush version from drupal (which is NOT being updated anymore--unlike the latest github version).

or 2. (Preferred) Install the latest github version:

Go here to view instructions on how to install the latest version of drush from github.

cd ~
wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz
tar xvf drush-7.x-5.9.tar.gz 

Now we add the drush paths to our .bash_profile.

vi .bash_profile 

Paste the following in toward the top:

Tags: cpanel godaddy drush Linux

How to add free shipping notice on product listing and product view in Magento

NOTE: This tutorial assumes you're using an extension that uses the "special_shipping_group" attribute... But you can also use this tutorial to output any attribute you'd like into the product view and product listing.

Ok... Say you're using the "special_shipping_group" attribute, to specify which products should receive free shipping.

You would, for example, add an attribute called: FREE SHIPPING

Make sure you also set this visible under product listing, and product view, or else it won't display.

Following, you will assign this attribute to all the products that are to use this "FREE SHIPPING" attribute.

Now...

Tags: Design magento attributes shipping free shipping display

How to install BFD (Brute Force Detection)

Source

What is BFD (Brute Force Detection)?
BFD is a modular shell script for parsing applicable logs and checking for authentication failures. There is not much complexity or detail to BFD yet and likewise it is very straight-forward in its installation, configuration and usage. The reason behind BFD is very simple; the fact there is little to no authentication and brute force auditing programs in the linux community that work in conjunction with a firewall or real-time facility to place bans. BFD is available at: http://www.rfxnetworks.com/bfd.php

This guide will show you how to install and configure BFD to protect your system from brute force hack attempts.

Requirements:
- You MUST have APF Firewall Installed before installing BFD - it works with APF and requires some APF files to operate.
- Root SSH access to your server

Tags: Linux

How to install and use Malware Linux Detect (Maldet)

How to install Maldet

cd /usr/local/src/
wget http://www.rfxn.com/downloads/maldetect-current.tar.gz
tar -xzf maldetect-current.tar.gz
cd maldetect-*
sh ./install.sh or sudo sh ./install.sh 

Now enable email_alert and add your email address to email_addr /usr/local/maldetect/conf.maldet

vi /usr/local/maldetect/conf.maldet 
#change to the following:
email_alert=1
email_addr="[email protected]"

How to update maldet

maldet --update-ver
maldet --update

How to manually scan with maldet:

maldet -a /home

Or:

maldet /home?/?/domains/?/public_html

Or in background:

Tags: maldet Linux malware

Drupal Drealty How to fix Active Properties Set to 'active=0'

Sometimes drealty doesn't properly set RETS status properties marked as "Active", "Pending Sale", or "Backup Offer" as 'active=1'. Any property marked as 'active=0' will NOT display, no matter what 'rets_status' is marked as.

We can fix that by running this SQL query in phpMyAdmin:

UPDATE `drealty_listing` SET `active`='1'
WHERE `rets_status`='Active' or `rets_status`='Pending Sale' or `rets_status`='Backup Offer' ;
Tags: Drupal drealty

Magento Mega Menu: Responsive Custom Menu MOD

Magento Mega Menu : Responsive Custom Menu MOD

Here is a modded Responsive Custom Menu I just did, adding named menu classes and positioning the custom block element above the menu items.

Why?

Original menu didn't have any unique class identifiers for menu items--it was partially unique, but nothing you can actually use to style any individual menu item.  Also I thought it made sense to have the custom block ABOVE the menu listing. After all, any custom element you want to show is likely going to be more important than the regular menu listing.

If you're interested in this, then simply download the attached Navigation.php or copy/paste over the following app/code/commmunity/WP/CustomMenu/Block/Navigation.php:

How to install PECL runkit

Here's a proper way of installing PECL runkit on centos.

cd /usr/local/src/
git clone https://github.com/zenovich/runkit.git
cd runkit
phpize
./configure
make
make install

Now edit your php.ini

vi /usr/local/lib/php.ini

Add the following under your extension= listings.

; PECL runkit
extension=sorunkit.so  

Now restart Apache.

service httpd restart

That's it.

Increase Limit of Drupal Views Exposed Group Filters sort order

My original post: Exposed filters group: increase weight sort count (#delta)

This still hasn't been fixed at the time of this writing. So here we go...

Sort breaks, and does unpredictable sorting, if you use more than 20 options. E.g. say you have have an exposed grouped filter with a price drop down of more than 20 options, sorting will not work after 20 items, it will always spit out a different order than what you specify.

The fix

Edit the following Views module file:

sites/all/modules/views/handlers/views_handler_filter.inc

Look for this:

'#delta' => 10

Replace with this:

'#delta' => 60
Tags: Drupal Views module

Speed up and secure Apache SSL encryption.

By default apache loads a bunch of encryption protocols. Most of which either are insecure and/or slow.

The location of these settings are based on DirectAdmin's Apache 2.4.x, however, you should easily be able to locate them in your apache .conf files.

vi /etc/httpd/conf/extra/httpd-ssl.conf

Set Apache to only use the fastest and best encryption algorithms.

Now comment out the default SSL settings and add new ones as shown below:

Tags: apache SSL security performance

How to install a new drive in Linux larger than 2TB with proper alignment

Let's assume that we already have a primary physical drive in our system (HDD or SDD), and have added a second drive to our box, which we need to partition and mount automatically on boot.

Here's how to that:

Let's see what physical drives we have installed in our server:

ls /dev/sd*

Since this is our 2nd drive, you should see /dev/sdb.

Example:

/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sdb

Let see the currently mounted drives and partition layout:

lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

Here's a full list of all available lsblk options:

Tags: Linux HDD ssd admin fdisk parted performance

How to fix Linux error "read-only file system"

Recently our /etc/fstab got screwed up preventing us from SSH-ing into the server after a reboot. So we were given KVM access to our server.

Once seting up Java to allow unsigned certificates--hint: under the Java Control Panel click the "Security" tab, and slide the "security level" to the bottom "Medium" . We were then greated with a message:

'give root password for maintenance or press ctrl+d to continue"

Come to find out CTRL-C and CTRL-V doesn't work, you have to type the pass by hand--this was very tedious since my root pass is extremely complex.

So once in I soon realized that the system was mounted as "read-only"; meaning that you couldn't make any changes to it; or in other words, completely useless at this state.

Tags: Linux admin fstab java KVM

Deny recursive DNS lookups in named (in newer or older versions of BIND)

For security reasons, it's recommended to disable recursive DNS lookups. Here is how:

Find out your named version

named -v

If your BIND version is at least 9.x then insert the following, between options { }:

        // Deny recursive lookups
        allow-query     { any; };
        allow-transfer  { none; };
        allow-recursion { localhost; };
        recursion yes;

So it looks like something like this:

Tags: named bind Linux admin

How to install an Apple Thunderbolt Display on a NON-Apple Thunderbolt PC with brightness control support

So... A couple of years ago I purchased a Thunderbolt capable motherboard  (Gigabyte GA-z77X-UP5), and an Apple's 27-in Thunderbolt Display--rather than it's (now-discontinued) Apple LED Cinema display--to go along with my Apple iMac 2010 (as a dual-display setup) which I was primarily using as an LED monitor for my Windows 7/8 PC.  Boy was that a mistake... LOL . Thunderbolt support on non-Apple computers was TERRIBLE back then. Maybe it still is terrible still, but I got some good news after all this time. More after the break.

How to prevent accidentally doing "rm -rf /" | How to Install safe-rm

As a server administrator, I rely mostly on root or sudo access--allowing me absolute control of the server. However, "with great power, comes great responsibility!"

You can easily accidentally do this devastatingly bad command of wiping your entire system clean.

rm -rf /
# or
rm -rf /*

Which looks almost identical to the popular command

rm -rf ./
# or
rm -rf ./*

There was a recent prank on 4chan /b/ forum that, in short, instructed users to execute the above command in order to "unlock Apple OS X bitcoin mining". 

Tags: Linux rm safe-rm Administration

How to specify where root email goes

Your server sends out a lot of email to user root. For example, CSF (ConfigServer Security & Firewall) sends out most security notifications to root.

So, this is how we specify what email address root emails go to:

vi /etc/aliases

Scroll to the bottom,  and add or replace  existing:

root: [email protected]

Save and exit, then reload the aliases:

newaliases

Another option is to create a ~/.forward file and put your email address in it.

Example: Say I'm logged in as root.

vi ~/.forward

This will create (or edit an exising) file:

/root/.forward

Next we add the email address we want root emails forwarded to:

[email protected] 

Now restart exim.

How to upgrade coreutils to latest version (from source)

Say you're on CentOS 5.x, and want to pimp out your bash prompt using the pretty awesome Solarized color scheme. Well, there's a nice .bashrc Solarized setup here: https://github.com/seebi/dircolors-solarized. To use all the features of dircolors.256dark version, you'll need GNU coreutils 8.5 or higher, otherwise you'll get errors like this:

Tags: Linux coreutils centos Administration DirectAdmin

Notepad++ : How to enable syntax highlighting for PHP, HTML, CSS, etc

I found an interesting discovery with Notepad++ where PHP, HTML, CSS, etc language syntax highlighting didn't appear in the language menu. Not sure if this is the result of the way an older version set the settings--whereas, even if you upgraded to latest version (without uninstalling first), the upgrades wouldn't overwrite the original settings file. I think this was disabled at the time of install when it asks if you want it to be your default for HTML files; where I normally UNselect this, since I use a PHP IDE to handle PHP, HTML, CSS, etc files.

Anyway... The fix:

Tags: notepad++ APPS HTML CSS PHP

Enable Zend OPcache for PHP 5.5 or Install ZendOpcache for PHP 5.3 or PHP 5.4

Zend Opcache is part of PHP 5.5, however, it's not enabled by default. It's a successor to APC cache--meaning APC cache is never going to be compatible with PHP 5.5 or higher

Opcache is also around 10% faster than APC, and more stable.

However, if you're on PHP 5.3 or PHP 5.4, you can still use ZendOpCache, and it should still be a bit faster than APC

Enable OpCache (part of with PHP 5.5)

vi /usr/local/lib/php.ini

Paste this under your extension_dir

Tags: Linux cache APC opcache

How to optimize and auto repair all MySQL databases using SSH

Here's a simple command to optimize and auto repair all tables in your MySQL database.


mysqlcheck -uroot -p --auto-repair --optimize --all-databases

This is the same thing as using PHPMyAdmin, however, you don't need to do this one by one for each database, select all tables, and optimize--and not to mention if you wanted to repair a database prior to optimizing, it will take 2x as long.

Tags: mysql Server Linux database