Monday, April 21, 2014

How To test REST API using REST CLIENT .

How To Test REST API using REST CLIENT 

REST : REST (REpresentational State Transfer) is a simple stateless architecture that generally runs over HTTP. REST is simpler to use than the well-known SOAP (Simple Object Access Protocol) approach, which requires writing or using a provided server program (to serve data) and a client program (to request data). RESTful APIs are defined with these aspects:
·   base URI, such as http://example.com/resources/
·   an Internet media type for the data. This is often JSON but can be any other valid Internet media type (e.g. XML, Atom, microformats, images, etc.)

·    standard HTTP methods (e.g., GET, PUT, POST, or DELETE)
A sample format of the Rest API with payload and Request method defined as below

URL
Type/Method
Payload (Json)
Response
http://example.com/resources
POST
{
"wsTest": {
"Code": “abc",
"Name": "test",
"enabled": true,
}
}
http://example.com/resources/1
POST
{}
GET
?keywordcode=abc
{
"wsTest": {
"Code": “abc",
"Name": "test",
"enabled": true,
}
}

Rest API could be tested via REST client. Rest client is an addon which comes with Mozilla firefox .
You could also use chrome addon . Link to download restclient addon in chrome 

After installing RESTclient it will ask for the browser to restart .  REST client could be started by clicking on the icon top right corner of the Mozilla firefox browser .

The below snapshot shows the example of GET method 

Steps  > >

1.      Enter the URL / REST API to be tested in the URL field
2.       Select the HTTP method as GET
3.       Set content type to from drop down box .
4.       Click on send button
5.       Check the specified response in response box . can view response as text /JSON 
The below snapshot shows the example of POST method 
Steps  > >
1.       Enter the URL/REST API be tested in the URL field
2.       Select the HTTP method as POST
3.       Enter the JSON request as Payload  eg  :
{
    "noOfResults": 100,
    "start": 0,
    "columns": [
        "itemType",
        "productCode"
    ],
    "fetchResultCount": true,
}
4.       Set content type to from drop down box .
5.       Click on send button
6.       Check the specified response in response box . can view response as TEXT /JSON








Sunday, April 20, 2014

Mongo Db monitoring with mongotop command

mongotop provides a method to track the amount of time a MongoDB instance spends reading and writing data. mongotop provides statistics on a per-collection level. By default, mongotop returns values every second.

Mongotop  Options

--help, -h |Returns information on the options and use of mongotop.
--verbose, -v |Increases the amount of internal reporting returned on standard output or in log files. Increase the verbosity with the -v form by including the option multiple times, (e.g. -vvvvv.)
--quiet |Runs the mongotop in a quiet mode that attempts to limit the amount of output. This option suppresses:
  • output from database commands
  • replication activity
  • connection accepted events
  • connection closed events
--version|Returns the mongotop release number.

Fields in mongotop

mongotop.ns -- Contains the database namespace, which combines the database name and collection.
mongotop.db -- Contains the name of the database. Refers to the global lock, rather than a specific database. This field does not appear unless you have invoked mongotop with the --locks option.


mongotop.total -- Provides the total amount of time that this mongod spent operating on this namespace.
mongotop.read -- Provides the amount of time that this mongod spent performing read operations on this namespace.
mongotop.write -- Provides the amount of time that this mongod spent performing write operations on this namespace.
mongotop.<timestamp> -- Provides a time stamp for the returned data.

Syntax :

By default mongotop connects to the MongoDB instance running on the localhost port 27017.However, mongotop can optionally connect to remote mongod instances. See the mongotop options for more information.

mongotop  --  mongotop will return every second.
mongotop 15 -- mongotop will return every 15 seconds.



Mongo Db monitoring with mongostat command

The mongostat utility provides a quick overview of the status of a currently running mongod or mongosinstance. mongostat is functionally similar to the UNIX/Linux file system utility vmstat, but provides data regarding mongod and mongos instances.


Mongostat Options
--help, -h  | Returns information on the options and use of mongostat.
--verbose, -v | Increases the amount of internal reporting returned on standard output or in log files. Increase the verbosity with the -v form by including the option multiple times, (e.g. -vvvvv.)
--discover | Discovers and reports on statistics from all members of a replica set or sharded cluster. When connected to any member of a replica set, --discover all non-hidden members of the replica set. When connected to a mongos, mongostat will return data from all shards in the cluster. If a replica set provides a shard in the sharded cluster, mongostat will report on non-hidden members of that replica set


