When we have to create a hash in just one line we can use this particular ruby code:
@users = User.find :all
user_hash = Hash[@users.map {|x| [x.id, x.name]}]
Here we created a hash in just one line with Id as the key of hash a...
For this we need to edit my.cnf file (This should be in /etc directory)
we need to enter following lines :-
log-slow-queries=/logs/mysql/slowQueries.log
long_query_time=30
This time is in seconds , so if any query wi...
By using REGEXP function of mysql.Below is the example via a MySQL Query
select empId,empName from tbl_employee where empName REGEXP [1-4]$;
This will select the data of all employees whose name ends with either 1 or 2 or 3 or 4
Website: http://www.keynotedeviceanywhere.com/
Keynote's DeviceAnywhere platform provides an end-to-end solution for testing and monitoring of mobile apps and websites to ensure the quality, performance and uptime of your products and service...
Here is a way of adding tooltip on a div using built-in ellipsis
$('.mydiv')
.bind('mouseenter', function () {
var $this = $(this);
if (this.offsetWidth < this.scrollWidth && !$this.attr('title'))
$this.at...
Migeration in SQl Server :
There are several options if one wishes to migrate a database from a SQL Server 2005 to SQL 2008 Server. First of all transferring a database from any version of SQL Server 2000 and above to 2008 version. This Wizar...
How add a toggle button for active inactive in Yii CGridView
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'subject-grid',
'dataProvider'=>$model->search(),
'columns'=>array(
'id',
...
Here is a simple way to validate user name and password in an HTML form using java script.
<html>
<head>
<title>
Login page
</title>
</head>
<body>
<h1 style="font-family:Arial;text-align="center"...
Data mirroring refers to the real-time operation of copying data, as an exact copy, from one location to a local or remote storage medium. In computing, a mirror is an exact copy of a dataset. Most commonly, data mirroring is used when multiple e...
Get the snapshot of any website in php without writting a script
<html>
<head>
<!--[if IE]>
<style>
#frame {
zoom: 0.2;
}
</style>
<![endif]-->
</head>
<body>
<div class="test...
Open the code view of any site :
<?php
$lines = file('http://www.whoznext.com/'); //Site url
foreach ($lines as $line_num => $line) { // iterate through each line
echo "Line #{$line_num} : " . htmlspecialchars($line...
Following is the function to change time format from 24 hours to 12 hours, please take a look at input and output examples before you use it
/*
* Return: 24 hours format to 12 hours format
* Input example: 1400, 730, 1205, 0
* Ouput e...
Apple has added many features to its iOS7 operating system. Few are mentioned below:-
Story Board in iOS7 app will have to ask user's permission to access the mic.
The user can use [NSArray firstObject]; just like lastObject in previous...
One of the changes in iOS 7 API's is hiding the status bar. Prior to iOS 7 we could hide status bar by using :
[[UIApplication sharedApplication] setStatusBarHidden:YES];
But now there is a slight change. We need to add a row "View contr...
Following steps are required to find out the coordinates on a page:
Step1: Download the file from the location
http://code.jquery.com/jquery-1.6.3.min.js
Step2: Write the script under the script tag of the aspx page
...
**Appearance Panel in Adobe Illustrator:**
Appearance Panel is one of the most important panel in Adobe Illustrator which used during in designing Illustrations. There are many things that Illustrator users can find in Appearance Panel. Even m...
Here, in this article when i click on one textbox the corresponding text in this textbox hides, and as soon as i click on another textbox the first textbox text appears.
The following steps are required to make the above task possible
Step1...
Following steps are required for showing a popup on mousehover on a link
Step1: Attach the javascript file from
http://code.jquery.com/jquery-1.6.3.min.js
Step2: Write the following internal stylesheet under the head secti...
To submit an application to the App Store, you need to create an iOS provisioning profile for distribution (App should be signed with these certificate) for that you have to be a member of the iOS Developer Program.
Note: iTunes Connect does n...
With every new version of OpenERP there are always surprising changes visually or functionally. Lets discuss the very cool new features of OpenERP 7.0 and compare with those of 6.1.
Clean Views:
OpenERP has made the version 7.0 views very ...
If we are using storyboards we can handle different sizes by creating different storyboards for iPhone 4 and iPhone 5 and handle them in didFinishLaunching method of AppDelegate in this way :
Here for iPhone 4 we have storyboard named "Main_iP...
Sometimes we need to display images with rounded corners in our several Applications, and this can be done very easily by writing some lines of code.
To get roundedCorner for an Image use the following code:
/**
* This method is used to ...
Sometimes we may face a situation when we need to remove objects from an array while iterating through the same array. We cannot remove elements from the same array on which we are fast enumerating (for in loop). And if we use the traditional "fo...
The rounded corners are applied to the element's background area, the element's border, and the box-shadow if specified. The CSS3 border-radius property allows you to apply rounded corners to HTML elements without the need to use images or other ...
To add a new server connection using an IP address, you need to follow these steps:
Go to the folder PostgreSQL/data, and edit the file postgresql.conf, add the following line at the end of the file and save:
listen_addresses = '*' ...
In this tutorial, I'll be making a UI with a start/stop recording button. I am using MediaRecording class to record the audio.
After making the layout, Call the method below on click of the mike button in the respective class:
MediaRecorder...
Hello Readers !
In this blog we will discuss about css3 new attribute transform and transition.
Okay let's start :-
Transform : Mainly transform property uses for give small animation or movement of any object.
To use this you have to...
For any enterprise that needs to implement an ERP system, the basic modules that are essential would include all the major functions of the enterprise that describe it completely.
OpenERP is one such system that does it all and has all the mo...
<!DOCTYPE html>
<html>
<head>
<style>
@keyframes anim
{
from {background:#fff;}
to {background:#00ff;}
}
@-webkit-keyframes anim /*Safari and Chrome*/
{
from {background:#000;}
to {background:#090909;}
}
div
...
Below code will return you the products of a category that have status 'Enable' , Visibility 'catalog,search' and
Stock Availability ' In stock'.
$productDetails = Mage::getModel('catalog/category')->load($cat_id)
...
Drupal is a free and open-source content management system. It is being used by around 2.1 % websites, ranging from personal blogs to corporate, political and government websites, all round the world.
Drupal contains all basic features common...
Joomla is one of the most popular open source CMS. It is free and easily customizable. This makes it suitable for both greenhorn users and developing professionals to create websites and potent web applications.
Its easily deployable, has a n...
An .axd file is a HTTP Handler file. There are two types of .axd files.
ScriptResource.axd
WebResource.axd
These are files which are generated at runtime whenever you use ScriptManager in your Web app. This is being generated only once w...
What is NoSQL?
NoSQL is not a relational database it has been developed keeping in mind few of the drawbacks of relational database. It was developed for the purpose of data stored about users, objects and the frequency in which the data is ac...
In many applications we have to share content, links etc on Facebook. We can achieve this by using Facebook feed dialog. The following lines of code explains how to use feed/publish dialog.
First you need to get the app id and create a meta da...
Displaying images in a mobile application is one of the most common tasks for app developers.
It can be quite challenging to efficiently load multiple images and display it on list-view or grid-view in Android.
You can use following single...
Nesting Datalist
Use the .aspx code below to bind datalist inside a datalist.
<asp:DataList ID="lstPanels" runat="server" RepeatColumns="1" RepeatDirection="Horizontal"
DataKeyField="PanelID" OnItemDataBound="lstPanelsItemDataBoun...
If you want to use the ActionBar APIs in the support library. So before you can add the action bar, you must have to set up your project with the appcompat v7 support library.
Steps given below to import and setup appcompat v7 support library...
Remove text from a textbox on focus and getting the text again after loosing focus
Use below .aspx code to make a textbox remove the default text on focus and again get the default text if the user leaves the textbox blank.
<asp:TextBox ...
Copy only columns from a datatable
Use 'clone' method to create a datatable with same structure
dtCopyColumns= dt.Clone();
This will copy only columns from dt to dtCopyColumns
Copy columns and rows from a datatable
dtCopy = ...
A simple code snippet for checking the file-size of a file before uploading it. It will not only help to save time but also network resource as we can implement the file check at the initial point only.
The current code allows the user to sel...
If you want to create a dialog which will look like as spinner dialog of single choice in android which will open in button click event than you can create a custom dialog.
Sample code given below :-
You just have to call this method on cli...
Its quite a feeling of contentment when I see my own work of graphics and web designing. Its been years since I started working thorough & I have learned a lot from people I interacted with and the projects I worked upon. I'd love to share so...
JavaScript Pagination
Here i am going to describe how we would add JavaScript pagination to the table.
We'll focus on displaying a particular page of data.
$(document).ready(function() {
$('table.paginated').each(function() {
var curre...
Hello friends, sometimes you come across with this very unexpected exception.
For eg: In the given code, after execution this exception occurs..
@RequestMapping(value = "addUser")
public String addUser(@ModelAttribute("userForm") UserF...