Found 448 Articles for Programming Scripts

Number.MAX_SAFE_INTEGER Property in JavaScript

Samual Sam
Updated on 25-Jun-2020 12:43:22

93 Views

The Number.MAX_SAFE_INTEGER property of the Number object represents the maximum safe integer in JavaScript (i.e. 253 - 1).SyntaxIts Syntax is as followsNumber.MAX_SAFE_INTEGERExample Live Demo    JavaScript Example           var result = Number.MAX_SAFE_INTEGER;       document.write("Maximum safe integer: " + result);     OutputMaximum safe integer: 9007199254740991

volatile keyword in C#

Samual Sam
Updated on 20-Jun-2020 17:21:20

588 Views

To reduce concurrency issues in C#, use the volatile keyword. Let us seen an example.The following is how you use a volatile keyword for public variable −class Program {    public volatile int a;    public void Program(int _a) {       i = _i;    } }Let us see another example: We have two static variables. Set them in a new method −_out = "Welcome!"; _new = true;We declared them as static before using volatile −static string _out; static volatile bool new;Now you need to run the method on a thread −new Thread(new ThreadStart(volatileFunc)).Start();Read the value of the ... Read More

Adding an element in an array using Javascript

Samual Sam
Updated on 15-Jun-2020 14:41:58

134 Views

Adding an element to an array can be done using different functions for different positions.Adding an element at the end of the arrayThis can be accomplished using the push method. For example, let veggies = ["Onion", "Raddish"]; veggies.push("Cabbage"); console.log(veggies);This will give the output −["Onion", "Raddish", "Cabbage"]You can also use this to push multiple items at the same time as it supports a variable number ofarguments. For example, let veggies = ["Onion", "Raddish"]; veggies.push("Cabbage", "Carrot", "Broccoli"); console.log(veggies);This will give the output −["Onion", "Raddish", "Cabbage", "Carrot", "Broccoli"]Adding an element at the start of the arrayThis can be accomplished using the unshift method. ... Read More

How to replace values of a Python dictionary?

George John
Updated on 15-Jun-2020 08:27:55

9K+ Views

You can assign a dictionary value to a variable in Python using the access operator []. For example,Examplemy_dict = {    'foo': 42,    'bar': 12.5 } new_var = my_dict['foo'] print(new_var)OutputThis will give the output −42This syntax can also be used to reassign the value associated with this key. For example,Examplemy_dict  =  {    'foo': 42,    'bar': 12.5 } my_dict['foo']  =  "Hello" print(my_dict['foo'])OutputThis will give the output −Hello

How can we combine multiple print statements per line in Python?

karthikeya Boyini
Updated on 05-Mar-2020 05:08:00

4K+ Views

You can combine multiple print statements per line using, in Python 2 and use the end argument to print function in Python 3.examplePython2.x print "Hello", print " world" Python3.x print ("Hello", end='') print (" world")OutputThis will give the output −Hello worldAnother thing you could do is put all the things in an array and call ''.join(array). examplearr = ["Hello", "world"] print(' '.join(arr))OutputThis will give the output −Hello world

What are Python coding standards/best practices?

Chandu yadav
Updated on 05-Mar-2020 05:03:45

501 Views

You can use the PEP8 guide as a holy grail. Almost all python world uses this guide to write clean understandable and standard python code. This is available as an extension as a linter for all modern text editors. You can check it out at  http://www.python.org/dev/peps/pep-0008/Properly Structure your folders. All projects need proper structuring. This helps organize code better. Python has an opinionated folder structure that you should use.README.rst LICENSE setup.py requirements.txt sample/__init__.py sample/core.py sample/helpers.py docs/conf.py docs/index.rst tests/test_basic.py tests/test_advanced.pyUse doctests. The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to ... Read More

How can we print multiple blank lines in python?

Samual Sam
Updated on 05-Mar-2020 05:02:36

2K+ Views

We can print multiple blank lines in python by using the character the number of times we need a blank line. For example, If you need 5 blank lines, you can use −Python 2.x: print "" Python 3.x: print("")You can use features like repetition operator in python to make this easier. For example,Python 2.x: print "" * 5 Python 3.x: print("" * 5)All of these commands will print 5 blank lines on the STDOUT.

Detect compatibility of the new HTML5 tag with jQuery.

Daniol Thomas
Updated on 29-Jan-2020 06:30:38

93 Views

Use the following to check the compatibility of the HTML5 tag :var $myEL = $(''); $myEL.appendTo('body'); var bgColor = $myEL.css('backgroundColor'); if (/rgb\(255\, 255\, 0\)/.test(bgColor))    return true; else    return false;

Using FFMPEG with HTML5 for online video hosting

Samual Sam
Updated on 30-Jul-2019 22:30:22

945 Views

HTML5 enabled browsers to have a video element that you can use to play a video on your site. To let you know, flowplayer and other flash based video streaming players use the FLV format. It has the same encoding as H.264. FFMPEG can convert videos to FLV, feel free to work it with flowplayer. Use the flvtool2 for reading and writing FLV metadata from and to the file. Use the tools to create your videos and stream them through flowplayer.

Difference between MessageChannel and WebSockets in HTML5

Smita Kapse
Updated on 30-Jul-2019 22:30:22

122 Views

Web Sockets is a next-generation bidirectional communication technology for web applications that operates over a single socket and is exposed via a JavaScript interface in HTML 5 compliant browsers. Once you get a Web Socket connection with the web server, you can send data from browser to server by calling a send() method, and receive data from server to browser by an onmessage event handler.Two way communication between the browsing contexts is called channel messaging. It is useful for communication across multiple origins.While creating messageChannel, it internally creates two ports to sending the data and forwarded to another browsing context. ... Read More

Advertisements