Skip to content

Instantly share code, notes, and snippets.

View rjoydip-zz's full-sized avatar
💭
👨‍💻

Joydip Roy rjoydip-zz

💭
👨‍💻
View GitHub Profile
@rjoydip-zz
rjoydip-zz / filterJson.js
Last active February 26, 2017 05:58
Filter json data and take according to user want.
function filterJsonData(data,rules,take,callback){
var i = 0;
var _data = data;
var _newDataSet = [];
take = (take == undefined) ? _data.length : take;
while(i < take){
Object.keys(_data[i]).forEach(function(ele){
(rules.indexOf(ele) === -1) ? delete _data[i][ele] : false;
@rjoydip-zz
rjoydip-zz / randomGenerate.js
Last active February 28, 2017 10:38
Generate random word,list,paragraph,array,name
var wordList = [];
var alp = 'abcdefghijklmnopqrstuvwxyz'.split('');
var alpSymNum = alp.join('').concat('!@#$%^&*_+~0123456789');
var nameSet =[
"abandoned","able","absolute","adorable","adventurous","academic","acceptable","acclaimed","accomplished",
"accurate","aching","acidic","acrobatic","active","actual","adept","admirable","admired","adolescent",
"adorable","adored","advanced","afraid","affectionate","aged","aggravating","aggressive","agile","agitated",
"agonizing","agreeable","ajar","alarmed","alarming","alert","alienated","alive","all","altruistic","amazing",
"ambitious","ample","amused","amusing","anchored","ancient","angelic","angry","anguished","animated","annual",
var wordList = [];
const alp = 'abcdefghijklmnopqrstuvwxyz'.split('');
const alpSymNum = alp.join('').concat('!@#$%^&*_+~0123456789');
var countryJson = [
{"name":"Israel","dial_code":"+972","code":"IL"},
{"name":"Afghanistan","dial_code":"+93","code":"AF"},
{"name":"Albania","dial_code":"+355","code":"AL"},
{"name":"Algeria","dial_code":"+213","code":"DZ"},
{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},
@rjoydip-zz
rjoydip-zz / graphQlToJSON.js
Created April 3, 2017 02:36
This is for converting graphql like schema to json format
/*
Input
========
{
empireHero:{
name
}
jediHero:{
name
}
function array_chunk(array, chunkSize) {
return [].concat.apply([],
array.map(function(elem, i) {
return i % chunkSize ? [] : [array.slice(i, i + chunkSize)];
})
);
}
app.directive('scrollToTop', function() {
return {
restrict: 'EA',
scope: { setFn: '&' },
link: function(scope, elem, attrs, ctrl) {
scope.$on('scroll', function(event) {
elem[0].scrollTop = elem[0].scrollHeight;
})
}
}
app.directive('imageExists', ['$http', 'IMAGE',
function($http, IMAGE) {
return {
restrict: 'EA',
link: function(scope, elem, attrs, ctrl) {
$http({
method: "GET",
url: attrs.src || attrs.ngSrc
}).then(function mySuccess(response) {
.directive('imageSwap', [function() {
return {
restrict: 'EA',
link: function(scope, elem, attrs, ctrl) {
var profileMainImage = [];
var innerHtml = attrs.src;
var id = attrs.id;
if (id) {
elem.bind('click', function() {
profileMainImage['alt'] = attrs.videoUrl;
@rjoydip-zz
rjoydip-zz / microo-example.js
Last active September 29, 2018 12:43
My first little experimented micro application
'use strict';
const microo = require('../lib/microo');
let microoApp = microo((err, res) => {
if (err) { throw err; }
console.log(res);
});
/*****************************************************************/
// Example 1
'use strict';
let merge = function (){
let _obj = {};
const argv = Array.prototype.slice.call(arguments);
argv.map(function(item){
const key = Object.keys(item);
key.map(function(newKey){
Object.defineProperty(_obj, newKey, {
value: item[newKey],