Monday, December 27, 2010

Things to remeber in linux

  • Display All Information About Files/Directories Using ls -l


Thursday, December 23, 2010

Things to remeber in html

  • text box width is set by style property only style="width:20px" not by width property <input type="text" id="text1" name="text1" style="width:20px" />
  • For putting html in the blogger you should go to this site and encode the code http://centricle.com/tools/html-entities/



Monday, December 20, 2010

Things to remeber in php

Things to remember in php so that you don't dependent on google and manual.

  • To push values in array $stack.
array_push($stack, "apple", "raspberry");
  • preg_split used in youngib api for commandline interface .
    array preg_split ( string $pattern , string $subject [, int $limit = -1 [, int $flags = 0 ]] )

Friday, December 17, 2010

Indexing in database

  • An index is a separate file that is sorted, and contains only the field/s you're interested in sorting on. If you create an index on employee_number, MySQL can find the corresponding record very quickly (Indexes work in very similar ways to an index in a book. Imagine paging through a technical book (or more often, an scrambled pile of notes!) looking for the topic "Optimizing MySQL". An index saves you an immense amount of time!
  • http://www.databasejournal.com/features/mysql/article.php/1382791/Optimizing-MySQL-Queries-and-Indexes.htm

Wednesday, November 24, 2010

Css Learning

  • white-space:no-wrap to make text in a line .
  • vertical-align:middle; display:table-cell will not work with float so advise to insert a div cover for entering float .
  • Use Float left to all the div in the container with the width specified.
  • Use Position:relative for parent div , and absolute for child div for positioning.
  • For Floating image use overflow:hidden;
  • Use CSS selectors .e.g. > * for select adjacent child divs. Check this link for more css selectors.
  • Z-index of elements should be check in the same Containers., And position should be absolute of the other element.

Tuesday, November 23, 2010

Regular Expressions

Regular Expression of Email:
string :rahul@gmail.com
exp.:([a-z])+@([a-z])+\.([a-z])+([a-z])

Passwords cannot contain sequences of 3 or more of the same character
(.)\1\1

  • # the following expression finds double characters
    (.)\1

Brackets, Ranges and Negation[],- ^

Positioning (or Anchors)^,$,.


  • The ^ (circumflex or caret) outside square brackets means look only at the beginning of the target string, for example,
  • The $ (dollar) means look only at the end of the target string, for example, fox$ will
  • The . (period) means any character(s) in this position,

Iteration MetaCharcters ?,* ,+,{n},{}
  • The ? (question mark) matches the preceding character 0 or 1 times only
  • The * (asterisk or star) matches the preceding character 0 or more times
  • The + (plus) matches the previous character 1 or more times,
  • {n} Matches the preceding character n times exactly
  • {n,m} Matches the preceding character at least n times but not more than m times,

More metacharacters()|


Submatches, Groups and Backreferences


for testing and article Please follow
http://www.zytrax.com/tech/web/regex.htm

Tuesday, November 16, 2010

Best Coding Practices

  • The more code you have the more possible to make errors and the more code you have to maintain.
  • Use Plugins are around to make life easier after all to write less code
  • Never write html code in the js files , always put html code in html file , and access html element in jquery .
    Object Oriented Programming
  • Don't put Parent Class in the Child Class , always pass the data to the child class from the Parent Class. e.g. App is parent Class then App should not be in the Child Class . Because it is the method of abstraction.
  • Put the Code related to the Class only in Class else put in Project (App) Class of the Project.
  • To Pass the Parent Class use the context .e.g. for passing config variable to the child class.
  • Each Class is separate entity and should be complete,not dependent on any class and should not give error if something changed in other class.
  • Best OOPS Principles http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
  • http://www.dofactory.com/Patterns/Patterns.aspx

Monday, November 15, 2010

Becoming Team Leader

  • I'm expected to mentor other developers, work on requirements
  • make design decisions for other developers
  • evaluate bug reports from users, assign them to developers,
  • As an individually-contributing developer, my job was to turn my own time in to software that the business could sell for a profit.

    As a team lead, my job is to see that the team effectively turns their time in to software that the business could sell for a profit.

  • Developer has two works only coding and meeting
  • Team Leader have to do
  1. Meeting with more persons
  2. Delegation - distribution of work
  3. Documentation
  4. Communication to client and others
  5. Mentoring the team .

