Skip to content

Instantly share code, notes, and snippets.

View oakbani's full-sized avatar
🏠
Working from home

Owais Akbani oakbani

🏠
Working from home
View GitHub Profile
@oakbani
oakbani / multiLineEllipsis.js
Last active January 28, 2016 08:27
A method in plain Javascript to implement multi-line text-overflow:ellipsis effect.
/**
* 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) {
@oakbani
oakbani / credit_card_16_digit_random_generator.py
Last active April 24, 2018 00:08
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):
random.seed()
credit_card_num = []
for i in range(4):
# 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]