Skip to content

Instantly share code, notes, and snippets.

View mo7amd's full-sized avatar

Mohammed Khaleel mo7amd

View GitHub Profile
@mo7amd
mo7amd / Truncate.js
Last active January 21, 2021 13:56
Truncate method
export const formateToEllipses = (string = '', maxCharAtOneLine, maxLines) => {
const ellipses = '...';
const separator = ' ';
const words = string.split(separator);
let lineNum = 1;
const lines = [];
let line = '';
const addEllipses = str => str.substring(0, maxCharAtOneLine - 3) + ellipses;
const isLargerThanLine = word => word.length > maxCharAtOneLine;
const gotoNewLine = (isEllipses = false, initial = '') => {

Keybase proof

I hereby claim:

  • I am mo7amd on github.
  • I am mo7amd (https://keybase.io/mo7amd) on keybase.
  • I have a public key ASBnLvGmSe6Ru7zd3wBiYMf3WLDKVdSwEG1hGZyOyj5_Xgo

To claim this, I am signing this object:

@mo7amd
mo7amd / fb_userId_scraper.js
Last active March 9, 2019 13:21
scrap fb_user_ids and name from comments
function getIdsList () {
document.querySelectorAll('a.UFIPagerLink').forEach(el => el.click())
const idSelector = '.UFICommentAuthorWithPresence.img._8o._8s.UFIImageBlockImage';
const namesSelector = `${idSelector} img`;
const el = document.querySelectorAll(idSelector);
const names = document.querySelectorAll(namesSelector);
const ids = [];
el.forEach((auth, index) => {
const link = auth.getAttribute('data-hovercard');
const name = names[index].getAttribute('alt');
@mo7amd
mo7amd / JsonPaths.txt
Last active February 21, 2019 15:24
JsonPaths
data[?(@.firstName === 'Zee')] // find obj with firstName key = 'zee'
data[*]['key1','key2'] // get certain keys of object on all the data
@mo7amd
mo7amd / bash
Created October 17, 2018 13:02
run npm install on multiple dir once
find . -maxdepth 1 -mindepth 1 -type d -exec bash -c 'cd "$0"; npm i' {} \;
@mo7amd
mo7amd / getSubArraysOfSum.js
Last active August 1, 2020 04:21
Get all sub-arrays of array arr[] with sum k
/*
References:
==============
1: HTTPS://WWW.QUORA.COM/WHAT-IS-THE-RECURSIVE-SOLUTION-FOR-FINDING-ALL-SUBSETS-OF-A-GIVEN-ARRAY
2: HTTPS://WWW.IDESERVE.CO.IN/LEARN/GENERATE-ALL-SUBSETS-OF-A-SET-RECURSION
hellow world from emacs
*/
@mo7amd
mo7amd / add-to-map.js
Created December 21, 2017 00:01
implement add method to Map Object to handle collision when add different value to the same key.
// add method to Map object
Map.prototype.add = function (key, value){
// check first if the key has value if not just set the value to the key
if ( map.has(key)) {
let oldValue = map.get(key); // get old value
let tempArr = []; // create temp array to collect new and values together
/* check if old value is array or not to make the values on one array which make
iteration over it when get the value command excute easier
**/
oldValue.constructor === Array ? tempArr = oldValue : tempArr.push(oldValue);
$(function(){
var selected = 0;
$('.rating__stars i').click(function(){
selected = $(this).index();
});
$('.rating__stars i').hover(
function(){
var index = $(this).index();
for(var i=0;i<index;i++){
$('.rating__stars i').eq(i).css("color","#ff9800");
var offset = $('div.saudi-trader-nav__item__menu').offset();
$('element').css("top",-offset.top);
$('child').hide();
$('parent').mouseover(function(){
$(this).find('child').show();
anchor_hover();
}).mouseout(function(){
anchor_hover();
$(this).find('child').hide();
});