Tuesday, October 26, 2010

code review process

Code review process:

  1. Design: we provided a high level over view of how to solve a problem. No code at this stage. Talk with fellow developer who is available and development manager. Benefits of early design review is getting input that a single developer might have missed. Re-design etc if required.
  2. Code it.
  3. Submit code/link to code changes to another developer for peer review via email/electronically. Best bet is to submit it to a developer who was not involved with design review. Note that the reviewer should review the code without input from the original developer. This is important. We approach it this way for several reasons. If the code can be understood by someone who has not written it then it is safe to say it is maintanable should the original developer be no longer around to ask (left the company or whatever) or even if they are. If the code reviewer cant understand the code then its given back to the developer and he/she makes it more understandable either by greater documentation or refactoring the code. It could be as simple as adding more information to the bug description that the code change is realted to. This in it self saves so much time in the future. The ability to pick up someone elses code and understand it quickly is very advantageous.
  4. Developer and code reviewer get together and discuss code/improvements.
  5. Developer makes changes if required.




Types of Code Review Activity:

1. Desk Review

2. Peer Review

3. Panel Review

4. Client Review

Desk Review /Informal Review:

1. As a Senior Developer/ team lead / Project lead can sit with developer in his machine and check the complex component implementation.

2. Review the naming convention, number of lines per method or class and for loop, if else ladder, Map or List or array usage and review the developer business logic understanding and implementation.

3. Provide the on the fly review comments to the developer to focus on the key implementation skeleton.


Peer Review:

1. As part of any logical component implementation completion, the developer can call for the Peer Review.

2. Peer will be identified with in his track/team and the code artifacts needs to be submitted to the peer by the developer

3. Identified peer will review the code artifacts against the coding checklist as well with the help of coding guidelines

4. Peer will provide the review comments to the appropriate developer and Keep the Team Lead/Project lead in the communication loop.



Panel Review:

1. Panel will be identified with in the project

2. Panel consist of Architect, SME, Lead, Senior Developers (max 5- 8 people)

3. End of Specific Service or Functionality formal component implementation completion, the code or deliverable will be submitted to the Panel by the respective track or team lead.

4. Panel member will do the offline review on the code/artifacts thoroughly

5. Panel needs to check the Implementation strategy, design pattern, reusability, QoS and the functional logic implementation.

6. Panel will gather in the Meeting room and the team lead /code owner will present the code to panel and walkthrough the artifacts.

7. Panel will raise the concern or identified gap in the meeting and the panel member will discuss the gaps.

8. Finally the panel will recommend the refactoring or approve the code for baseline.

9. All the review comments will be prioritized under one of the following criteria such as Development change/refactoring, bug, design issue, requirement missing, Change Request etc

Client Review:

1. After the panel review ,the code will be given to the Client Technical panel (if your project structure has this?) and receive their inputs for further beautification in your client deliverables.

Finally your project manager will take the summary of the code review metrics from the tool and use that for code quality metrics/ SLA Base line.

source :http://www.saching.com/Articles/What-is-Code-Review-Process-2121.html

Sunday, October 24, 2010

using jquery ui

jQuery UI provides a comprehensive set of core interaction plugins, UI widgets and visual effects that use a jQuery-style, event-driven architecture and a focus on web standards, accessiblity, flexible styling, and user-friendly design. All plugins are tested for compatibility in IE 6.0+, Firefox 3+, Safari 3.1+, Opera 9.6+, and Google Chrome.

Interactions

Complex behaviors like drag and drop, resizing, selection and sorting.


Widgets

Full-featured UI controls — each has a range of options and is fully themeable.


Utilities

Low-level utilities for building rich interactions, widgets, and effects.

Effects

Animated transitions and easing for rich interactions.

Effect Methods


Thursday, July 22, 2010

Cross Table Delete with MySQL

DELETE product.*, productPrice.*
FROM product p, productPrice pp
WHERE p.productId = pp.productId
AND p.created < '2004-01-01'

php curl to access a site


