Sanjeev Sabhlok's notes on technology, hardware, gardening

How to buy a cheap train ticket from Zurich to Interlaken (or anywhere in Switzerland)

I found that there are a lot of websites that are charging hugely inflated amounts for train tickets.

The advantage of using these sites is that you can book well in advance of the journey.

The official Swiss train company does not book tickets more than one month in advance. However, its prices are roughly 50-60 per cent of the price charged by other companies.

If you can wait for a month ahead of the data of travel to book, then use this: https://www.sbb.ch

 

Continue Reading

How to fix the 500 internal server error on Dreamhost/ How to optimise WordPress

Step 1: Find the error log

https://help.dreamhost.com/hc/en-us/articles/216512197-Viewing-your-error-log-via-SFTP

Step 2: Review the bottom of the error log

I was getting massive errors “Premature end of script headers: index.php” – sometimes tens of times every minute.

Step 3: SQL Database – Optimise WordPress tables through phpmyadmin

My database is usually around 96MB. It had grown to 115MB.

DO NOT USE WP-OPTIMISE since it will freeze.

Go to phpmyadmin, select tables with overhead and run optimise from the drop-down menu

Step 4: SQL Database – remove transients

I had thousands of transients in the options table. Removed them (this way).

Step 5: Plugin: Check cache settings

My cache settings (Super cache) needed to be carefully checked

Step 6: Plugin: Smush it

I installed WP Smush plugin and smushed nearly 2000 images (free version does it, but 50 at a time).

Step 7: Plugin: Minify

I installed WP Super Minify to minify javascript and CSS. I still get a bad score on pingdom for these things, but I don’t know how else to fix this issue.

With all this, the site has come back to life and I can now make new posts/ manage the site without it collapsing/ freezing every second.

ADD THESE TO FUNCTIONS.PHP

DEFER PARSING JAVASCRIPT

/**
* Defer parsing of javascript.
*/
if (!(is_admin() )) {
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, ‘.js’ ) ) return $url;
if ( strpos( $url, ‘jquery.js’ ) ) return $url;
// return “$url’ defer “;
return “$url’ defer onload='”;
}
add_filter( ‘clean_url’, ‘defer_parsing_of_js’, 11, 1 );
}

FORCE SCRIPTS INTO FOOTER

/**
* Force scripts into Footer
* @link https://developer.wordpress.org/reference/since/4.2.0/
*/
function enqueue_scripts_in_footer() {
wp_deregister_script( ‘jquery’ ); // https://codex.wordpress.org/Function_Reference/wp_deregister_script
wp_deregister_script( ‘jquery-migrate.min’ );
wp_register_script( ‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, array(), false, true );
wp_register_script( ‘jquery-migrate.min’, ‘/wp-includes/js/jquery/jquery-migrate.min.js’, array(), false, true );
wp_enqueue_script( ‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, array( ‘jquery’ ), false, true );
wp_enqueue_script( ‘jquery-migrate.min’, ‘/wp-includes/js/jquery/jquery-migrate.min.js’, array( ‘jquery-migrate.min’ ), false, true );
}
add_action( ‘wp_enqueue_scripts’, ‘enqueue_scripts_in_footer’ );

 

REMOVE EMOJIS Remove emojis

remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );

 

Continue Reading
Continue Reading