The purpose of this blog is to put together all the articles that have helped us. It may help us again and someone else can also benefit from it. All the credits for included articles go to the original authors. We’ll try our best to include credits with every article, but if we miss someone, excuse us, since this site is not used for commercial purposes.

March 3, 2016

Start Mongodb after System Crash

Recently, I experienced that Mongodb was not starting after a system crash. When I ran service mongod restart mongodb crashed with error in log file. The error said "exception in initAndListen: 12596 old lock file, terminating" If you ever encounter […]
September 4, 2015

Ubuntu – “node: No such file or directory” error on using express-generator

Issue: After you install express-generator on your Ubuntu machine and try to run it like express -h You may encounter an error saying "/usr/bin/env: node: No such file or directory" Solution: The issue is that the Node executable for Ubuntu is […]
June 14, 2015

Uploading multiple files with Carrierwave in Rails 4

This post shows how to use carrierwave gem to upload multiple files in Rails 4 Let suppose the following scenario. We have multiple projects and each project can have multiple screenshots. In project.rb class Project < ActiveRecord::Base has_many :screenshots accepts_nested_attributes_for :screenshots, […]
June 14, 2015

Using has_many with Nested Form in Rails 4

This post shows how to use field_for and accepts_nested_attributes_for to created nested form for has_many model Let suppose the following scenario. We have multiple projects and each project can have multiple screenshots. Following will be the definition of model classes. class […]
April 14, 2015

Using Private key with PuTTY

This article is intended for the members of TeamDX. Following are the steps you need to take in order to log in to server using private key provided to you by your team lead.  Start PuTTY by double-clicking its executable […]
February 13, 2015

Using Twitter Bootstrap with Ruby on Rails

Step by step guide to integrate Twitter Bootstrap with Ruby on Rails application. Please note that after these steps, your application layout file will be replaced with default one. Step1: Add gem to your Gemfile gem 'twitter-bootstrap-rails' Step 2: Install required […]
January 16, 2015

Error installing debugger gem on ubuntu

I recently encountered error while bundle install. The issue was with debugger gem. Following is the error I was getting No source for ruby-1.9.3-p484 provided with debugger-ruby_core_source gem. extconf.rb failed After searching Google for answer, I found that this gem […]
April 30, 2014

Enum column in Rails

Declare an enum attribute where the values map to integers in the database, but can be queried by name. Example: class User < ActiveRecord::Base enum status: [ :admin, :user, :banned ] end  For migration, write  def up create_table :authorities do […]
July 1, 2013

How to write text on existing image using php

The post below describes an easy and quick way to write text over an existing image using PHP. You can use this method to watermark your images and can put it to use in number of other ways.   First […]
June 17, 2013

How to Record Audio Files in Android

The android multimedia frameworks performs a remarkable job with recording and playing a variety of media files. By using this scalable framework you can enrich your applications with audio integration. Depending on your device hardware, you can use the MediaRecorder […]
June 3, 2013

Send SMS programmatically in Android

SMS messaging has become an integral part of every mobile phone and for the past decade every mobile device be it a smartphone or a simple mobile phone has come with an sms messaging feature. Understanding how this application works […]
May 31, 2013

How to use PDO-MySQL with PHP

PDO is a PHP extension that allows multiple PHP's database connections by creating a single cohesive interface. It allows code portability and compatibility across various platforms. It can be considered as a database access layer providing a uniform method of […]
May 29, 2013

How to use 9-Patch images in Android

Android is remarkable good in supporting various screen sizes, it allows various drawable directories for particular screens and layout configurations using density-independent pixel (dp) instructions. Android also allows using 9 patch images as backgrounds for buttons and application content. In […]
May 28, 2013

PHP PHAR Package

The phar extension is used to put entire PHP applications into a single file called a "phar" (PHP Archive) for easy distribution and installation. It provides the means for distributing code as a single archive, that does not have to […]
May 20, 2013

Customer Review Date Changer for Magento

The customer review date changer extension for Magento is a small, lightweight plugin that allows you to change the date for customer reviews at your Magento store. While importing your store from one CMS like WordPress to Magento, you have […]
May 8, 2013

