Thursday 25 July 2013

Twitter Card Validator - server error and automatic retry

I have been implementing Twitter Cards on our sites in last few days. I'm at the stage where everything is implemented however, I do need to get them validated and request for approval.

This you would think is the easiest part of entire development process - that's until you get "Server error, please try again." error and the only reply I have got from Twitter is "we know... keep trying".

So after retrying by hand few times I have decided that I have better things to do with my time; hence the script.

What it does?

  1. Every 10 seconds retry (push retry button).
  2. If you hit rate limiter wait for 10 turns (10 x 10 seconds)
  3. If you pick up that there is no error message then you are finished.

Warning: I have used this to validate some of my Twitter Cards, however I do not give any guarantee that this will work for you and not block your twitter account or cause any other damage.

var tries = 0;
var rateLimit = 10;
var int=self.setInterval(function(){
var button = $("div.icon-refresh");
if(button.length>0){
 var error = $("span.error-label-text:contains('Server error'):visible");
 var rateLimiter = $("span.error-label-text:contains('Rate')");
 
 // Retry function
 var retryNow = function(){
  button.click();
  tries++;
  
  console.log("Attempt: "+tries);
 }
 
 if(error.length>0){
  retryNow();
  
  if(rateLimit <= 0){
   rateLimit = 10;
   console.log("Rate limiter reset to 10 seconds");
  }
 }else if(rateLimiter.length>0){
  console.log("Rate limiter - wait for " + rateLimit + " seconds");
  rateLimit--;
 }else{
  // Final check for any errors
  if($("span.error-label-text:visible").length==0){
   console.log("Success!");
  }else{
   console.log("Another error detected re-trying anyway!");
   retryNow();
  }
 }
}
},10000);


Requirements

  1. Twitter Account
  2. Chrome / Firefox with Firebug
Figure 3.1

Steps

  1. Open your browser (Chrome is my browser of choice) 
  2. Go to URL https://dev.twitter.com/docs/cards/validation/validator
    1. Figure 6.1
      Figure 7.3
    2. It might require you to log in, so use your twitter account and login then use the URL to login again.
  3. Pick a card from "Card Catalog" once the page loads. (See Figure 3.1)
  4. Select "Validate & Apply" tab
  5. Enter your site's URL
  6. Wait for "Error to show up" (See Figure 6.1)
  7. Now we are set for running the script
  8. Figure 7.6
    1. Right click the page and select "Inspect Element"
    2. Development tools will appear at the bottom of the page.
    3. Go to the Console tab
    4. Copy / Paste script from above to the console.
    5. Press Enter to start retry.
    6. See figure 7.6 for example output.
    7. Figure 7.7
    8. Once its validated you will get success message. (See figure 7.7)

Wednesday 24 July 2013

Installing EPiServer 6 R2 on Windows 8

Great step by step guide on how to bypass some nasty error messages (that aren't actually errors) while installing EPiServer 6 R2 on Windows 8 machine.

Thanks Paul!

http://dotnetcake.blogspot.com.au/2012/06/installing-episerver-6-r2-on-windows-8.html

Tuesday 23 July 2013

Creating a branch out of your pending changes on Trunk in TFS

I have been working on our Trunk branch when I have been told that my changes aren't going to be in this release. Luckily I haven't checked in, however I wanted to move all my stuff onto a separate branch so I can do my daily check-ins as per usual.

This is very easily solvable in SVN, however in wold of TFS not so much.

After some Googling I found this:
Unshelve changes onto another location
It is a very good guide however it misses some vital steps.

  1. Create a shelve out of your pending changes.
    1. Open your pending changes.
    2. Click Shelve (make sure you tick all files you want to move across). Make note of shelve name.
    3. Now you will need to do a full backup of your code in form of another shelve set.
    4. This time create shelve but check all files.
  2. You will be required to revert all your changes on branch/trunk that you have just used to create shelve. (You can also create a physical folder copy if you really worried about loosing your changes).
    Note: Without this step (ie. changes still pending on trunk) power tools wouldn't un-shelve to my new branch.
    1. Open your pending changes.
    2. Select all files
    3. Right click and select Undo...
    4. Make sure that there are no pending changes.
  3. Create another branch based.
    1. Right click your current branch and select "Branching and Merging"
    2. Select "Branch"
    3. Name it accordingly.
  4. Follow guide on Unshelve changes onto another location to restore to newly created branch.
I hope that works for you!