$url = 'http://www.google.com';

//open connection
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
);
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);

curl_setopt_array( $ch, $options );
//execute post
$result = curl_exec($ch);
$header = curl_getinfo( $ch );
echo $result;
//close connection
curl_close($ch);
?>

Monday, July 5, 2010

ape server ajax push engine

APE server side module

The APE module is the fastest, most modular and powerful way to exchange data between all users. With a APE module you can :

  • Push data to a client
  • Push data to a channel
  • Set property to user (for example user nickname)
  • Set property on channel (for example save last sent message on the channel)
  • Get information about users connected to APE
  • Get data from a MySQL server
  • Create a socket
  • Do many others things

Wednesday, June 30, 2010

ulip vs mutual fund......

Mutual Fund are pure investments. ULIP are combination of Insurance and Investment.

First question that we need to answer while buying ULIP is - Do I need to buy insurance?

1) Does the person seeking insurance have any financial liabilities?
2) If something happens to the person, Is there someone who can be in a financial crisis?

1) Insurance
ULIPs provide you with insurance cover.
MFs don’t provide you with insurance cover.

A point in favor of ULIPs. But let me tell you that you don’t get this insurance cover for free. Mortality charges (i.e. the price you pay for the insurance cover) get deducted from your investment.

2) Entry Load
ULIPs generally come with a huge entry load. For different schemes, this can vary between 5 to 40% of the first years premium.
MFs do not have any entry load.

Tax saving MF ( Popularly called as Equity Linked Saving Scheme or ELSS) come with a lock-in period of 3 years. Other MFs don’t have a lock-in period. Again MFs have advantage over ULIPs. ULIPs do allow you to take money out prematurely but they also put penalties on you for doing that.


Friday, June 25, 2010

shares

1. You own a part of the business

.

The good news is, since you own part of the company, you are entitled to a share in its profits.

The bad news is that you are also expected to bear the losses, if any.


2. In the short-run, the price of the share can wildly fluctuate

Let's say the company fixes the price of each share at Rs 10. This is called the face value of the share.

When the share is traded in the stock market, this value may go up or down depending on supply of and demand for the stock.

If everyone wants to buy the shares, the price will go up. If nobody wants to buy the shares, and many want to sell them, the price will fall.

The value of a share in the market at any point of time is called the 'price of the share' or the 'market value of a stock'.

A share with a face value of Rs 10 may be quoted at Rs 55 (higher than the face value) or even Rs 9 (lower than the face value).

So you might have paid Rs 15 for a share which is now quoting at Rs 12. Don't panic and sell. If it is a good company, the share price will eventually rise.

The prices will get influenced by the market sentiment and the general direction of the market. As a result, you may see short-term slumps.

4. Decide how much you want to invest

5. Don't rely solely on 'good advice'

It doesn't matter who is buying the stock or who is recommending it. Steer clear of such ways of making a fast buck. These tips will land you in a soup.

When you hear of a 'hot tip', dig further.

6.. There are many things to remember when you buy shares. stop loss, short sell, Intraday, Delivery, Cash trade e.t.c.

http://www.sharemarkettheory.blogspot.com




Wednesday, June 23, 2010

software architecture

Software architecture is the set of decisions the software architect makes.

The Role of the Software Architect

Tuesday, June 22, 2010

giving the demo of software

  • do's
  • demo is all about demonstrating your product
  • you will live or die by your product
  • you should believe in your product and its ability to shine ,so let it shine
  • gimmick to show value your product skit ,role playing,video etc.
  • a while few laugh keep the audience engaged
  • . Leave room for spontaneity (or at least appear like you have).
  • Have fun. DEMO is fun. That's why people like it
  • . Have a backup plan.
  • Practice piece by piece.
  • Practice in front of people.
  • Practice with distractions.
  • Find your speaking style
  • Practice hand gestures.
  • Find your comfort zone.
donts
  • Don't praise your own product.
  • Don't use a tag line.
  • Don't say what you're looking for out of your DEMO.
  • Don't try to be funny if you aren't funny.
  • Don't sing.

Saturday, June 5, 2010

for getting time difference in two time stamp in minutes for session

for getting time difference in two time stamp in minutes for session