SALT implementation in YII

A salt is a random data string that is used as an input to hash a password. The salt and the password are concatenated and encrypted with a cryptographic hash function and the output is then stored in the database. […]
April 12, 2013

Multiple Attachments using PHPMailer Class

  To send an email with multiple attachments using php, we would be using a class PHPMailer. You can download that class from this link: To add more than one attachments to our email we would be using the […]
April 10, 2013

How to use BB code with PHP

  What is BB code? Bulletin Bar Code or simply BB Code is a lightweight markup language that is used to impose strict formatting rules in discussion boards, forums and occasionally in blogs. Its main objective is to facilitate a […]
April 9, 2013

Nonce Implementation in PHP

What is Nonce? Literally it means a number that can be used only once. Nonce is often a random or pseudo random number that is used in authentication protocols in preventing semantic URL and replay attacks using old communications. Each […]
November 28, 2012

Website Security Measures

I would like to share my personal observations and knowledge relating website security. You can add more by commenting this post. Password Hashing Passwords and other credentials must be stored hashed in Database. Use md5() or sha1() functions. Password Renew […]
November 28, 2012

Toggle WiFi Method in Android

First you need to have user permissions to access WiFi state and change it. To do so add following XML nodes in your app’s Manifest XML file under root node. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> Next we need to […]
November 28, 2012

Verify HTTP URL with PHP

Developers often require verifying the URLs of external sites in various situations like for Affiliate Program, Link Building and many more. We can create a simple function named verifyURL()  which accepts the URL as string parameter and return Boolean if […]
April 23, 2012

Code to make android phone silent

You can use the setRingerMode() method of AudioManager class.  AudioManager audiomanage = (AudioManager)getSystemService(Context.AUDIO_SERVICE); audiomanage.setRingerMode(AudioManager.RINGER_MODE_SILENT);  The value that you pass to the method should be one of RINGER_MODE_NORMAL, RINGER_MODE_SILENT, or RINGER_MODE_VIBRATE Also note that you have to add following permission to […]
November 18, 2011

Protect Magento Product Images from getting Stolen

It is good that magneto offers watermarking for securing the catalog/product images but this security is not sufficient for advance internet users. Suppose, following is the link for your watermarked image But if anyone removes the cache/1/image/de684549e4151748e56ee0dd7902c19f part of […]
September 24, 2011

Magento Admin URL Error 404 Fix

After moving Magento site to new server/location we often get "Error: 404 Not Found" while accessing the admin / back-end. The reason of this error is store_id and website_id should be set to "0" (zero). For some reason when you […]
June 18, 2011

Enable In-place Editing in Yii Grid

Today someone asked me for help to integrate Jeditable with Yii CGridView. So I thought why not write a little tutorial that can help others as well. In this article I assume that you are comfortable working with Yii; you […]
June 8, 2011

How to create custom validation rule

In the scenarios where validation rules provided by the Yii framework won’t handle your requirements, you can create custom validation rules. One example is the "authenticate" validation rule provided in "LoginForm" model of Yii blog demo. You can create your […]
May 15, 2011

Upgrade Redmine

Login to your server using putty Go to RubyForge and copy the URL of Redmine version you want to upgrade to. Download it to your server using wget command. Go to Redmine Site to check the requirements. Make sure you […]
May 15, 2011

Install RubyGems from Source

If you want to install some previous version of RubyGem or for what ever reason, want to install RubyGem from source, perform following steps Login to your server using putty Go to RubyForge and copy the URL of RubyGem of […]
May 12, 2011

Constructor Overloading in PHP

