Monday, 20 March 2023

mocker data generator using nodejs

 fake data generator using node.js

 synthetic data generation using nodejs

Help link

https://www.npmjs.com/package/mocker-data-generator

https://chancejs.com/


https://phaker.js.org/


https://fakerjs.dev/



test_data_generator.js

var mocker = require('mocker-data-generator').default // (vanilla way)
const { faker } = require('@faker-js/faker');

var users = {
firstName: {
faker: 'name.firstName()'
},
lastName: {
faker: 'name.lastName()'
},
country: {
faker: 'address.country()'
},
city: {
faker: 'address.city()'
},
// description: {
// faker: 'lorem.paragraph()'
// },
createdAt: {
faker: 'date.past()'
},
id: {
incrementalId: 0
},
age: {
faker: 'datatype.number({"min": 18, "max": 30})'
//faker: 'random.numeric(2,{"min": 1, "max": 17})'
},
birthdate:{
faker:'date.birthdate({ "min": 10, "max": 20, "mode": "age" })'
},
user_group:{
values:
['Primary Owner', 'Owner', 'Admin','Editor','Contributor','Viewer','Billing']
},
emails:
{
faker: 'internet.email()'
}
,
// emails: [
// {
// faker: 'internet.email()',
// length: 1
// }
// ],
username: {
function: function () {
return (
this.object.lastName.substring(0, 5) +
this.object.firstName.substring(0, 3) +
Math.floor(Math.random() * 10)
)
}
},
phone_number:{
faker:"phone.number('+91 97 ### ### ##')"
},
account_balance:{
faker:"finance.amount()"
},
currencyCode:{
faker:'finance.currencyCode()'
},
account_number:{
faker:'finance.account()'
},
accountName:{
faker:'finance.accountName()'
},
creditCardCVV:{
faker:'finance.creditCardCVV()'
},
creditCardIssuer:{
faker:'finance.creditCardIssuer()'
},
creditCardNumber:{
faker:"finance.creditCardNumber('63[7-9]#-####-####-####')"
},
last_login_ip4:{
faker:"internet.ipv4()"
},
last_login_ip6:{
faker:"internet.ipv6()"
},
get: {
function() {
return this.object.emails[0]
}
}
}


var house = {
id: {
incrementalId: 0
},
address: {
faker: 'address.streetAddress'
},
householder: {
hasOne: 'users'
},
// mateIds: {
// hasMany: 'users',
// max: 2,
// min: 2,
// unique: true
// }
};

console.time('bench')
mocker()
.addGenerator('faker', faker)
.schema('users', users, 10)
.schema('cat2', users, { uniqueField: 'user_group' })
.schema('houses', house, 5)
.build(function (err, data) {
console.log(err)
console.timeEnd('bench')
console.log(JSON.stringify(data));
})


package.json
{
"name": "mocker-data-generator",
"version": "1.0.0",
"dependencies": {
"ava": "^5.1.0",
"casual-browserify": "^1.5.19",
"chance": "^1.1.7",
"codecov": "^3.8.2",
"conventional-github-releaser": "^3.1.5",
"gh-pages": "^4.0.0",
"http-server": "^14.1.1",
"mocker-data-generator": "^3.0.1",
"multiview": "^3.0.1",
"npm-scripts-info": "^0.3.9",
"nyc": "^15.1.0",
"opn-cli": "^5.0.0",
"phaker.js": "^6.0.0-rc.1",
"prettier": "^2.8.1",
"randexp": "^0.5.3",
"standard-version": "^9.5.0",
"trash-cli": "^5.0.0",
"ts-node": "^10.9.1",
"tslib": "^2.4.1",
"tslint": "^6.1.3",
"tslint-config-standard": "^9.0.0",
"typedoc": "^0.23.23",
"typescript": "^4.9.4"
},
"devDependencies": {
"@faker-js/faker": "^7.6.0"
}
}

Tuesday, 14 February 2023

इस्लामिक आतंकवाद अफ्रीका में अपने अबतक के सबसे ऊपरी स्तरों पर हे

