The Time Module in Python

Mohd Mohtashim
Updated on 29-Jan-2020 11:08:47

488 Views

There is a popular time module available in Python which provides functions for working with times and for converting between representations. Here is the list of all available methods −Sr.NoFunction with Description1time.altzoneThe offset of the local DST timezone, in seconds west of UTC, if one is defined. This is negative if the local DST timezone is east of UTC (as in Western Europe, including the UK). Only use this if daylight is nonzero.2time.asctime([tupletime])Accepts a time-tuple and returns a readable 24-character string such as 'Tue Dec 11 18:07:14 2008'.3time.clock( )Returns the current CPU time as a floating-point number of seconds. To measure computational ... Read More

Minimize Number of Used Bins in C++ for Bin Packing Problem

Arnab Chakraborty
Updated on 29-Jan-2020 11:08:42

4K+ Views

In case of given m elements of different weights and bins each of capacity C, assign each element to a bin so that number of total implemented bins is minimized. Assumption should be that all elements have weights less than bin capacity.ApplicationsPlacing data on multiple disks.Loading of containers like trucks.Packing advertisements in fixed length radio/TV station breaks.Job scheduling.ExampleInput: weight[] = {4, 1, 8, 1, 4, 2} Bin Capacity c = 10 Output: 2 We require at least 2 bins to accommodate all elements First bin consists {4, 4, 2} and second bin {8, 2}Lower BoundWe can always calculate a lower ... Read More

Barabasi-Albert Graph for Scale-Free Models in C++

Arnab Chakraborty
Updated on 29-Jan-2020 11:00:00

310 Views

The Barabási-Albert model is treated as one of several proposed models that produce scale-free networks. It combines two important general concepts: growth and preferential attachment. Both concepts i.e. growth and preferential attachment have wide existence in real networks. The meaning of growth is that the number of nodes in the network increases over time.The meaning of preferential attachment is that the more connected a node is, the more chance it is to receive new links.Higher degree nodes have stronger ability to catch or grab links added to the network. Basically, the preferential attachment can be well understood if we think ... Read More

Balanced Expressions with Opening Brackets in C++

Arnab Chakraborty
Updated on 29-Jan-2020 10:57:50

225 Views

In case of a given integer m and an array of positions ‘position[]’ (1

Client-side Validation with HTML and without JavaScript

Krantik Chavan
Updated on 29-Jan-2020 10:53:36

301 Views

To display HTML5 client-side validation error bubbles, use the required attribute.You do not need to have javascript for client side validations like empty text box would never be submitted because HTML5 introduced a new attribute called required which would be used as follows and would insist to have a value:                    Enter email :          Try to submit using Submit button                    

Create Text Inside Circles in HTML5 Canvas

Nishtha Thakur
Updated on 29-Jan-2020 10:52:50

1K+ Views

To create a text inside circles in canvas, use the:context.beginPath();The following is the canvas:$("#demo").on("click", "#canvas1", function(event) {    var canvas = document.getElementById('canvas1');    if (canvas.getContext) {       var context = canvas.getContext("2d");       var w = 25;       var x = event.pageX;       var y = Math.floor(event.pageY-$(this).offset().top);       context.beginPath();       context.fillStyle = "blue";       context.arc(x, y, w/2, 0, 2 * Math.PI, false);       context.fill();       context = canvas.getContext("2d");       context.font = '9pt';       context.fillStyle = 'white';       context.textAlign = 'center';       context.fillText('amit', x, y+4);    } });HTML    

Completely Fill Web Page with HTML Canvas

V Jyothi
Updated on 29-Jan-2020 10:51:22

387 Views

To make canvas fill the whole page, you need to be 100% in width and height of the page.* {    margin: 0;    padding: 0; } body, html {    height:100%; } #canvas {    position:absolute;    height:100%; width:100%; }

Allow Restricted Resources from Another Domain in Web Browser with HTML5

Smita Kapse
Updated on 29-Jan-2020 10:50:07

314 Views

Cross-origin resource sharing (CORS) is a mechanism to allows the restricted resources from another domain in a web browserFor suppose, if you click on HTML5- video player in html5 demo sections. it will ask camera permission. if user allows the permission then only it will open the camera or else it doesn't open the camera for web applicationsHere Chrome, Firefox, Opera and Safari all use the XMLHttprequest2 object and Internet Explorer uses the similar XDomainRequest object, object.function createCORSRequest(method, url) {    var xhr = new XMLHttpRequest();    if ("withCredentials" in xhr) {       // Check if the XMLHttpRequest ... Read More

Validate the Size of Input File in HTML5

Govinda Sai
Updated on 29-Jan-2020 10:49:35

2K+ Views

You can try to run the following code to validate the size of input type file:                                                                                                   $(function(){                $('form').submit(function(){                   var val = true;                       $('input[type=file][data-max-size]').each(function(){                   if(typeof this.files[0] !== 'undefined'){                      var max = parseInt($(this).attr('max-size'),10),                      mySize = this.files[0].size;                      val = max > mySize;                      return val;                   }                });                return val;             });          });          

Autorun a Python Script on Windows Startup

Arnab Chakraborty
Updated on 29-Jan-2020 10:43:54

1K+ Views

Appending a Python script to windows start-up basically indicates the python script will run as the windows boots up. This can be accomplished by two step processes -Step #1: Appending or Adding script to windows Startup folderAfter booting up of the windows, it executes (equivalent to double-clicking) all the application present in its startup folder or directory.AddressC:\Users\current_user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\By default, the AppData directory or folder under the current_user is hidden that enable hidden files to get it and paste the shortcut of the script in the given address or the script itself. Besides this the .PY files default must be set ... Read More

Advertisements