SELECT TIMESTAMPDIFF(MINUTE,`last_update`,CURRENT_TIMESTAMP ) FROM sessions;

thanks
rahul

Monday, May 31, 2010

MAKING EXT JS FORM



HIII

MAKING FORM IN EXT JS OF CRUD OPERATION.

CODE IS AS FOLLOWS

SHOWTASKGRID FUNCTION MAKES THE GRIDPANEL WHICH USES STORE OR RECORDSET IS SIMPLEDATASTORE, SHOW THE COLOUMN MODEL USES THE ROW SELECTION MODEL FOR SHOWING THE UPDATE FORM AND DOING THE DELETE OPERATION , IN FBAR I HAVE GIVEN THE BUTTONS FOR ADD UPDATE ,REFRESH, CLEAR GROUPING AND FOR LOGOUT ,I HAVE GIVEN FUNCTIO FOR DELETERECORD WHICH IS USED FOR DELETED THE RECORD AND MAKE NEW EXT.WINDOW AND ASSING THE GRID VARIABLE IN THE ITEMS OF WINDOW ... BY THIS GRID WILL BE SHOWN IN THE WINDOW....



function showtaskgrid(){
var grid = new xg.GridPanel({
store: SimpleDataStore,
columns: [
{header: "Id", width: 10, sortable: true, dataIndex: 'id'},
{header: "Customer", width: 20, sortable: true, dataIndex: 'customer'},
{header: "Project", width: 20, sortable: true, dataIndex: 'project'},
{header: "Assigned To", width: 20, sortable: true, dataIndex: 'employee'},
{header: "Task", width: 20, sortable: true, dataIndex: 'task'},
{header: "Due Date", width: 20, sortable: true, dataIndex: 'duedate', renderer: Ext.util.Format.dateRenderer('m/d/Y')},
{header: "Hands on Hrs", width: 20, sortable: true, dataIndex: 'handsonhours'},
{header: "Comments", width: 20, sortable: true, dataIndex: 'comment'},
{header: "Completed On", width: 20, sortable: true, dataIndex: 'completiondate', renderer: Ext.util.Format.dateRenderer('m/d/Y')},
{header: "Days Left ", width: 20, sortable: true, dataIndex: 'dayleft'},
{header: "Buffer Hours", width: 20, sortable: true, dataIndex: 'buffhours',renderer:renderbuffhours}
],
sm: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec) {
/* addTab();
Ext.getCmp("task").getForm().loadRecord(rec);*/
}
}
}),
listeners: {
viewready: function(g) {
g.getSelectionModel().selectRow(0);
} // Allow rows to be rendered.
},
viewConfig: {
forceFit:true,
enableRowBody:true,
showPreview:true,
getRowClass : function(record, rowIndex, p, ds) {
var xf = Ext.util.Format;
p.body = '

' + xf.ellipsis(xf.stripTags(record.data.comment), 200) + '

';
return 'x-grid3-row-expanded';
}
},
view: new Ext.grid.GroupingView({
forceFit:true,

groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
}),


plugins: filters,
frame:true,
width: 1000,
height: 450,
collapsible: true,
animCollapse: false,
title: 'Listing of Task',