फ्रांसीसी आतंकवाद विरोधी दबाव में कमी ने सलाफी-जिहादी उग्रवादियों को आंदोलन की अधिक स्वतंत्रता दी है। माली में फ्रांसीसी आतंकवाद विरोधी अभियान अंततः साहेल में सलाफी-जिहादी विद्रोह को समाप्त करने में विफल रहा। यह मुख्य रूप से इसलिए है क्योंकि फ़्रांस और  अमरीका इस वख्त रिसेशन से गुजर रहे हे और उक्रेन युद्ध में भी काफी संसाधन खर्च कररहा हे  फिर भी, फ्रांसीसी और यूरोपीय आतंकवाद विरोधी बलों ने कई आतंकवादी नेताओं को खत्म करने, उत्तरी मालियन शहरों की रक्षा करने में मदद करने और क्षेत्र में इस्लामिक स्टेट से संबद्ध होने के लिए पर्याप्त सैन्य दबाव डाला। मिशन के अंत ने जेएनआईएम और इस्लामिक स्टेट की साहेल शाखा दोनों का हौसला बढ़ाया है। इस्लामिक स्टेट के साहेल प्रांत के सदस्य—जिन्हें इस्लामिक स्टेट इन द ग्रेटर सहारा (आईएसजीएस) के रूप में भी जाना जाता है—दिसंबर 2022 में नए आईएस अमीर के प्रति वचनबद्ध होने पर बल के एक प्रदर्शन में पूर्वोत्तर माली में बड़ी संख्या में एकत्रित हुए। जेएनआईएम के अमीर, इयाद अग घाली ने 2023 में पूरे उत्तरी माली की यात्रा की और जनवरी में दो वर्षों में अपनी पहली सार्वजनिक उपस्थिति दर्ज की। 








वर्ल्ड में कई कंट्री और न्यूज़ एनालिस्ट जब भी अमरीका या कोई भी कंट्री इस्लामिक टेरोरिस्ट को मरने जाता हे तो पहले उसका विरोध करता हे। अमरीका और  फ्रांस जैसे कंट्री अपने पैसे और ससाधन इन कंट्री और को और भविष्य में आने वाली समस्या के लिए अभी से लड़ रहेहे। इस्लामी टेररिस्ट केवल लोगो को ही माररहे हे ऐसा नहीं हे बल्कि ये पर्यावरण और पशु समाज को भी नष्ट कर रहे हे। जब भी अमरीका और फ़्रांस या और कोईभी कंट्री इस्लामिक कंट्री या वॉर जोन से विथड्रो करती हे तब लोग उसका विरोध करते हे और उसे फेलियर कहते हे (जब की ये लोग जहा रहते हे वह का नातो इतिहास जानते हे और वर्तमान को समाज सकतेहै और भविष्य की तो इन्हे चिंता नहीं हे इस बात का अहंकार तो इन्हे पहलेसे ही हे और यह बात वो खुद ही जोर शोर से बताते हे )

फ्रांस की वापसी और इसके बाद के झटकों ने जेएनआईएम से जुड़े अन्य उत्तरी मालियन अभिनेताओं को भी प्रभावित किया है। उत्तरी माली में कई सशस्त्र तुआरेग समूह हैं, जिनमें से अधिकांश तीन सामान्य शिविरों में आते हैं: सलाफी-जिहादी उग्रवादी, पूर्व अलगाववादी विद्रोही और संघ समर्थक सशस्त्र समूह। इनमें से कई समूहों और उनके नेताओं का साझा मानव नेटवर्क का दशकों पुराना इतिहास है।  सलाफी-जिहादी समूहों और समर्थक अलगाववादी समूहों ने शुरू में 2012 में उत्तरी माली विद्रोह के एक ही पक्ष में लड़ाई लड़ी, इससे पहले कि 2013 में फ्रांसीसी नेतृत्व वाले हस्तक्षेप ने गैर-जिहादी विद्रोहियों को अग गली के अंसार अल दीन समूह से अलग करने में मदद की। अंतर्राष्ट्रीय समुदाय ने 2015 में विभिन्न तुआरेग विद्रोहियों और मालियन सरकार के बीच एक समझौते की सुविधा प्रदान की, जो काफी हद तक लागू नहीं हुआ है। हालांकि, औपचारिक दूरी के बावजूद अग घाली ने पूर्व विद्रोही नेटवर्क के साथ संपर्क बनाए रखा है।

