Category Archives: Programming

mariadb logo

MariaDB – An Alternative to MySQL

MariaDB is an Enhanced and Binary Drop In replacement (equivalent) for MySQL. It’s a completely free and open source software, available under GPL/LGPL/BSD. Most importantly, moving from MySQL to MariaDB is seamlessly easy (you rarely need to change anything, just uninstall MySQL and install MariaDB, Voila! you’re ready to go, read on more about the compatibility).

mariadb logo

Why Choose MariaDB over MySQL ?

  • Additional Storage Engines (Aria, XtraDB, Cassandra etc)
  • Speed Improvements (faster joins and subqueries, optimizer enhancements etc)
  • New features and extensions (e.g virtual columns, dynamic columns, pluggable authentication etc)
  • Improved Testing suite
  • Truly open source (as compared to some closed modules in MySQL Enterprise edition)

To know more about the MariaDB, visit the official website : https://mariadb.org/

tmux-vim

tmux 1.8 is released!

tmux is one of the most popular Terminal Multiplexer (never used it? If you’e a heavy terminal user, then probably you need it) . The latest release is v1.8.

Recently I wrote an article on managing multiple terminals with Terminator, tmux is a very similar program but I feel – tmux is more efficeint/faster, specially with vim (or any command line editor such as Emacs). So, whether you already use a similar program or not, you should try tmux.

Installing tmux on Ubuntu

sudo apt-get install tmux

Here is a screenshot (designing my personal blog with jekyll, I’ll launch in next few weeks) using tmux with vim editor.

tmux-vim

checkout official website for more details.

play-logo

Getting Started with Play Framework : Ubuntu/Linux Mint

What is Play Framework ?

Play Framework is a simple and powerful web development framework for Java/Scala. It’s very inspired from Ruby On Rails framework, so it’s like Rails, but for Java/Scala (initially it supported only Java, but now it also supports Scala (a programming language, very similar to Java, with some functional features, designed to be as a better Java)). Unlike other complicated java web development frameworks, Play is very simple and highly productive.

play-logo

Play is a lightweight, fast and highly scalable web development framework, with web friendly architecture and features (stateless, low resource consumption, reactive model based on Iteratee IO etc). So if you’re a Java/Scala developer, who want to develop cool web applications – then Play is a great choice for you.

Installing Play Framework

You must have Java installed (JDK 6 or later), read this tutorial on installing JDK in Ubuntu / Linux Mint if you haven’t already done that. When you’re done setting up java development kit, open a terminal and type javac to make sure everything is setup properly.

Download Play Framework

Download the latest version of Play (currently, it’s v2.1.0) and extract it to your Home Directory (it can be anywhere, but you should have write permission).

Set Path Variable for Play

Add the play to your path variable. Suppose, you have extracted the play framework to ~/packages/play-2.1.0 directory. Then open a terminal and type :

export PATH=$PATH:~/packages/play-2.1.0/

Now, if you type play at the terminal, you should have play command available.

play-command

Creating your first app

Now, you have successfully installed the play framework – Let’s create a simple application “TestApp” (it will simply say : “Hello Play”, not any useful, but you get an overview).

play new TestApp

Now, it will prompt for few questions (Application Name, Java/Scala etc), then move into the application directory and start the application.

cd TestApp
play

Now, you will have the play prompt, So you can run the application –

[TestApp]$ run

Open your browser and type the address http://localhost:9000, the default page should appear.

welcome-play-app

Now, open the file App/Controllers/Application.java in your favorite text editor (Emacs, Vi, gedit etc) or IDE (geany, Eclipse etc) and replace the existing return line (in index method) with this :

return ok("Hello Play");

Now, visit the address http://localhost:9000 (or refresh if it’s slready loaded) and you should see the “Hello Play” greetings. Yeah! our first useless app is running :)

hello-play

Recommended Resources For Further learning!

ruby-2.0

Ruby 2.0.0 “stable” is released!

Ruby 2.0.0-p0 is the first stable release for Ruby 2.0, with a lot of new features and improvements. Ruby 2.0 is very compatible with 1.9, so it will be much easier to migrate to Ruby 2.0 (as compared to 1.8 to 1.9, read the official announcement).

ruby-2.0