iconCls: 'icon-grid',
fbar : ['->', {
text:'Clear Grouping',
iconCls: 'icon-clear-group',
handler : function(){
SimpleDataStore.clearGrouping();
}
},'-', {
text:'Add Task',
iconCls: 'icon-clear-group',
handler : function(){
addTab();

}
},'-', {
text:'Refresh',
iconCls: 'icon-clear-group',
handler : function(){
grid.getStore().removeAll();
grid.getStore().load();

}
},'-', {
text:'Update',
iconCls: 'icon-clear-group',
handler : function(){
var selectedKeys = grid.selModel.selections.keys;
if(selectedKeys.length > 0)
{
addTab();
var rec = grid.getSelectionModel().getSelected();

Ext.getCmp("task").getForm().loadRecord(rec);
}
else
{
Ext.MessageBox.alert('Message','Please select at least one item to delete');
}

}
},'-', {
text:'Delete',
iconCls: 'icon-clear-group',
handler : function(){
var selectedKeys = grid.selModel.selections.keys;
if(selectedKeys.length > 0)
{
Ext.MessageBox.confirm('Message','Do you really want to delete selection?', deleteRecord);
}
else
{
Ext.MessageBox.alert('Message','Please select at least one item to delete');
}

}
},'-', {
text:'Log Out',
iconCls: 'add16',
handler : function(){
Ext.Ajax.request({
url:'logout.php',
success:function(){window.location='index.php';},
failure:function(){window.location='index.php';},
});

}
}
]
});
function deleteRecord(btn) {
if(btn=='yes')
{

//returns record objects for selected rows (all info for row)
var selectedRows = grid.selModel.selections.items;

//returns array of selected rows ids only
var selectedKeys = grid.selModel.selections.keys;

//note we already did an if(selectedKeys) to get here

//encode array into json
var encoded_keys = Ext.encode(selectedKeys);
//submit to server
Ext.Ajax.request( //alternative to Ext.form.FormPanel? or Ext.BasicForm.submit
{ //specify options (note success/failure below that receives these same options)
waitMsg: 'Saving changes...',
//url where to send request (url to server side script)
url: 'deletetask.php',

//params will be available via $_POST or $_REQUEST:
params: {
task: "delete", //pass task to do to the server script
companyID: selectedKeys//the unique id(s)

},

/**
* You can also specify a callback (instead of or in
* addition to success/failure) for custom handling.
* If you have success/failure defined, those will
* fire before 'callback'. This callback will fire
* regardless of success or failure.*/
callback: function (options, success, response) {
if (success) { //success will be true if the request succeeded
Ext.MessageBox.alert('OK','record deleted');//you won't see this alert if the next one pops up fast
var json = Ext.util.JSON.decode(response.responseText);

//need to move this to an after event because
//it will fire before the grid is re-rendered
//(while the deleted row(s) are still there
Ext.MessageBox.alert('OK', ' record(s) deleted.');

//You could update an element on your page with
//the result from the server
//(e.g.
)
//var total = Ext.get('total');
//total.update(json.sum);

} else{
Ext.MessageBox.alert('Sorry, please try again. [Q304]',response.responseText);
}
},

//the function to be called upon failure of the request (server script, 404, or 403 errors)
failure:function(response,options){
Ext.MessageBox.alert('Warning','Oops...');
//ds.rejectChanges();//undo any changes
},
success:function(response,options){
//Ext.MessageBox.alert('Success','Yeah...');
//commit changes and remove the red triangle which
//indicates a 'dirty' field
grid.getStore().removeAll();
grid.getStore().load();
}
} //end Ajax request config
);// end Ajax request initialization
};//end if click 'yes' on button
}; // end deleteRecord
SimpleDataStore.load();

var wingrid = new Ext.Window({
title: 'Task Manager',
id:Ext.id(),
closable:false,
width:1200,
height:700,
minWidth: 300,
minHeight: 200,
//border:false,
layout:'fit',

items: grid
});
wingrid.show(this);
}

FOR MAKING THE GROUPING STORE IN EXTJS I HAVE USED THE FOLLOWING CODE

var SimpleDataStore = new Ext.data.GroupingStore({
proxy: new Ext.data.HttpProxy({
url: 'tasklist.php',
method: 'POST'
}),
reader: new Ext.data.JsonReader({

},
[
//this is field in database
{name: 'id', type: 'numeric'},
{name: 'customer', type: 'string'},
{name: 'project', type: 'string'},
{name: 'employee', type: 'string'},
{name: 'task', type: 'string'},
{name: 'duedate', type: 'date'},
{name: 'handsonhours', type: 'numeric'},
{name: 'completiondate', type: 'date'},
{name: 'comment', type: 'string'},
{name: 'dayleft', type: 'string'},
{name: 'buffhours', type: 'string'}

]),
sortInfo:{field: 'customer', direction: "ASC"},
groupField:'customer' // this script used to classify by country
});

FOR GIVING FILTER TO THE GRID USED THE FOLLOWING CODE....


