Skip to content

Instantly share code, notes, and snippets.

View mohammad-haji's full-sized avatar
😉
:)

MH mohammad-haji

😉
:)
View GitHub Profile
getNestedValue = (data, _key) => {
let keys = ("data." + _key).split('.'),
nested = keys[0];
for (let i = 1; i < keys.length; i++) {
if (eval(nested) == null) {
nested = null;
break;
}
nested += "." + keys[i];
}
import {Pipe, PipeTransform} from "@angular/core";
/*
* Convert english number to persian number
* takes english string
* Usage:
* value | enToFaNumber
* Example:
* {{EnglishNumber|enToFaNumber}}
*/
/**
* remove duplicates from array object with specific key
* @param arr
* @param key
* @return {Array.<T>|*}
*/
export function removeDuplicates(arr, key) {
return arr.filter((obj, index, arr) => {
return arr.map(mapObj => {
return mapObj[key]
/**
* chunk array into specific chunks :)
* @param arr
* @param len
* @returns {Array}
*/
function chunkArray(arr, len) {
if (!Array.isArray(arr)) return [];
let chunks = [],
i = 0,
#!/bin/bash
: '
copy files from source directory into another directory by file index
@usage: ./cp.sh sourcePath targetPath
@example: ./cp.sh ./original/ ./cpfolder/
'
sourcePath=$1;
targetPath=$2;
if [[ (-z "$sourcePath") || (-z "$targetPath") ]];
then
@mohammad-haji
mohammad-haji / install.md
Last active September 17, 2019 04:29
npm install from public or private repos on GitHub or Bitbucket