एक जेएनआईएम-नियंत्रित उत्तरी माली भी अंतरराष्ट्रीय आतंकी हमलों की साजिश रचने वाली कोशिकाओं का अड्डा बन सकता है। दीर्घकालिक सबसे खराब स्थिति में, जेएनआईएम इन पनाहगाहों का उपयोग अंतरराष्ट्रीय हमले की क्षमताओं को विकसित करने के लिए कर सकता है। पिछले पैटर्न से पता चलता है कि समूह तेजी से स्थानीय से अंतरराष्ट्रीय लक्ष्यों की ओर बढ़ सकते हैं और यह कि कई कारक स्थानीय समूहों को अंतरराष्ट्रीय हमलों का पीछा करने या समर्थन करने के लिए प्रेरित करते हैं। जेएनआईएम संभवत: अल्पावधि में अंतरराष्ट्रीय हमलों का पीछा नहीं करेगा, लेकिन समूह ने वैश्विक हमलों को प्रोत्साहित करना जारी रखा है और कभी भी बाहरी आतंकी हमले की साजिश रचने से इनकार नहीं किया है।

























Thursday, 24 November 2022

angular v15 directive ngFor handling empty list

 


// hello.component.ts


import { Component, Input } from '@angular/core';
import { NgForEmpty } from './ng-of-empty';

@Component({
selector: 'hello',
template: `<h1>Hello {{name}}!</h1>
<ul>
<li *ngFor="let p of persons; empty: emptyTmpl">{{p}}</li>
</ul>
<ng-template #emptyTmpl>Empty list</ng-template>
`,
styles: [`h1 { font-family: Lato; }`],
standalone: true,
imports: [NgForEmpty],
})
export class HelloComponent {
@Input() name: string;
persons = ['Dignāga','Dharmakīrti','Kamalaśīla','Śāntarakṣita',
             'Asanga','Vasubandhu'];
}


// ng-of-empty.ts



import { NgFor, NgIf } from '@angular/common';
import { Directive, inject, Input } from '@angular/core';

@Directive({
selector: '[ngFor]',
standalone: true,
hostDirectives: [
{ directive: NgFor, inputs: ['ngForOf'] },
{ directive: NgIf, inputs: ['ngIfElse: ngForEmpty'] },
],
})
export class NgForEmpty<T> {
private readonly ngIf = inject(NgIf, { host: true });

@Input() set ngForOf(ngFor: T[] | undefined) {
this.ngIf.ngIf = ngFor && ngFor.length > 0;
}
}




Sunday, 20 November 2022

Angular functional guard to check on the user role to guard your routes

functional guard to check on the user role  to guard your routes. 


The functional guard accepts a param for the user role 


Less verbose than a class based guard



    use canMatch to skip a route dynamically in combination with functional guards. 

  👍 Super handy when a path should lead to different comp depending on some logic 

  👋 canLoad is going to be deprecated in favor of canMatch


    


Saturday, 19 November 2022

Directive composition API in Angular 15

our directive stand alone by adding standalone property inside directive declaration 

import { Directive } from '@angular/core';

@Directive({
  selector: '[appRedColor]',
  host:{'style': 'color:red;'},
  standalone: true
})
export class RedColorDirective {

  constructor() { }

}

Now the text inside testdirective component will be displayed in red color.

<app-testdirective></app-testdirective>

And our code looks simple without adding an extra directive in component tag.

We can add more than one directive inside hostDirectives property.


@Component({
  selector: 'app-testdirective',
  templateUrl: './testdirective.component.html',
  styleUrls: ['./testdirective.component.scss'],
  hostDirectives:[RedColorDirective,HeightDirective,FontStyleDirective,......]
})
export class TestdirectiveComponent {
}

We can add hostDirectives inside an another directive as well.

Saturday, 15 October 2022

Reusable ng-template with parameters




