Snippets Collections
 */
function getRandomArbitrary(min, max) {
    return Math.random() * (max - min) + min;
}
job = {
	'title': title,
	'company': company,
	'salary': salary,
	'summary': summary
}

joblist.append(job)

print(*joblist, sep='\n')
# define strings
listOfPlaces = ["Berlin", "Paris", "Lausanne"]
currentCity = "Lausanne"

for place in listOfPlaces:
    print ("comparing %s with %s: %s" % (place, currentCity, place == currentCity))
this.XMLHelper = (new x_hca2_mh_intg.MHXMLUtils());

var responseBody = response.getBody();
var prettyXML = this.XMLHelper.prettifyXML(responseBody);


var MHXMLUtils = Class.create();
MHXMLUtils.prototype = {

    initialize: function() {
    },

    parseXMLNode: function (xml, node) {
        var xmlDoc = new XMLDocument2();
        xmlDoc.parseXML(xml);
        return (xmlDoc.getNodeText(node));
    },

    prettifyXML: function (xmlString) {
        var formatted = '';
        var reg = /(>)(<)(/)/g;
        xmlString = xmlString.replace(reg, '$1\r\n$2$3');
        var pad = 0;
        var nodes = xmlString.split('\r\n');
        nodes.forEach(function(node, index) {
            var indent = 0;
            if (node.match( /.+</\w[^>]>$/ ))
                indent = 0;
            else if (node.match( /^</\w/ )) {
                if (pad != 0) {
                    pad -= 1;
                }
            } else if (node.match( /^<\w[^>][^/]>.$/ ))
                indent = 1;
            else
                indent = 0;

            var padding = '';
            for (var i = 0; i < pad; i++)
                padding += '    ';

            formatted += padding + node + '\r\n';
            pad += indent;
        });
        return formatted;
    },

    type: 'MHXMLUtils'
};
star

Wed Jan 10 2024 07:57:26 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/1527803/generating-random-whole-numbers-in-javascript-in-a-specific-range

#kazem #print
star

Sun May 15 2022 06:41:38 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/13443588/how-can-i-format-a-list-to-print-each-element-on-a-separate-line-in-python

#python #print #list #newline
star

Thu Oct 07 2021 17:58:04 GMT+0000 (Coordinated Universal Time) https://stackabuse.com/comparing-strings-using-python/

#python #print
star

Fri Oct 23 2020 17:42:22 GMT+0000 (Coordinated Universal Time)

#prettyprint #xml #pretty #print #servicenow

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension