Skip to content

Instantly share code, notes, and snippets.

Owais Akbani oakbani

  • Pakistan
Block or report user

Report or block oakbani

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View py_list_shallow_deep_cp.py
# 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]
@oakbani
oakbani / credit_card_16_digit_random_generator.py
Last active Apr 24, 2018
Credit Card 16-digit Random Number Generator
View credit_card_16_digit_random_generator.py
# 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):
@oakbani
oakbani / multiLineEllipsis.js
Last active Jan 28, 2016
A method in plain Javascript to implement multi-line text-overflow:ellipsis effect.
View multiLineEllipsis.js
/**
* 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) {
You can’t perform that action at this time.