Skip to content

Instantly share code, notes, and snippets.

Working from home

Owais Akbani oakbani

Working from home
  • Pakistan
View GitHub Profile
# Python List makes a shallow copy by default and doesn't copy-on-write.
list_a = [1,2,3]
list_shallow = list_a
print(list_a) # [1, 2, 3, 4]
print(list_shallow) # [1, 2, 3, 4, 5]
list_a = [1,2,3]
oakbani /
Last active Apr 24, 2018
Credit Card 16-digit Random Number Generator
# 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):
credit_card_num = []
for i in range(4):
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.