var filters = new Ext.ux.grid.GridFilters({
local:true,
filters:[
{type: 'numeric', dataIndex: 'id',store: SimpleDataStore},
{type: 'string', dataIndex: 'customer',store: SimpleDataStore},
{type: 'string', dataIndex: 'project'},
{type: 'string', dataIndex: 'employee'},
{ type: 'string',dataIndex: 'task'},
{ type: 'date',dataIndex: 'duedate'},
{ type: 'numeric',dataIndex: 'handsonhours'},
{dataIndex: 'completiondate', type: 'date'},
{dataIndex: 'comment', type: 'string'},
{dataIndex: 'dayleft', type: 'numeric'},
{dataIndex: 'buffhours', type: 'numeric'}
]});

FOR OPENING THE FORM ON CLICK OF THE ADD BUTTON.....

USE THIS FUNCTION.....

function addTab(){
/*data store for project,employee,customer auttosuggest*/
var customer = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'customer.php'
}),
reader: new Ext.data.JsonReader({

},
[{name: 'customer'},
{name: 'customer'}
])
});
customer.load();
var project = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'project.php'
}),
reader: new Ext.data.JsonReader({

},
[{name: 'project'},
{name: 'project'}
])
});
project.load();
var employee = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'employee.php'
}),
reader: new Ext.data.JsonReader({

},
[{name: 'employee'},
{name: 'employee'}
])
});
employee.load();
/* formpanel for form for add edit task*/
var simple = new Ext.FormPanel
({
id:'task',
bodyStyle : "padding: 0px;",
buttonAlign: 'center',
defaults: {anchor: '100%'},
defaultType: 'textfield',
frame : true,
labelAlign : "top",
method: 'post',
style: 'margin: 0px auto',
url: 'savetask.php',
width: 300,
items :
[{
xtype:'combo',
store: customer,
name:'customer',
fieldLabel : "Customer",
displayField: 'customer',
valueField:'customer',
minChars: 1,
typeAhead: false,
mode: 'remote',
forceSelection: false,
triggerAction: 'all',
emptyText: 'Select a customer...',
selectOnFocus: true

},{
xtype:'combo',
store: project,
name:'project',
fieldLabel : "Project",
displayField: 'project',
valueField:'project',
minChars: 1,
typeAhead: false,
mode: 'remote',
forceSelection: false,
triggerAction: 'all',
emptyText: 'Select a project...',
selectOnFocus: true
},{
xtype:'combo',
store: employee,
name:'employee',
fieldLabel : "Employee",
displayField: 'employee',
valueField:'employee',
minChars: 1,
typeAhead: false,
mode: 'remote',
forceSelection: false,
triggerAction: 'all',
emptyText: 'Select a employee...',
selectOnFocus: true
},{
xtype : "textarea",
name : "task",
fieldLabel : "Task",
height : 50,
},

{
xtype : "hidden",
name : "id",
fieldLabel : "id",
height : 0,
}
,

new Ext.form.DateField({
fieldLabel: 'Due Date',
name: 'duedate',
allowBlank: false,
width:190
}),
{
name : "handsonhours",
fieldLabel : "Hand On Hours"
} ,{
xtype : "textarea",
name : "comment",
fieldLabel : "Comment",
height : 50,
},
new Ext.form.DateField({
fieldLabel: 'Completion Date',
name: 'completiondate',
width:190
})



],

});
/* window for form for add edit task*/
if(!win){
var win = new Ext.Window({
title: 'Add Task',
id:Ext.id(),
closable:true,
width:500,
height:550,
minWidth: 300,
minHeight: 200,
//border:false,
layout:'fit',
plain:true,
items: simple,
buttons:
[{
text: 'Reset',
handler: function(){simple.getForm().reset()}
},{
text: 'Submit',
handler: function()
{
simple.getForm().submit
({
success: function(form, action) {

Ext.Msg.alert('Success', action.result.msg);
grid.getStore().removeAll();
grid.getStore().load();
win.hide();
},

failure: function(form, action) {
Ext.Msg.alert('Failure', action.result.msg);
win.hide();
}
});
}
}]

});
}
win.show(this);
}
IN THIS FUNCTION FIRST I HAVE MAKE THREE DATA STORE FOR CUSTOMER,PROJECT,EMPLOYEE AUTO SUGGEST COMBO BOX IN THIS I WAS GETTING THE PROBLEM OF NOT GETTING THE DATA ON TYPING IN THE TEXT BOX THAN THROUGH SOME BLOG I GOT THE IDEA OF POSTING OF QUERY IN THE VALUE OF TEXT BOXT I GOT THAT IN THE POST VARIABLE THAN I QUERY WITH THAT POST VARIABLE WITH LIKE THAN MY PROBLEM IS SOLVED , THE CODOR HELPED ME IN SOLVING THIS PROBLEM THANKS TO HIM..