What’s new in Ruby 2.0.0 ?

  • core features (better API with keyword arguments, UTF-8 default encoding etc)
  • Built-in libraries (Lazy Enumerator, Onigmo, Async exception handling API..)
  • Debug Support (DTrace support)
  • Performance improvements (GC optimization, faster require, VM optimization etc)

New to Ruby ?

Ruby is an easy to learn scripting language, similar to Python, Perl, PHP etc. It’s optimized for programmer’s happiness :)

Checkout these free tutorials on Ruby.

openshift

Heroku Alternatives : For Deploying Rails Applications

Heroku is a cool PaaS (Platform as a Service) for deploying Ruby on Rails applications. It has even a free plan to help you get started (although, it has issue though – often the dyno becomes idle, so I won’t consider it for any real world projects/experiments) but the problem is – as you need more resources, it can easily get quite expensive and slow(if you don’t overthrow more dynos). By the way, if you’re aware of the Heroku’s Routing Secret (causing horrible response time for Rails applications) then it’s the time to look for alternative options.

What are some good alternatives to Heroku ?

Heroku is a Platform as a Service, so it lets you concentrate fully on the application development, by taking care of the server administration stuffs. So, If you want similar experience then you should try Redhat’s OpenShift or Cloud Foundry.

openshift

1. OpenShift

OpenShift is a free and open source PaaS for deploying web applications (supports all cool frameworks such as Ruby On Rails, Sinatra, Django, Node.js etc). They also provide a free plan to get you started – with 3 small gears for free! (gears are resource units, each with some limited amount of RAM (512 MB) and disk space (1GB)). For Rails , currently supported databases are MySQL, MongoDB and PostgreSQL.

Deploying Rails applications is also very easy (checkout an example rails app demo on github).
Know More on OpenShift

2. Cloud Foundry

Cloud Foundry is another PaaS platform for deploying web apps, it’s an open and scalable platform, from the VMware. It also supports a number of frameworks and tools.

checkout Cloud Foundry Project for more details and you can find a Core provider for Cloud Foundry.

There are lots of awesome Cloud Foundry providers including AppFog.

AppFog – it’s a PaaS built on Cloud Foundry, they also have a free plan with 2GB RAM, 50GB bandwidth etc to help you get started.

About AppFog

If you need more control over the things, then IaaS (Infrastructure as a Service) may be best suitable for you. AWS(Amazon Web Services) is the best option for that (Google has also offered similar services such as GCE(Google Compute Engine) but it’s very new and lacks a lot of features).

3. AWS

AWS offers complete set of services for building highly scalable web applications. It has S3 (scalable storage), EC2 (virtual servers on demand), Block Storage, Cloudfront (CDN), Cloudwatch, RDS (Relational Databases such as MySQL), DynamoDB (NoSQL store), Route 53, VPC, SES (Email Notifications), SNS (Push Notifications) and lot of other cool services to help you quickly build, deploy and scale.

checkout AWS services and features

Recently, Amazon has also announced a PaaS service, based on the top of their existing AWS services – Elastic Beanstalk, with the aim of simplifying deploying/managing applications.

4. VPS

Virtual Private Server (VPS) is a good option for small or medium sized predictable web applications. You can easily setup Capistrano for automated deployment. Once the things are setup, VPS management is not so hard as it seems, especially if you got a reliable and awesome VPS provider such as Linode or Digital Ocean (plan starts at $5/mo with 512 MB RAM, 20GB SSD and 2TB Bandwidth, not sure checkout the review of digital ocean)

If you’re not sure, where to begin then checkout this guide about deploying Rails applications to VPS

5. Cloud 66

Cloud 66 is an Application Stack Management as a Service, it’s a platform for provisioning, configuring, deploying and managing your web applications. it allow you to easily deploy (to any infrastructure such as VPS, AWS, Joyent Cloud, Rackspace and more) and scale, so you don’t have to worry about your configuring/monitoring your servers anymore. You also get a free plan to try (includes deploying to 1 server).

Cloud 66

Thank You for reading so far :) Checkout my recent fun projects  created using sinatra : this one on jumble and other one for generating funny slogans (fun weekend projects)

Learning Rails ?

Check out this interactive video course on Ruby on Rails at Treehouse.

Update #1. Fixed some typo.
Update #2. Added AppFog.
Update #3. Added Cloud 66.
Update #4. Added more details about OpenShift gear