.—all | Configures mongostat to return all optional fields.



<sleeptime> | The final argument is the length of time, in seconds, that mongostat waits in between calls. By defaultmongostat returns one call every second.mongostat returns values that reflect the operations over a 1 second period. For values of<sleeptime> greater than 1, mongostat averages data to reflect average operations per second.



--rowcount <number>, -n | Controls the number of rows to output. Use in conjunction with the sleeptime argument to control the duration of a mongostat operation.Unless --rowcount is specified, mongostat will return an infinite number of rows (e.g. value of 0.)



--noheaders | Disables the output of column or field names.



mongostat outputs the following fields:

inserts -- Number of objects inserted into the database per second. If followed by an asterisk (e.g. *), the datum refers to a replicated operation.
query  --  Number of query operations per second.
update  --  Number of update operations per second.
delete  --  Number of delete operations per second.
getmore  --  Number of get more (i.e. cursor batch) operations per second.
command  --  Number of commands per second. On slave and secondary systems, mongostat presents two values separated by a pipe character (e.g. |), in the form of local|replicated commands.
flushes  --  Number of fsync operations per second.
mapped  --  Total amount of data mapped in MB. This is the total data size at the time of the last mongostat call.
size  --  Amount of (virtual) memory in megabytes used by the process at the time of the last mongostat call.
res  --  Amount of (resident) memory in megabytes used by the process at the time of the last mongostat call.
faults  --  Number of page faults per second.
locked  --  The percent of time in a global write lock.
locked db  --  The percent of time in the per-database context-specific lock. mongostat will report the database that has spent the most time since the last mongostat call with a write lock.
(This value represents the amount of time that the listed database spent in a locked state combined with the time that the mongod spent in the global lock. Because of this, and the sampling method, you may see some values greater than 100%.)
idx miss  --  The percent of index access attempts that required a page fault to load a btree node.
qr  --  The length of the queue of clients waiting to read data from the MongoDB instance.
qw  --  The length of the queue of clients waiting to write data from the MongoDB instance.
ar  --  The number of active clients performing read operations.
aw  --  The number of active clients performing write operations.
netIn  --  The amount of network traffic, in bytes, received by the MongoDB instance.
                (This includes traffic from mongostat itself.)
netOut  --  The amount of network traffic, in bytes, sent by the MongoDB instance.
                   (This includes traffic from mongostat itself.)
conn  --  The total number of open connections.
set  --  The name, if applicable, of the replica set.
repl  --  The replication status of the node.
                Value          Replication Type
                     M            master
                  SEC           secondary
                  REC           recovering
                 UNK          unknown
                  SLV           slave


Syntax :

mongostat --rowcount 20 1
mongostat --rowcount 20
mongostat -n 20 1
mongostat -n 20



Saturday, April 19, 2014

Mongo DB Query Cheat Sheet

Mongo Query cheat Sheet 


1. mongo  --  start mongo shell

(By default, mongo looks for a database server listening on port 27017 on the localhost interface.
To connect to a server on a different port or interface, use the --port and --host options.) 

2. List all the database in mongo 
show dbs

3. To create a new database 
 Use %database name%
(but the db hasn’t been created.Now insert some data into collection then it will show the data) 

use test   ( test is the default name of the database which already exist in mongo )

5. To list all the tables(collections) within the same db .
show collections

6. To find a particular entry from the collection 
db.%collection_name%.findOne()
db.testdata.findOne()

7. To find record with where statement and And
Db.%collection_name%.findOne({“key”:”value”,”key”:”value”})
Db.testdata.fineOne({“x”:2})

8. To get the count
Db.%collection_name%.findOne({“key”:”value”,”key”:”value”}).count()
Db.testdata.find().count()
Db.testdata.findOne({“x”:2,”x”:3}).count()

9.To insert multiple documents in mongo table
for (var i = 1; i <= 25; i++) db.%collection_name%.insert( { x : i } ) 
for (var i = 1; i <= 25; i++) db.testData.insert( { x : i } ) 

10. To insert single document in mongo table 
db.%collection_name%.insert( { x : i } )

11. To copy from 1 collection to another
db.source.copyTo("target");
db.testdata.copyTo("testdata1");   
(it will create a new collection with exact no of records
Because copyTo() uses eval internally, the copy operations will block all other operations on the mongod  instance). 