AFTER MAKING THIS AUTO SUGGEST I MAKED THE FORM PANEL IN WHICH ALL TEXT BOX AND AUTOSUGGEST I PUT THAN I MAKED NEW WINDOW AND ASSIGNED THE FORM SIMPLE VARIBLE TO WINDOW AND SHOWED IT ........

I HAVE MADED THE LOGIN LOGOUT FORM IN EXTJS IN THAT I GOT THE PROBLEM OF SESSION VARIBLE THAN I PUT THE ACTION ON LOGIN
IS WINDOW.LOCATION TO ANOTHER PAGE THAN I GOT THE SESSION VARIABLE STOARGE

THANKS


RAHUL







Monday, May 3, 2010

testing web application

1.check broken link from
http://www.dead-link-checker.com/en/
2.check design all browser testing -every page
3.form submission and flow of dynamic website

a) if admin there then password encryption check

Saturday, May 1, 2010

feed aggreegator in ruby on rails

to fetch the feed to the db
def cfeed
if params[:recache] and params[:secret]=="at123"
cache_feeds
expire_fragment(:controller => 'public', :action => 'index') # next load of index will re-fragment cache
render :text => "Done recaching feeds"
end
end


uses the feed tool gem

# This will replace cached feeds in the DB that have the same URI. Be careful not to tie up the DB connection.
def cache_feeds
puts "Caching feeds... (can be slow)"

feeds = Feed.all.map do |uri|

feed = FeedTools::Feed.open( uri.address )
{ :uri => uri.address, :title => feed.title,
:items => feed.items.map { |item|
{:title => item.title, :published => item.published, :link => item.link,:description=>item.description,:author=>item.author} } }

end
feeds.each { |feed|
new = CachedFeed.find_or_initialize_by_uri( feed[:uri] )
new.parsed_feed = feed
puts feed
new.save!
}
end

and for showing the feeds from db to page..

@f=Feed.find(:all)
@aggregate = read_cache unless read_fragment({})

def read_cache
@fr=@f
@fr.map { |uri|
begin
feed = CachedFeed.find_by_uri( uri.address ).parsed_feed
feed[:items].map { |item| {:feed_title =>feed[:title], :feed_item => item} }
rescue
[] # because there might not be anything cached for some feed(s)
end

} .flatten .sort_by { |item| item[:feed_item][:published] } .reverse
end

and for the view part use the following code


<% cache do %>
<%
lastday = -1
@aggregate.each do |item| %>


<%
mydate = item[:feed_item][:published].getlocal
if mydate.yday != lastday
%>
<%= mydate.strftime("%b %d,%Y" ) %>
<%
lastday = mydate.yday
end
%>


"><%= item[:feed_item][:title] %>


<%=item[:feed_item][:description]%>


<% end %>
<% end %>


this will make your feed agreegator hopefully better..

adding google add to your site

to add google ad to your site use the following code

google custom search add

added the google custom search which search in the particular url..

Friday, April 30, 2010

adding feed burner to your site

use this code for use feedburner give the id of the site..

adding twitter of yours to your site

just use this code to your site

db porting task or db table migration

i was want to migrate the table and i have used this query which helpful


INSERT INTO tg_development.content_masters
(
content_text,
title,parent_id
)
(SELECT `fulltext`,title,CASE WHEN jos_content.sectionid=5 THEN 2 ELSE 3 END FROM tegeek_jo151.jos_content)

which have transfered the all data to other database..

Password Encryption through javascript

hii

in my site in admin panel was wanted to do the password encryption of ruby on rails so i got some resources for it and implemented like this,

