Open links in a new tab using jQuery

The most common way to open links in a new tab is to middle click the link in the web browser or right-click. To open a link in a new tab by default you need to add target="_blank" to the hyperlinks, but this would get annoying over time if you have to add this to every link in your source. You can add this simple jQuery snippet to your source to open every external link in a new tab of the web browser. If you don’t already have jQuery need a local copy of it or use Google’s hosted library CDN for jQuery.

<script type="text/javascript" src="//"></script>`

You need to load jQuery before this script loads or else this script won’t work.

  $('a').each(function() {
    var a = new RegExp('/' + + '/');
    if(!a.test(this.href)) {
      $(this).click(function(event) {
        event.stopPropagation();, '_blank');

Sass on Raspberry Pi

Sass also known as Syntactically Awesome Stylesheets is a stylesheet scripting language that is interpreted into Cascading Style Sheet also known as CSS. Sass consists of two syntaxes, The original syntax, called “the indented syntax”, uses a syntax similar to Haml, It uses indentation to separate code blocks and newline characters to separate rules, it uses a .sass extension, The newer syntax uses block formatting that is similar to CSS, It uses braces to denote code blocks and semicolons to separate lines within a block, the new syntax uses a .scss extension.

Sass is really useful when you have to write a lot of stylesheet for a large project or when you want to write maintainable stylesheet library. Sass offers the following features variables, nesting and mixin.

Raspberry Pi can be a really good dedicated hardware to build and manage Sass based projects.

Installing Sass on you Raspberry Pi is really simple.

Installing Ruby.


sudo apt-get install ruby  

(Arch Linux ARM)

pacman -S ruby  

Exporting Ruby path (Only for Arch Linux ARM), place this in your .bashrc.

PATH="$(ruby -e 'puts Gem.user_dir')/bin:$PATH"  
export PATH  

Installing the Sass gem.

gem install sass --no-ri --no-rdoc  

We can now write our first Sass file.

touch style.scss  

If you prefer SASS then.

touch style.sass  

Once you have added these lines to the file, we can now use sass to compile it.

sass style.scss:style.css  


sass style.sass:style.css  

If you have chosen SCSS view the code below. We are creating a mixin and using it.

@mixin bg($bg-color, $bg-fonts) {
    background-color: $bg-color;
    font-family: $bg-fonts;

If you have chosen SASS view the code.

=bg($bg-color, $bg-font)
 background-color: $bg-color
 font-family: $bg-font

 +bg(#ddd, sans-serif)

The CSS output would look something like this for both files.

body {  
  background-color: #dddddd;
  font-family: sans-serif; }

If you want the Sass compiler to actively watch the file changes and update the output this can be done by a simple command.

sass --watch style.scss:style.css  


sass --watch style.sass:style.css  

Now you have Sass installed and setup on your Raspberry Pi.

Happy Coding!

LEMP on Raspberry Pi

Raspberry Pi is a single board ARM based computer developed in the UK by the Raspberry Pi foundation.

Raspberry Pi can be a really good web server for development/production environment, setting up a LEMP (Linux NGINX MariaDB PHP) stack on a Raspberry Pi running Arch Linux ARM is a really easy.

Why Arch Linux ARM?

Arch Linux ARM comes with the latest stable packages and the most recent firmware available for the Raspberry Pi. Arch Linux ARM is also the least memory consuming OS for Raspberry Pi.

I am assuming you have your Raspberry Pi running Arch Linux ARM with access via SSH.


Updating your Raspberry Pi.

 sudo pacman -Syu  

Once the update is done we can now start installing NGINX Web Server.

 sudo pacman -S nginx  

Installing PHP and php extensions

This will install php-fpm and other PHP extensions. This will also install Composer.

 sudo pacman -S php-fpm php-mysql php-sqlite php-xsl php-tidy php-pspell php-mcrypt php-snmp php-mongo php-pear php-composer php-embed php-enchant php-gd php-intl php-ldap php-odbc xdebug  

Installing MariaDB (MariaDB 10).

 sudo pacman -S mariadb  

Now we need to edit our NGINX configuration to pass files through PHP-FPM, I will be using nano but you can use any editor of your choice.

 nano /etc/nginx/nginx.conf 

Once you have the file opened in nano or you prefered editor, replaces the content with the following code block.

 # nginx.conf for 1.6.xworker_processes 1; # Number of nginx process

events {  
 worker_connections 5000;  

http {

server {

    listen 80;
    server_name localhost;

    location / {
        root /srv/http;
        index index.php index.html;

    location ~ \.php$ {
        root /srv/http;
        try_files      $uri = 404;
        fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        include        fastcgi.conf;



Enabling NGINX. PHP-FPM, MariaDB to run at the startup of the Raspberry Pi

systemctl enable mysqld.service; systemctl enable nginx.service; systemctl enable php-fpm.service  

Now we can reboot your Raspberry Pi.


Your web-root or the place where your PHP files are stored is

Getting inside the web-root.

 cd /srv/http  

Now we can create an “index.php file.

 touch index.php 

Add the following lines inside the index.php file.

Now visit your Raspberry Pi ip address. This should display a web page displaying LEMP stack information and list of PHP plugins and plugin configurations

Done, Happy Coding!

Deploy Jekyll using FTP

Jekyll is a blog aware static website generator, Jekyll is mostly used for serving GitHub Pages, You can also run your Jekyll based website on shared hosting, VPS, PAAS and many other hosting platforms. Most hosting platforms do not offer Git to deploy. Most platforms offer FTP and SFTP and sometimes FTP is the only way to transfer files into your server.

I am assuming that you already have Jekyll setup and your Jekyll website complete setup with the matter needed to be filled in the _config.yml.

We will be using Glynn a Rubygem that lets you deploy your Jekyll based website using FTP/SFTP.

Installing Glynn.

gem install glynn --no-ri --no-rdoc # sudo may be required depending on your user privilege.  

Once you have Glynn installed you need to add the following to your _config.yml file

ftp_host: '< ftp hostname >'  
ftp_dir: '/your/path/website'  
ftp_passive: false

# optional
ftp_port: 21                  # default 21  
ftp_username: '< ftp username>'     # default read from stdin  

You can deploy your website by running Glynn inside you Jekyll website. Glynn will read your _config.yml file and ask you for your ftp account password

glynn # Thats it.  

If prefer not entering your ftp account password every time you deploy your website, you can do that too. You can add the ftp account password as a string in the _config.yml

ftp_password: '< ftp account password >'  

Now Glynn won’t ask you for a password while deploying.


Jekyll on Raspberry Pi

green and black circuit board

Jekyll is a blog aware static website generator written in Ruby that converts Markdown files into static HTML files. It supports many Markdown interpreter here are some of them RDiscount , Maruku, Kramdown and RedCarpet. Jekyll stores its configuration in a ‘_config.yml’ file that contains information about how to built the static website and which module and plugins should be used, It is one of the most widely used static website generators. It is recommended due to its popularity and large community support and active development.

It also supports plugin to add more functionality and extensions that are not available by default, these plugins can be written in Ruby and can be placed under the ‘_plugins’ folder, The file must end with the ‘.rb’ extension. Any file placed under the ‘_plugins’ folder will be loaded before the website is generated.

It is available as a Ruby gem that installs with its dependencies, It is easy and fast in terms of usage and performance.

Here is how you can get It running on your Raspberry Pi. We will be compiling Ruby 2.1.2 using RVM, we also would be installing Node.js to avoid the ExecJS issue, I have chosen Node.js over the ‘TheRubyRacer’ gem because Node.js is faster more stable and installs in a shorter time than ‘TheRubyRacer’, If you want a pure Ruby based Jekyll setup you can skip the Node.js install step and go with ‘TheRubyRacer’ gem, It’s all based upon personal preference. The big reason why I am compiling Ruby is that I prefer the latest version of Ruby and compiling Ruby make Jekyll and other Ruby stuff, even more, faster due to adaptation to the CPU cycles. I highly recommend not to overclock you Raspberry Pi over 800 MHz as this process uses means of compiling and might cause damage if you don’t have a stable source of power supply.

I have used PiBang Linux Server Edition, but you can use Raspbian. PiBang Linux is based on Raspbian but it does not come with the extra educational software that Raspbian offers, PiBang Linux Server does not come with GUI or Xorg. I have used SSH to follow the instruction below.


Updated: This is method is for Debian Jessie or newer.

sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-get install ruby-full
sudo gem install jekyll
sudo gem install bundler

If you prefer compiling Ruby, follow the setup below.

We need to first install RVM on our Raspberry Pi.

\curl -sSL | bash -s stable

Once RVM is installed we need to exit the terminal.

/bin/bash --logout

Now RVM can be executed.

We can now fetching dependencies needed to compile Ruby on Raspberry Pi. This command will ask you for your user password by default on Raspbian it’s. raspberrypi If you are I PiBang Linux user it depends on what you have set as the password while going through the setup screen, You have to enter the password of the user you what to log in as.

rvm requirements  

Once we have the build essential and the required packages for compiling Ruby on our Raspberry Pi, we can now install Ruby. ‘2.1.2’ is the current latest version of Ruby at the time of this post being published. Installation of Ruby will take a least 2 hours or more depending on the internet connection and clock speed.

rvm install 2.1.2 # installing Ruby  

Now that we have Ruby installed, we can now finally install Jekyll. By choosing not to install ‘ri and ‘rdoc’ we are saving time and avoiding to install thing we don’t require.

gem install jekyll --no-ri --no-rdoc  

To avoid the ‘ExeJS’ error we need to install Node.js on your Raspberry Pi. A precompiled version of Node.js is already available for the Raspberry Pi. You can install Node.js by reading this post. If you want to build Jekyll based website purely using Ruby you can install ‘TheRubyRacer’ gem. TheRubyRacer takes a lot of time to as it needs to build native extensions.

gem install therubyracer --no-ri --no-rdoc  

Now we can create our Jekyll project/website.

jekyll new website # jekyll new   

Now you can get into the directory.

cd website/  

Once you are in the directory you can start the Jekyll preview server.

jekyll serve  

You can now enter your Raspberry Pi IP address with the port set to ‘4000’ example.  

You will get Jekyll running with its stock setup on your web browser.

You can edit the _config.yml and customize the website. You can read the It documentation and learn more about customization over here.

You can deploy your static website that we just created using ‘Glynn’ or ‘Git’, It depends all on you.

Now we have Jekyll installed on our Raspberry Pi. Thanks for reading and feel free to subscribe using RSS. If you have any problem feel free to leave a comment below.

Atom on Arch Linux

Atom is a cross platform open source text/source code editor developed by GitHub written in C++, Node.js, CoffeeScript, JavaScript, CSS. Atom offers a built in package manager called APM to install packages developed by Atom developers and 3rd party developers. Atom is built on top of Chromium-based desktop application framework. Atom UI can be tweaked by the user. All the user has to do is edit a simple stylesheet written in ‘less’. This stylesheet overrides the default config. The Atom UI can also be reset by cleaning the changes made my the user. Atom editor in active development, Atom by default has a limit of only a file of 2 MB which can be tweaked by the user if he wishes to open a larger file. Atom supports languages that other editor do not support (example: sass,scss).

You can install Atom very easily on Arch Linux, Atom is has a PKGBUILD on AUR.


We need Yaourt to install Atom, You can install Yaourt from here.

Yaourt – Installation of Yaourt on Arch Linux…
**Yaourt** is yet another user repository tool. It is, not co-incidentally, an
acronym for **Y**et **A**n**O**ther **U**ser **R**epository **T**ool. It is a
community contributed repository for pacman, which is the package manager of
[Arch Linux]( and a few other minor Linu…

To install release built of Atom. Atom release downloads it from GitHub release builds.

yaourt -S atom-editor  

To install Git built of Atom. Atom git builds Atom by downloading it from GitHub

yaourt -S atom-editor-git  

Once Atom is done installing you can launch it from the application menu or execute.

atom .  

By default Atom installs Atom’s CLI tools in Linux.


The Atom release and the git built both will built Atom using Node.js on your system. Atom currently does not officially offer pre-built packages for any Linux distribution. Atom’s performance will very depending on your system and may has longer load up time based on your system speed of opening applications. Atom has crossed build 100 which means Atom is more stable.

Now you have Atom installed on Arch Linux. If you have any problem feel free to leave a comment below.

Android SDK : installation on Ubuntu via PPA

**Android SDK** is a development kit targeted at developing apps for mobile devices running Android. With the Android SDK, one can develop, debug, and test apps via an inbuilt emulator. The emulator can emulate the expected behavior of the Android OS on many platforms including Linux, Windows, and Mac.


Here, we will instruct on how you could install the latest version of ***Android SDK  ***under Ubuntu 12.04/11.10 or Linux Mint via our PPA. You can still install it manually if you like; check this page for more details.

Unlike most other SDKs, the Android SDK comes in parts and don’t function without one another. The list of repositories for installation packages on Ubuntu and Linux Mint doesn’t already contain the Android SDK. This is why we would need to add a PPA i.e. Personal Package Archive. This essentially lets us include an additional repository that will let us install the Android SDK via the terminal.

Since it’s the terminal, you’d be guaranteed to have the most recent version of the SDK.

This process will install the following:

    1. The Android SDK and ADK
  1. Eclipse IDE for JAVA
  2. JAVA JDK 6

Install Android SDK

1. Open Terminal

Do this using the keyboard shortcut [CTRL][ALT][T] or [command][option][T] in Macs.

2. Add the new PPA

sudo add-apt-repository ppa:upubuntu-com/sdk

The above command will include the required repository containing Android SDK.

sudo apt-get update

This will update your system to conform with the latest in the repository.

sudo apt-get install android-sdk

This installs the Android SDK. Be patient and let the process complete.

This completes the installation of all of Android SDK components on your Linux PC.

3. Install the ADT plugin in Eclipse

Start up Eclipse that was installed in the previous step.

In the menu-bar go to **Help **> Install New Software

Android SDK

In the pop-up dialog, click the ***Add ***button and enter the following details and click **OK.**
Fill in the following details

Name: **ADT Plugin**(but you can enter whatever you like really)



Check on **Developer Tools** and click **Next***.*

Shortly, you’ll come upon a list of tools to be downloaded. Click Next.


Accept the terms of the license agreements and click **Finish **to start the installation of selected items. Read the whole thing if you are into that sort of thing.

[![Add repository into Eclipse](×264.png)](

When the installation completes, restart Eclipse so that changes take effect. You can now start developing your Android apps and games!

That’s it. Feedback is much appreciated.