Skip to content

Instantly share code, notes, and snippets.

// Testing DOM performance
(function (depth, width, tag, tag2) {
console.log('Tree depth: ' + depth);
console.log('Children per level ' + width);
console.log('Tag to build tree with ' + tag);
console.log('Replacement tag ' + tag2);
console.time('maketree');
var starttree = (function makeTree(depth, width, root, tag) {
if (depth == 0) {
@shubhadeep
shubhadeep / UI5BindingInlinevsNamedFunctions.js
Created August 5, 2014 13:56
Comparison of binding SAPUI5 button actions as in-line functions (closures) vs. binding the same instance (by function name). Compare the memory heap profile to see the difference in both cases.
/**
* Comparison of binding button actions as inline functions (closures)
* profile to see the difference in both cases.
* vs. binding the same instance (by function name). Compare the memory heap
*/
// Bind function expression (closure) - 1M times
(function (numButtons) {
var btn = new sap.m.Button({text: "hello"});
for(var i = 0; i < numButtons; i++) {
@shubhadeep
shubhadeep / OpenUI5InitBookmarklet.js
Created August 5, 2014 14:07
This is a bookmarklet you can add to your browser bookmarks to boostrap OpenUI5 into the current browser tab. It also removes whatever is present in the document head and body.
javascript:(function () {
var body = document.body.parentElement.replaceChild(document.createElement('body'), document.body);
var head = document.head.parentElement.replaceChild(document.createElement('head'), document.head);
var bootstrap = document.createElement('script');
bootstrap.setAttribute('src', 'https://openui5.hana.ondemand.com/resources/sap-ui-core.js');
bootstrap.setAttribute('id', 'sap-ui-bootstrap');
bootstrap.setAttribute('data-sap-ui-theme', 'sap_bluecrystal');
bootstrap.setAttribute('data-sap-ui-libs', 'sap.m');
document.head.appendChild(bootstrap);
document.body.setAttribute('id', 'content');
@shubhadeep
shubhadeep / ObjectCreationPerformance.js
Created August 8, 2014 09:51
Creating empty objects in different ways and checking execution time, heap size etc.
/**
* Creating empty objects in different ways and checking execution time, heap size etc.
*/
// Property-less object
console.time('zoop');
var zoop = (function (numObjects) {
var pooz = Object.create(null);
for(var i = 0; i< numObjects; i++) {
pooz[i] = Object.create(null);
@shubhadeep
shubhadeep / TreeTableTest.js
Created January 8, 2015 09:18
OpenUI5 Tree Table Test
// OpenUI5 Tree Table Test binding to OData Model
(function (serviceUrl, entitySet, navigationProperty, label, propertyBindingPath) {
var tt = new sap.ui.table.TreeTable({
columns: [
new sap.ui.table.Column({
label: label,
template: new sap.m.Label({text: propertyBindingPath})
})
]
@shubhadeep
shubhadeep / webdavclient.py
Created September 18, 2015 17:53
Python WebDAV Client
import os, sys, requests
from lxml import objectify, etree
WEBDAV_STATUS_CODE = { # See http://tools.ietf.org/html/rfc4918
'OK' : 200,
'CREATED' : 201,
'NO_CONTENT' : 204,
'MULTI_STATUS' : 207,
'NOT_FOUND' : 404,
'METHOD_NOT_ALLOWED' : 405,