<ng-template #loading let-overlayHeight="overlayHeight"
let-loaderLeft="loaderLeft" let-marginTop="marginTop">
<div class="overlay" [style.marginTop]="marginTop || ''"
[style.height]="overlayHeight || '100%'" style="position:relative;">
<div class="loader" [style.left]="loaderLeft || '40%'"
        style="position:relative;top:35%">
<svg viewBox="0 0 86 80">
<polygon points="43 8 79 72 7 72"></polygon>
</svg>
</div>
</div>
</ng-template>


Use

<ng-template *ngIf="paretoProductCategoriesChartLoading"
[ngTemplateOutlet]="loading"
[ngTemplateOutletContext]="{overlayHeight: '280px',marginTop:'20px'}">
</ng-template>

Create a common Html element within angular template.

Sunday, 17 July 2022

change label css when checkbox checked

 

<form>
<label>
<input type="checkbox">
Make this red when checked
</label>
</form>
<button>Make this red too!</button>

<style>
body:has([type="checkbox"]:checked) label,
body:has([type="checkbox"]:checked) button {
color: red;
}
</style>


change label css when checkbox checked

Saturday, 18 June 2022

ng-container with ngTemplateOutlet and ng-template with context variable

<div *ngIf="!multiOptionsChart.length" class="row">
<ng-container *ngTemplateOutlet="
chartBlock;
context: {
optionItem : options,
chartType:'single'
}">
</ng-container>
</div>

<div *ngIf="multiOptionsChart.length" class="row">
<div *ngFor="let optionItem of multiOptionsChart; let i = index">
<ng-container *ngTemplateOutlet="
chartBlock;
context: {
optionItem : optionItem ,
chartType:'multi'
}">
</ng-container>
</div>
</div>

<ng-template #chartBlock
let-optionItem="optionItem"
let-chartType="chartType">

<div class="graph-action">
your multi and single chart type common code
</div>

<ng-container *ngIf="chartType === 'multi'">
<span>chartType</span>
<span>: {{ chartType }}</span>
</ng-container>
<ng-container *ngIf="chartType === 'single'">
<span>single chartType</span>
<span>: {{ chartType }}</span>
</ng-container>
Name : {{ optionItem.name }}
</ng-template>


Monday, 13 June 2022

Debug websites in different browsers and devices and write their css media queries

 

 

        css media query for all devices

        https://simplecss.eu/


You can also test in diffrent device using this tool 

Download from    https://www.lambdatest.com/

    


   in Ubuntu  

    step 1 :     chmod a+x LTBrowser.AppImage

    step 2 for run :   ./LTBrowser.AppImage 
 

       

Example 13" Macbook Pro Retina
@media only screen and (max-width : 1600px) and (max-height : 2560px) {
}



Thursday, 2 June 2022

Vue Dynamic Directive Arguments and vue event binding

   Vue Dynamic Directive Arguments



  Vue Promise

  



 If you do not want the root element of a component to inherit attributes, you can set 

  inheritAttrs: false

in the component’s options



vue event shortcut

  


Tuesday, 31 May 2022

use memo in your angular component template function call

import { Component } from '@angular/core';

function hasDifferentArgs(prev: unknown[], next: unknown[]) {
if (prev.length !== next.length) return true;
for (let i = 0; i < prev.length; i++) {
if (!Object.is(prev[i], next[i])) return true;
}
return false;
}

function memo(fnToMemoize) {
let prevArgs = [{}];
let result;

return function (...newArgs) {
if (hasDifferentArgs(prevArgs, newArgs)) {
result = fnToMemoize(...newArgs);
prevArgs = newArgs;
}
return result;
};
}

function expensiveComputing(name: string) {
return '$' + name + '$';
}

@Component({
selector: 'my-app',
template: 'Hello, {{fancyName(name)}}!',
})
export class AppComponent {
name = 'World';

fancyName = memo((name) => expensiveComputing(name));
}


Monday, 23 May 2022

how to disable anydesk autostart in ubuntu

 I've found the following approach to disable the AnyDesk service. In this way, you can run it manually.


systemctl disable anydesk.service

You can also check its service status:


systemctl status anydesk

nb: you might want to stop it first (or after) if it is running:


  service anydesk stop