Skip to main content

Posts

Showing posts with the label javascript

How to update content through Google Sites API?

The code to insert document data works for Google sites but for update it fails. I tried below two calls 1 entry . setMediaSource ( ms ); gives following //IllegalArgumentException: Cannot set media source on entry with existing non-MediaContent 2 service . updateMedia ( new URL ( getContentFeedUrl ()), newAttachment ); give //com.google.gdata.util.InvalidEntryException,Invalid request URI service is sites service object, entry is attachment entry Finally the following code seems to work      MediaStreamSource ms = new MediaStreamSource(is, fileMimeType);      ContentQuery query = new ContentQuery(new URL(getContentFeedUrl()));      query.setFullTextQuery(filename);      ContentFeed contentFeed = service.getFeed(query, ContentFeed.class);      String strAttach;      for (AttachmentEntry entry : contentFeed.getEntries(AttachmentEntry.class))...

My most frequent typos

The following has been few interesting typos which have eaten away precious hours of human life ... 1. Using ( instead of { in django. I simply removed one of succeeding endif after reading enough documentation at http://www.djangobook.com/en/2.0/chapter04/ .The paged crossed over from "TemplateSyntax " error and the function bracket was staring in my eyes. 2. Using ##footer instead of #footer, finally firebug console helped me realize the flaw. 3. Using hr in closing angle tag brackets of html instead on h3. 4. Website address as http://carpoolkaro.appcpot.com Instead of "http://carpoolkaro.appspot.com" 5. Forgetting to put in html. Accordian is accordion in jquery, watch out for there are only O's in correct one. How do you feel when a typo engages you more than a girlfriend/spouse/sports?

some more javascript learning

1. Label : any javascript statement including loops, conditionals, curly brackets blocks etc., a. Break:label; will take you to safety of label block 2. The break will bring you out of loop and continue will take you to new iteration in loop skipping the lower block. Continue first goes to increment than to condition statement in for loop whereas in while loop it goes to condition test directly. 3. Scope chain - every execution context has it. At top level its global and if not found object is undefined. In nested it includes the function call objects. The search begins in lowest scope and spreads out. 4. Create objects -- use object literal (comma separated property name value in curly bracket). An empty {} will declare a placeholder for referring object. 5. Object.property=value; is identical to object[property]=value; The first is used when you know name of property beforehand. The second is used for dynamic creation of property names. a. Use double quotes when naming property ins...

learning and debugging javascript

Debugging Javascript 1. Use Firebug - a. There is a console output where in you can type statements like 2*3 and press ENTER. i. "\u03c0" press ENTER and see what comes. b. Console.log("what ever you want to dump in console") frees you from alert. c. Once you get a error in console window then restarting firefox helps 2. FireFox - Tools - Error console a. Repeat 1 a above and click on evaluate. b. "\xA9" press ENTER and see what comes. 3. Browser window location bar a. The place where you type http://dsteps.blogspot.com instead try i. Javascript:10%2 and press ENTER. ii. javascript:for (i=0,j=1,fib=j;fib ");} Other notable facts 1. Functions are values that can be manipulated like datatypes. Thus they can store in variables, arrays and objects and can pass around as parameters too. a. var sq = function(x){return x*x}; b. function sq(x){return x*x;} c. Pont a and b are same. 2. If you don’t initialize a var variable then its value is un...