first my form of login is like this..
  <%= javascript_include_tag('rsa/jsbn', 'rsa/prng4', 'rsa/rng', 'rsa/rsa', 'rsa/base64', :cache => true) %>


 <% form_tag session_path, :id => 'login' do -%>

Please Login

<%= text_field_tag :username, params[:username] %>


<%= password_field_tag :upassword, params[:upassword] %>

<%= hidden_field_tag :password, '' %>

<%= submit_tag 'Log in' %>
<% end -%>
  <%= hidden_field_tag :public_modulus, @public_modulus %>
<%= hidden_field_tag :public_exponent, @public_exponent %>

Two things to note here. First, we are including the four necessary JavaScript libraries on this page only. Second, we use a hidden field to store/commit the password – this field is populate via JavaScript.

and in the controoller :::::::::
 def new
key = OpenSSL::PKey::RSA.new(1024)
@public_modulus = key.public_key.n.to_s(16)
@public_exponent = key.public_key.e.to_s(16)
session[:key] = key.to_pem
end
def create
key = OpenSSL::PKey::RSA.new(session[:key])
password = key.private_decrypt(Base64.decode64(params[:password]))
user = User.authenticate(params[:username], password)
if user
reset_session # reset session after login
session[:user_id] = user.id
flash[:notice] = "Welcome back, #{user.username}"
redirect_to admin_url
else
flash[:error] = 'Invalid username/password entered'
new and render :action => 'new'
end
end


http://iamjosh.wordpress.com/2008/03/18/encrypting-login-password-without-ssl-in-ruby-on-rails/


Saturday, April 10, 2010

Formating date Time in Rails

Formating date Time in Rails

You can format Date field by using strftime function

example :

Time.now()
=> Wed Dec 12 15:48:59 +0530 2007

Time.now().strftime(“%d/%m/%y %H:%M”)
=> “12/12/07 15:50″

Here’s the (shortened) table for strftime.

%a weekday name.
%A weekday name (full).
%b month name.
%B month name (full).
%c date and time (locale)
%d day of month [01,31].
%H hour [00,23].
%I hour [01,12].
%j day of year [001,366].
%m month [01,12].
%M minute [00,59].
%p AM or PM
%S Second [00,61]
%U week of year (Sunday)[00,53].
w weekday [0(Sunday),6].
W week of year (Monday)[00,53].
x date (locale).
%X time (locale).
%y year [00,99].
%Y year [2000].
%Z timezone name.


How does respond_to work in the Rails controllers?

WTF is going on?!?! (aka the rails respond_to block)

respond_to do |format|
format.html
format.xml { render :xml => @mah_blogz }
end

The key thing to understand is that respond_to is a method attached to your controllers superclass: ActionController, and we are passing in as an argument something called a block:

respond_to (BLOCK STARTS HERE) do |format|
format.html
format.xml { render :xml => @mah_blogz }
end (BLOCK ENDS HERE)

WTF is a block?

It’s like the innards of a function. Read this great post by Eli Bendersky.

Digging into Rails source: respond_to (edited for clarity)

def respond_to(&block)
responder = Responder.new(self)
block.call(responder)
responder.respond
end

What’s the “&” prefixing the block argument?

We are passing respond_to a ruby block. That block is converted to a Proc due to the “&” prefix to the block argument. The functionality of this prefixed “&” is a Ruby feature. Procs are callable, anonymous functions.

So what’s with the |format| stuff back in the controller?

|format| defines that the block takes one argument (referred to inside the block as ‘format’).

This means that inside the respond_to method, we end up with a Proc that takes one argument. This argument has the .xml and .html methods called on it. What do we pass into the Proc as an argument when we call it from inside respond_to? We pass in an instance of the Responder class.

So we end up calling .html and .xml on an instance of the responder class as it is passed into the block (that’s been converted to a Proc) inside the respond_to method… Phew.

So here we are

I’ll leave you to dig further, but basically from here the Responder instance handles .html and .xml via method_missing, depending on mime types your rails app can process. This allows you to configure other mime types from your rails app by registering them in your initialisers.

Sunday, April 4, 2010

Rss Feed

RSS (most commonly expanded as "Really Simple Syndication") is a family of web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format.