12. Update single document in collection
db.%collection_name%.update( { “search_key” : “search_value” }, { $set : { “update_key” : “update_value” } } )
db.testdata.update({“x”:2}),{$set:{“x”:”300”}})

13. Update Multiple documents in collection 
Db%collection.name%.update({"search_key":"search_value"},{$set:{"update_key":"update_value"}},{"multi":true})
db.testdata.update({"x":3},{"x":"200"}},{"multi":true})

14. Delete document(records) from collection 
db.%collection_name%.remove( { “search_key” : “search_value” } )

db.testdata.remove({"x":2,"x1":100});

15. List all index for a database 
db.system.indexes.find()

16 . List all index in collection 
db.testdata.getIndexes()



Wednesday, April 16, 2014

Delete or restore a Google Account

Delete or restore a Google Account
Deleting your Google Account will affect all products associated with that account. For example, if you use Gmail with your account, you'll no longer be able to access that email. You'll also be unable to reuse your Gmail username. Before deleting your account, review the data and products associated with your account on the Google Dashboard.
Delete a Google Account
1.     Sign in on the Google Accounts homepage. If you forgot your password, you can reset it.


2.     Click Data tools at the top.

3.     In the Data tools box, click Delete account and data. If you don't see this link near the bottom of the page, your account may have been created through an organization or company which requires different steps for deletion.


4.     Confirm your account deletion. To do so, you'll need to select these two options:
o    "Yes, I want to delete my account."
o    "Yes, I acknowledge that I am still responsible for any charges incurred due to any pending financial transactions."
o    Please confirm this by entering your password. and enter current password

You can safely select the latter option if you haven't used any of Google's paid products, such as Ad Words and Wallet, or if you have no pending financial transactions related to these products.
5.     Click on submit button

Restore a Google Account
If you accidentally deleted your Google Account, you have a short amount of time to try and recover it:
1.     Go to our password assistance page.

2.     Select "I don't know my password."
3.     Enter the last password that you remember

4.     Follow the steps until you see a link to verify your identity.
5.     Click the link to fill out the form.



Step By Step explanation of How to hide UR hard disk OR lock UR Hard drivers

Step By Step explanation of How to hide UR hard disk OR lock UR Hard drivers


1.    Go to run command and type in gpedit.msc


2.    This command will not gonna work on home vista, 7 and 8 and home premium. ( perform well in win 7 ultimate well). Click on gpedit.msc . A Local group  policy editor window  will open up .

3.    Click on User Configuration >> Administrative templates >>windows components >> windows explorer


4.    Click on hide these specific drives in my computer  and  click right click and hit on edit



5.    Click enabled and select drop down box choose any one of the options and click on Apply . This option will only hide ur drive in my computer. But it could be still accessible from URL .

6.    IF  anyone want to prevent/ restrict access from particular drives in my computer then click on windows explorer >>Prevent access to drives from my computer .


7.    Right click and click on edit and choose from drop down and click on apply .





Tuesday, April 15, 2014

TOP 10 ADDONS IN FIREFOX

TOP 10 Addons In Firefox which are widely used -


 1 . YouTube Audio & Video          Downloader



Downloads YouTube videos in all available formats (FLV, MP4, WebM, and 3GP) with video quality of your choice. It also contains a pure JavaScript library to extract the ORIGINAL audio file out of FLV videos. It optionally downloads subtitles as well! 


2. Anonymous Proxy  

Easy anonymous web browsing.
– Change your IP-Address and country
– Visit blocked or censored websites.
– Delete cookies, show your public ip, and more

No proxies or other programs required


Download Link 


3. FireBUG    

Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page...


4.Ad blocker   

 Blocks annoying video ads on YouTube, Facebook ads, banners and much more.Adblock Plus blocks all annoying ads, and supports websites by not blocking unobtrusive ads by default (configurable).

 

5. Tamper Data 

Use Tamper Data to view and modify HTTP/HTTPS headers and post parameters.Trace and time http response/requests.
Security test web applications by modifying POST parameters.



6. Rest Client

RESTClient supports all HTTP methods RFC2616 (HTTP/1.1) and RFC2518 (WebDAV). You can construct custom HTTP request (custom method with resources URI and HTTP request Body) to directly test requests against a server

Download Link 


7. Clear Console


Clear Console addon provides options to clear your cookies, cache, history, html5/local storage, http logins, all of them or restart your browser in a single click

The addon also provides options to
- enable/disable notifications
- set preferences upon closing the browser


8. Json view


View JSON documents in the browser.