This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python List makes a shallow copy by default and doesn't copy-on-write. | |
list_a = [1,2,3] | |
list_shallow = list_a | |
list_shallow.append(4) | |
print(list_a) # [1, 2, 3, 4] | |
list_a.append(5) | |
print(list_shallow) # [1, 2, 3, 4, 5] | |
list_a = [1,2,3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This method generates a 16 digit random credit card number. | |
# If 'secure' flag is True, One of the four digits of every four digits, is replaced by a random Upper case letter. | |
import random | |
def generate_random_num(secure=False): | |
random.seed() | |
credit_card_num = [] | |
for i in range(4): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns shortened and appended text(with an ellipsis(optional)) to be rendered in dom if it will take more space than the dom's clientHeight and clientWidth | |
* It is recommended to set height/width, max height/max width, word-wrap:break-word of the element before calling this function | |
* | |
* {String} text: Text Content | |
* {dom Element} renderTo : The actual element where the text is to be rendered | |
* {Boolean} ellipsis: false if ellipsis is not to be appended to the end of the text | |
* @returns {String} returns the new truncated text | |
*/ | |
function truncateTextToFit (text, renderTo, ellipsis) { |