There is no simple method of overloading constructors in PHP. There are few workarounds to achieve this. I use the following technique. class UserIdentity extends CUserIdentity { public function __construct() { $arg_list = func_get_args(); switch(func_num_args()) { case 1: // calling […]
April 26, 2011

Yii’s default validator Aliases

Below is the complete list of predefined validator aliases: boolean: alias of CBooleanValidator, ensuring the attribute has a value that is either CBooleanValidator::trueValue or CBooleanValidator::falseValue. captcha: alias of CCaptchaValidator, ensuring the attribute is equal to the verification code displayed in […]
April 12, 2011

Specifying nested relations for eager loading

Eager loading can be nested. For example, if for every comment, we also want to know its author, we could use the following ‘with’ find:   // find all posts together with their author and the author's profile Post::model()->with('author','author.profile')->findAll();  
April 9, 2011

Add conditions in search for relational tables

Let’s discuss example relationship given on following URL If you want to be able to filter results in grid using Posts’ author name then modify the search function of  Post model to similar to the one given below.
April 4, 2011

Target IE6, IE7, IE8 uniquely

Note: It’s generally considered to be a bad practice to include hacks within your stylesheets, there are some scenarios where you can use these hacks e.g. if you have only one style that needs to be handled differently.
April 3, 2011

Session Handling in Yii

Yii::app()->session->add(‘product’, $productId); Yii::app()->session->get(‘product’); Yii::app()->session->remove(‘product’);
April 3, 2011

Send & retrieve cookies in Yii

To retrieve a cookie with the specified name: $cookie=Yii::app()->request->cookies[$name]; $value=$cookie->value;   To send a cookie:  $cookie=new CHttpCookie($name,$value); Yii::app()->request->cookies[$name]=$cookie;
April 3, 2011

Get current Controller & action in Yii

 In view file  $this->uniqueid        (controller name) $this->action->Id      (action name) ($this is CController instance) In other files Yii::app()->controller->id  Yii::app()->controller->action->id
March 24, 2011

Create Symbolic links in Windows 7

 To create symbolic link in windows 7, use command mklink. C:Windowssystem32> mklink Creates a symbolic link. MKLINK [[/D] | [/H] | [/J]] Link Target /D Creates a directory symbolic link. Default is a file symbolic link. /H Creates a hard […]
February 14, 2011

Installing Self-Signed SSL Certificate on WAMP Server

 Part I: Creating SSL Certificate 1- download windows executable file for openssl from and install it 2- open cmd window  3- cd to [openssl installation directory]/bin e.g if your installation directory is C:Program FilesOpenSSl, then cd to C:Program FilesOpenSSlbin 3- type […]
February 7, 2011

Customize CKEditor

 To add a new font in CKEditor’s font drop down list, add the following lines of code in your config.js   CKEDITOR.editorConfig = function( config ) { config.font_names ="Futura;" + config.font_names; }; CKEDITOR.on( 'instanceCreated', function( e ){ e.editor.addCss("@font-face{font-family:'Futura'; src:url('');" ); […]
February 4, 2011

Debug JavaScript in Internet Explorer

Source: Microsoft Office 2007: The Microsoft Script Editor is normally installed by default with Office 2007, but is not reachable directly from the Start -> All Programs -> Microsoft Office menu.  Instead, you can usually find it by searching for […]
January 20, 2011

Using Join in Update Query

  update solvents,Answers left join solvents.`Solvent` on Answer set t.`Answer_ID` = Answers.Answer_ID where Answers.Question_ID = 2;  
December 15, 2010

MySql query – Grouping by first character in field value

MySQL select statement for querying records grouped by first character of value SELECT case when SUBSTRING( UPPER(`title`) from 1 for 1) between '0' and '9' then '0-9' else SUBSTRING( UPPER(`title`) from 1 for 1) end as letter, count(title) AS occurences […]
December 2, 2010

Hexadecimal codes of Colors

The 16 named colors   black white red green blue cyan magenta yellow gray silver maroon olive navy teal purple lime black white red green blue cyan magenta yellow gray silver maroon olive teal teal purple lime    
November 28, 2010

iFrame in jQuery UI Dialog

To display iFrame in jQuery UI Dialog, use the following code. <html> <head> <link rel="stylesheet" href="./styles/smoothness/jquery-ui-1.7.2.custom.css" type="text/css" media="screen" /> <script type="text/javascript" src="./scripts/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="./scripts/jquery-ui-1.7.2.custom.min.js"></script> <script type="text/javascript"> $(function() { $('a').click(function(e) { e.preventDefault(); var $this = $(this); var horizontalPadding = 30; […]
November 9, 2010

Make the Footer Stick to the Bottom of a Page

Step 1: Markup   <html> <head><!-- header includes... --></head> <body> <div class="wrap"> <div class="header"></div> <div class="middle"></div> </div> <div class="footer"> <!-- footer contents ... --> </div> </body> </html>   Step 2: CSS   html,body{height:100%;} .wrap {min-height: 100%;height: auto !important;height: 100%;} .middle […]
October 12, 2010

Control parent window’s location from a popup

Step 1:  In your parent window document add a function function changeURL(url) { if( url == ""){ url = document.location.href; } document.location.href = url; }   Step 2: In popup document call this function to change URL of parent window opener.document.changeURL(''); […]
October 12, 2010

Control parent window’s location from an iframe

Step 1:  In your parent window document add a function function changeURL(url) { if( url == ""){ url = document.location.href; } document.location.href = url; }   Step 2: In iframe document call this function to change URL of parent window parent.document.changeURL(''); […]
October 10, 2010

How to customize the error message of a validation rule

The following validation rule uses an error message that is different from the default one class Post extends CActiveRecord { public function rules() { return array( array('title, content', 'required', 'message'=>'Please enter a value for {attribute}.'), // ... other rules ); […]
October 9, 2010

DropDown for pageSize in CGridView

A convenient drop down to select page size and save in User state. Step 1: On top of my controller action for the gridview (if you used CRUD, this is actionAdmin() ) i added: // page size drop down changed if […]
October 8, 2010

Steps required to change project to production mode

Step 1: In config/main.php, add following element to "components" array 'cache'=>array( 'class'=>'system.caching.CApcCache', ),   Step2: In config/main.php, add following element to " components[‘db’] " array 'schemaCachingDuration' => 3600   Step 3: Comment out the following line of index.php defined('YII_DEBUG') or […]
October 6, 2010

Upload and resize image using YII

Download and extract this file in protected/extensions directory.   In config/main.php file, add the following element to components array  'image'=>array( 'class'=>'application.extensions.image.CImageComponent', 'driver'=>'GD', )   Now in action, insert the following code and modify paths $model->Picture = CUploadedFile::getInstance($model,'Picture'); if( is_object($model->Picture) ) […]
October 4, 2010

Automated display of flash messages

Step 1. Put this method into your WebUser class: public function getFlashKeys ( ) { $counters=$this->getState(self::FLASH_COUNTERS); if(empty($counters)) return array(); return array_keys($counters); }  
October 4, 2010

Ajax button in CGridView

To add an ajax button to CGridView modify the buttons column  as   'columns' => array( 'id', 'name', array( 'class'=>'CButtonColumn', 'template' => '{view} {update} {delete}', 'buttons'=>array( 'view' => array( 'url'=>'"index.php?r=admin/view&id=".$data->user_id."&m=users"', 'click' => "function (){ $('#viewTab').load($(this).attr('href'));return false; }" ) ), ), […]
October 4, 2010

Display loading div when executing ajax requests

In html add the following div right before closing body tag <div class="ajax-loading"><div></div></div>   Add the following CSS code to stylesheet. (Download loading-bgr.gif and loading.gif) div.ajax-loading{ position: fixed; top: 0; left: 0; height:100%; width:100%; z-index: 9999999; background-image: url('../../images/loading-bgr.gif'); opacity: 0.7; […]
September 22, 2010

Working with flash messages in Yii

If you would like to inform the user, that his changes were successfully saved, you could add the following line to your Controller: Yii::app()->user->setFlash('success',"Data saved!");   Displaying the flash message in a view is done by if( Yii::app()->user->hasFlash('success') ) { […]
September 21, 2010

Installing Zend 5 on Windows 7

Here’s how I installed it, taken from zend forums ( This worked for me in Windows 7. Modify the paths below as needed for your installation of Windows 7. Download and install the latest JRE for Windows: Download and […]
Configuration error when starting up NSU
This website uses cookies to provide necessary website functionality, improve your experience and analyze our traffic. By using our website, you agree to our Privacy Policy and our cookies usage.