Pages

Wednesday, July 17, 2013

Web Development/Jquery/Javascript-Set a menu Link "selected" class if its href matches page url

Here is a simple js code with HTML to set a "seected" class to menu item when its corresponding page is open.

 <dl class="sidebarBox">  
   <dt>Mailboxes</dt>  
   <dd>  
     <ul class="mailbar">  
       <li><a href="inbox"><b>Inbox</b></a></li>  
       <li><a href="sent">Sent</a></li>  
       <li><a href="trash">Trash</a></li>  
     </ul>  
   </dd>  
 </dl>  
 <script type="text/javascript">  
   var winpath=window.location.pathname;  
   $(".mailbar li a").each(function(index)  
   {  
     var menupath=$(this).attr('href');  
     if(menupath==winpath)  
       $(this).parent().addClass("current");  
     else  
       $(this).parent().removeClass("current");  
   });  
 </script>  

Paypal-Authorization Error 1002

While integrating Paypal I was receiving an authorization error 1002

My NVP header string all the things except paymentaction which can be selected based needs from following url

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECSettlements

Other things needed for header string are

API_USERNAME
API_SIGNATURE
API_ENDPOINT
SUBJECT
PAYPAL_URL
Paymentaction

I used it as "Sale" as mine was a case of st right forward sale

If you are receiving a  result as follows

Array
(
    [TIMESTAMP] => 2013-06-22T10:06:14Z
    [CORRELATIONID] => 5xc75ssx3d7e2
    [ACK] => Success
    [VERSION] => 65.1
    [BUILD] => 6454311
    [AMT] => 23.00
    [CURRENCYCODE] => USD
    [AVSCODE] => X
    [CVV2MATCH] => M
    [TRANSACTIONID] => 9T29872102086351Q
)

then payment is processed successfully

Amazon S3-RequestTimeTooSkewed The difference between the request time and the current time is too large

Recently while working on a Project which had a hosting on Amazon Cloudfront, Storage on S3 and Streaming from Amazon EC2.I came across an issue which went ok initially but became a 2 day R&D Topic for my team after a server shutdown and Reset...

While requesting bucket I got a strange error from Amazon

"RequestTimeTooSkewed The difference between the request time and the current time is too large"

I checked everything from security credentials to bucket name finally going to Amazon Support where I came to knew that i was the fault of my system clock.

Our Systems must sync to NTP-Network Time Protocol in order to sync with Amazon Cloud Services..

My server

Centos which is redhat/suse based

Here is how i resolved the same

First and foremost I installed ntp again to be on safer side and make sure every stone in path was carved to needs

Install NTP
Yum install ntp

Check from config NTP is On
Chkconfig ntpd on

If everything is going well without any warnings till now its time to finalize

Sync Server time with amazon ntp

You have to check by trying to access your bucket and adding file to it after each and every sync with following servers..its like hit and try depending on your region.

ntpdate -u 0.amazon.pool.ntp.org
ntpdate -d 0.amazon.pool.ntp.org

ntpdate -u 1.amazon.pool.ntp.org
ntpdate -d 1.amazon.pool.ntp.org

ntpdate -u 2.amazon.pool.ntp.org
ntpdate -d 2.amazon.pool.ntp.org

ntpdate -u 3.amazon.pool.ntp.org
ntpdate -d 3.amazon.pool.ntp.org

That's it that solved my issue out

GIT Repository-Export only modified and added files with folder structure in Git

Recently I was working on a git repository setup on  my local and had a task of getting all the modified and changed files in a tar.(Remember I had not committed my changed files).Even if you have you can use the corresponding commit id to get list of changed files in that commit

Here is the command I used to extract modified and added files in a GIT repository


 git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $commit_id | xargs tar -rf mytarfile.tar