Shohel’s Developer MindScape
Monday, 16 September 2019
Tuesday, 2 July 2019
Monday, 24 June 2019
Top 10 tips and tricks for React
The beginner's collection of powerful tips and tricks for React
Name your components No matter how you expose your component, name it Prefer functional components Replace divs with fragments Be careful while setting state Binding component functions Adopt container pattern (even with Redux) Server rendering InternationalizationFind more about https://www.freecodecamp.org/news/the-beginners-collection-of-powerful-tips-and-tricks-for-react-f2e3833c6f12/
Friday, 5 April 2019
Top 10 standard typescript guideline
Top 10 standard typescript guideline
1. TypeScript StyleGuide and Coding Conventions
Link2. Coding guidelines
Link3. TypeScript Style Guide
Link4. Excel Micro TypeScript Style Guide
Link5. Typescript Best Practices
Link6. Do's and Don'ts
Link7. Five tips I wish I knew when I started with Typescript
Link8. clean-code-typescript
Link9. Typescript Guidelines
Link10. TSLint core rules
LinkTuesday, 12 March 2019
The Ultimate Template Syntax in Angular
The Angular application oversees what the client sees and can do, accomplishing this through the connection of a segment class occasion (the segment) and its client confronting layout. Many code scraps outline the focuses and ideas, every one of them accessible in the Template Syntax Live Code
https://stackblitz.com/edit/angular-ultimate-template-syntax
Thursday, 14 February 2019
All About JavaScript Arrays
How to merge two arrays in JavaScript and de-duplicate items
var array1 = ["Shohel","Rana"]; var array2 = ["Shipon", "Shohel"]; let noDuplicate = array1.filter ( i => array2.findIndex(a => i==a)==-1 ); let result = [...noDuplicate, ...array2]; console.log(result);
JavaScript Array splice vs slice
var array=[1,2,3,4,5]; console.log(array.splice(2)); This will return [3,4,5]. The original array is affected resulting in array being [1,2]. var array=[1,2,3,4,5] console.log(array.slice(2)); This will return 3,4,5. The original array is NOT affected with resulting in array being [1,2,3,4,5]. var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; var removed = array.splice(2,2); var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; for( var i = 0; i < array.length-1; i++){ if ( array[i] === 5) { arr.splice(i, 1); } } //=> [1, 2, 3, 4, 6, 7, 8, 9, 0] var elements = [1, 5, 5, 3, 5, 2, 4]; for(var i = elements.length -1; i >= 0 ; i--){ if(elements[i] == 5){ elements.splice(i, 1); } }
JavaScript pushing element at the beginning of an array
TheArray.unshift(TheNewObject);
Remove Elements from End of a Array in JavaScript
var ar = [1, 2, 3, 4, 5, 6]; ar.length = 4; // set length to remove elements console.log( ar ); // [1, 2, 3, 4]
Remove Elements from End of a Array using pop in JavaScript
var ar = [1, 2, 3, 4, 5, 6]; ar.pop(); // returns 6 console.log( ar ); // [1, 2, 3, 4, 5]
Remove Elements from Beginning of a Array in JavaScript
var ar = ['zero', 'one', 'two', 'three']; ar.shift(); // returns "zero" console.log( ar ); // ["one", "two", "three"]
Remove Element by Array filter Method
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; var filtered = array.filter(function(value, index, arr){ return value > 5; }); //filtered => [6, 7, 8, 9] //array => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
Remove Elements by Delete Operator in JavaScript Array
var ar = [1, 2, 3, 4, 5, 6]; delete ar[4]; // delete element with index 4 console.log( ar ); // [1, 2, 3, 4, undefined, 6] alert( ar ); // 1,2,3,4,,6
Clear or Reset a JavaScript Array
var ar = [1, 2, 3, 4, 5, 6]; //do stuff ar = []; or ar.length = 0; //a new, empty array! var ar = [1, 2, 3, 4, 5, 6]; console.log(ar); // Output [1, 2, 3, 4, 5, 6] ar.splice(0, ar.length); console.log(ar); // Output []
Insert an item into an array at a specific index (JavaScript)
var arr = []; arr[0] = "Jani"; arr[1] = "Hege"; arr[2] = "Stale"; arr[3] = "Kai Jim"; arr[4] = "Borge"; console.log(arr.join()); arr.splice(2, 0, "Lene"); console.log(arr.join());
Array sort and reverse in Java Script Array
var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.sort(); // First sort the elements of fruits fruits.reverse(); // Then reverse the order of the elements
Array Extension
//delete object //split javascript object Array.prototype.spliceObject = function (sourceToRemove) { //Remove the deleted entry from list var index = this.indexOf(sourceToRemove); if (index != -1) { // Make sure the value exists this.splice(index, 1); } return index; }; // calling arrayList.spliceObject(entity); Array.prototype.spliceObjectByID = function (id) { //Remove the deleted entry from list var index = this.map(function (x) { return x.id; }).indexOf(id); if (index != -1) { // Make sure the value exists this.splice(index, 1); } return index; }; // calling arrayList.spliceObject(entity.id); //array move //move up move(array, element, -1); //move down move(array, element, 1); Array.prototype.arrayMove = function (element, delta) { var index = this.indexOf(element); var newIndex = index + delta; if (newIndex < 0 || newIndex == this.length) return; //Already at the top or bottom. var indexes = [index, newIndex].sort(function (a, b) { return a - b; }); //Sort the indixes this.splice(indexes[0], 2, this[indexes[1]], this[indexes[0]]); //Replace from lowest index, two elements, reverting the order return; };
Find the Highest (or Lowest) Array Value
//Sorting ascending: var points = [40, 100, 1, 5, 25, 10]; points.sort(function(a, b){return a - b}); // now points[0] contains the lowest value // and points[points.length-1] contains the highest value //Sorting descending: var points = [40, 100, 1, 5, 25, 10]; points.sort(function(a, b){return b - a}); // now points[0] contains the highest value // and points[points.length-1] contains the lowest value
Java Script Array Clone
https://e2ecode.blogspot.com/2013/12/array-clone-in-java-script.html
Sunday, 27 January 2019
How to Start Angular 7 Step by Step
What is Angular?
Angular is one of the JavaScript framework that helps developers to build smaller to large scale applications of mobile, web and desktop. Angular library provides a series of features that make it trivial to implement the complex requirements of modern applications, such as data binding, routing, and animations. Angular is one of the only JavaScript libraries to provide a comprehensive style guide with a number of opinionated guidelines on how you could write your code with the framework.Installation
Prerequisites
Before starting of your Angular application, you may need some latest tools that are below. * [Nodejs] * [Git] * [Visual Studio Code] * [Angular CLI] For the CLI generated project, you need the Node 6.9.0 or higher.Downloading and Setting up
Download the prerequisites tools directly from the below link according to your operation system and install those tools. * [Nodejs] * [Git] * [Visual Studio Code] * [Angular CLI] After installing Nodejs, the node package manager (npm) should automatically be installed. > Test it out by doing: open terminal window and write the following command > `npm --version` After installing Git, the git package manager (git) should automatically be installed. > Test it out by doing: open terminal window and write the following command > `git --version` After installing Visual Studio Code, you can check the installed IDE from your start program menu. > Test it out by doing: open visual studio code IDE from start program menu.Install Angular CLI
Open terminal window and write the following command for global installation npm install -g @angular/cli _N.B: Internet connection is needed before doing this job._ Learn more....Tuesday, 25 September 2018
Hierarchical Query to Return All Children and Parent
--========Get all ancestor
;WITH cte AS (
SELECT dbTable.*
FROM dbTable
WHERE id = 100000200
UNION ALL
SELECT dbTable.*
FROM dbTable
INNER JOIN cte ON cte.ParentID = dbTable.id
)
SELECT * FROM cte
--========Get all successor
;WITH cte AS (
SELECT dbTable.*
FROM dbTable
WHERE id = 100000200
UNION ALL
SELECT dbTable.*
FROM dbTable
INNER JOIN cte ON dbTable.ParentID = cte.id
)
SELECT * FROM cte
Saturday, 24 March 2018
Saturday, 17 March 2018
Sunday, 14 August 2016
Print PDF directly from JavaScript
This question demonstrates an approach that might be helpful to you: Silent print a embedded PDF
It uses the <embed> tag to embed the PDF in the document:
<embed type="application/pdf" src="path_to_pdf_document.pdf" id="pdfDocument" width="100%" height="100%"> </embed>Then you call the .print() method on the element in Javascript when the PDF is loaded:
function printDocument(documentId) { var doc = document.getElementById(documentId); //Wait until PDF is ready to print if (typeof doc.print === 'undefined') { setTimeout(function(){printDocument(documentId);}, 1000); } else { doc.print(); } }You could place the embed in a hidden iframe and print it from there, giving you a seamless experience.
Friday, 20 May 2016
sql server change length of nvarchar column
declare @schema nvarchar(255)
declare @table nvarchar(255)
declare @col nvarchar(255)
declare @dtype nvarchar(255)
declare @sql nvarchar(max)
declare maxcols cursor for
select
c.TABLE_SCHEMA,
c.TABLE_NAME,
c.COLUMN_NAME,
c.DATA_TYPE
from
INFORMATION_SCHEMA.COLUMNS c
inner join INFORMATION_SCHEMA.TABLES t on
c.TABLE_CATALOG = t.TABLE_CATALOG
and c.TABLE_SCHEMA = t.TABLE_SCHEMA
and c.TABLE_NAME = t.TABLE_NAME
and t.TABLE_TYPE = 'BASE TABLE'
where
c.DATA_TYPE like '%varchar'
and c.CHARACTER_MAXIMUM_LENGTH = 500
open maxcols
fetch next from maxcols into @schema, @table, @col, @dtype
while @@FETCH_STATUS = 0
begin
set @sql = 'alter table [' + @schema + '].[' + @table +
'] alter column [' + @col + '] ' + @dtype + '(2000)'
exec sp_executesql @sql
fetch next from maxcols into @schema, @table, @col, @dtype
end
close maxcols
deallocate maxcols
Subscribe to:
Posts (Atom)