Category Archives: Tips-N-Tricks

Enable Netfilter/Iptables on ArchLinux

I was surprised that iptables modules are not loaded automatically on ArchLinux. Here’s how you load them. Dump the following lines in any file (for eg. netfilter.conf) under modules-load.d and restart your machine. Alternatively load the modules manually if you want to avoid restarting.

@~ 1028$ cat /etc/modules-load.d/netfilter.conf 
x_tables
ip_tables
iptable_filter
iptable_mangle
nf_conntrack
nf_defrag_ipv4
nf_conntrack_ipv4
nf_nat
iptable_nat

Remove Extra Columns Added by the WordPress SEO Plugin by Yoast

The WordPress SEO Plugin by Yoast is a wonderful plugin for all practical purposes. However its got a minor glitch (or feature – depends on how you perceive it) that it adds extra columns to all post listings. Removing them is easy, but not many people venture into that part of WordPress – The Screen Options. Unselect the columns corresponding to WordPress SEO in screen options so that you don’t have to see them in post listings again. Screenshot Below

Hide Wordperss SEO Columns

Install kmscon on Ubuntu Linux

Kmscon is a simple terminal emulator based on linux kernel mode setting (KMS). It is an attempt to replace the in-kernel VT implementation with a userspace console. It is similar to the in-kernel terminal-emulator and is based on DRM. Listed below is the procedure to install kmscon in ubuntu.

sudo apt-get install libgles2-mesa-dev libgbm-dev libegl1-mesa-dev libdrm-dev libglib2.0-dev libfreetype6-dev
git clone https://github.com/dvdhrm/kmscon.git
./autogen.sh
make
sudo ./kmscon --switchvt

The last command will start kmscon on /dev/tty8.

Assign Google Adsense Code to a PHP Variable

Assigning Google Adsense code to a PHP variable doesn’t work the way you would expect it to. I thought just deleting the newline characters and extra spaces from the adsense code and then assigning the resulting text to a variable should work. However it does not, and I’m not sure why. However what does work is shown below.

<?php
$googleadsensecode = '
<script type="text/javascript">
google_ad_client = "pub-123456789";
google_ad_slot = "123456";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
echo $googleadsensecode;
?>

The following example does not work.

<?php
$googleadsensecode = '<script type="text/javascript"> <!-- google_ad_client = "ca-pub-123456789"; google_ad_slot = "123456"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>';
echo $googleadsensecode
?>

Makefile – Check if a file exists using wildcard function

The following snippet of code can be used to check for the existence of a file from within a Makefile.

ifneq ("$(wildcard $(PATH_TO_FILE))","")
FILE_EXISTS = 1
else
FILE_EXISTS = 0
endif

Quoting from make documentation.

$(wildcard pattern)
The argument pattern is a file name pattern, typically containing
wildcard characters (as in shell file name patterns). The result of
wildcard is a space-separated list of the names of existing files
that match the pattern.

In this present case, we are not using any wildcards, but the absolute path to the file.