Posts

Showing posts with the label Typescript Example

Add List To Tuple Python Code Example

Example 1: python add to list list_to_add . append ( item_to_add ) # or list_to_add . push ( item_to_add ) Example 2: how to append list in python list1 = [ "hello" ] list1 = list1 + [ "world" ] Example 3: how to add number in tuple a = ( '2' , ) b = 'z' new = a + ( b , ) Example 4: how to add strings in tuple in python First , convert tuple to list by built - in function list ( ) . You can always append item to list object . Then use another built - in function tuple ( ) to convert this list object back to tuple . You can see new element appended to original tuple representation . by tutorialspoint . com happy coding : D

Axis Limits Matlab Plot Code Example

Example: axis limits matlab xlim ( [ 0 10 ] ) ylim ( [ - 0.4 0.8 ] )

Arraylist Api In Java Code Example

Example 1: java arraylist import java . util . List ; //list abstract class import java . util . ArrayList ; //arraylist class //Object Lists List l = new ArrayList ( ) ; ArrayList a = new ArrayList ( ) ; //Specialized List List < String > l = new ArrayList < String > ( ) ; ArrayList < Integer > a = new ArrayList < Integer > ( ) ; //only reference data types allowed in brackets <> //Initial Capacity List < Double > l = new ArrayList < Double > ( 5 ) ; //list will start with a capacity of 5 //saves allocation times Example 2: arraylist java methds import java . util . ArrayList ; ArrayList < Integer > myList = new ArrayList < Integer > ( ) ; myList . add ( 0 ) ; myList . remove ( 0 ) ; //Remove at index 0 myList . size ( ) ; myList . get ( 0 ) ; //Return element at index 0

Add Unique Validation On A Condition In Request Validation Laravel Code Example

Example 1: laravel unique validation /** * Store a new blog post. * * @param Request $request * @return Response */ public function store ( Request $request ) { $validatedData = $request - > validate ( [ 'title' => 'required|unique:posts|max:255' , 'body' => 'required' , ] ) ; // The blog post is valid... } Example 2: set unique value validation for laravel form request use Illuminate\Validation\Rule ; public function rules ( ) { return [ 'title' => [ 'required' , Rule : : unique ( 'posts' , 'title' ) - > ignore ( $ this - > post ) ] ] ; }

Check If Child Exists Firebase Database Android Code Example

Example: firebase check if child exists // Assume we have the following data in the Database: { "name" : { "first" : "Ada" , "last" : "Lovelace" } } // Test for the existence of certain keys within a DataSnapshot var ref = firebase . database ( ) . ref ( "users/ada" ) ; ref . once ( "value" ) . then ( function ( snapshot ) { var a = snapshot . exists ( ) ; // true var b = snapshot . child ( "name" ) . exists ( ) ; // true var c = snapshot . child ( "name/first" ) . exists ( ) ; // true var d = snapshot . child ( "name/middle" ) . exists ( ) ; // false } ) ;

Angular 9 Scroll To Element Id Code Example

Example 1: on button click scroll to div angular / ? css or scss / html { scroll - behavior : smooth ; } / ? typescript / //use ViewportScroller in angular //in constructor private _vps : ViewportScroller //function scrollFn ( anchor : string ) : void { this . _vps . scrollToAnchor ( anchor ) } / ? HTML / < button ( click ) = "scrollFn('about')" > Scroll to div < / button > ///About section < div id = "about" > Lorem ipsum dolor sit amet consectetur adipisicing elit . Optio , quasi nostrum labore sequi neque sed nihil consequuntur ? Ea , dolorum minima , cumque explicabo dicta est sit harum dolores , assumenda ex non . < / div > Example 2: scrollto angular //there are a few options you can go with, the basic one being css only //css or scss html { scroll - behavior : smooth ; } //You could also user ViewportScroller - available in angular //..... private _vps : ViewportScroller ...

Check Open Port Ubuntu Code Example

Example 1: linux how to see ports in use # Any of the following sudo lsof - i - P - n | grep LISTEN sudo netstat - tulpn | grep LISTEN sudo lsof - i : 22 # see a specific port such as 22 sudo nmap - sTU - O IP - address - Here Example 2: ubuntu check process on port sudo lsof - i : 22 Example 3: ubuntu open port sudo ufw allow 1191 / tcp Example 4: how to check list of open ports in linux sudo lsof - i - P - n | grep LISTEN sudo netstat - tulpn | grep LISTEN sudo lsof - i : 22 # see a specific port such as 22 sudo nmap - sTU - O IP - address - Here Example 5: see what is using a port ubuntu $ sudo lsof - i : 22 Example 6: check what ports are open linux ## if you use linux sudo ss - tulw

Array.sum Javascript Code Example

Example 1: array sum javascript const arr = [ 1 , 2 , 3 , 4 ] ; const sum = arr . reduce ( ( a , b ) => a + b , 0 ) ; // sum = 10 Example 2: js sum of array [ 1 , 2 , 3 , 4 ] . reduce ( ( a , b ) => a + b , 0 ) // Output: 10 Example 3: javascript sum of array const sum = arr => arr . reduce ( ( a , b ) => a + b , 0 ) ; Example 4: add all elements in array javascript console . log ( [ 1 , 2 , 3 , 4 ] . reduce ( ( a , b ) => a + b , 0 ) ) console . log ( [ ] . reduce ( ( a , b ) => a + b , 0 ) ) Example 5: sum of all numbers in an array javascript const arrSum = arr => arr . reduce ( ( a , b ) => a + b , 0 ) Example 6: javascript sum array values function getArraySum ( a ) { var total = 0 ; for ( var i in a ) { total += a [ i ] ; } return total ; } var payChecks = [ 123 , 155 , 134 , 205 , 105 ] ; var weeklyPay = getArraySum ( payChecks ) ; ...

Angular Typescript Class Constant Code Example

Example: create constant in class typescript private static readonly myPrivateConstant : number = 5 ;

Add Arraylist Java Code Example

Example 1: java insert into arraylist ArrayList < Integer > str = new ArrayList < Integer > ( ) ; str . add ( 0 ) ; str . add ( 1 ) ; // Result = [0, 1] str . add ( 1 , 11 ) ; // Result = [0, 11, 1] Example 2: insert element into arraylist java ArrayList < String > arrayList = new ArrayList < > ( ) ; // Adds element at the back of the list arrayList . add ( "foo" ) ; arrayList . add ( "bar" ) ; // Result = ["foo", "bar"] // Adds element at the specified index arrayList . add ( 1 , "baz" ) ; // Result = ["foo", "baz", "bar"] Example 3: how to add to an arraylist java import java . util . ArrayList ; public class Details { public static void main ( String [ ] args ) { //ArrayList<String> Declaration ArrayList < String > al = new ArrayList < String > ( ) ; //add method for String ArrayList...

Clear Div Content Jquery Code Example

Example 1: delete all child elements jquery $ ( "div" ) . empty ( ) ; Example 2: jquery empty // Remove all child nodes of the set of matched elements from the DOM // This method does not accept any arguments. $ ( "div.parent" ) . empty ( ) ; Example 3: jquery clear text in div // removes only text, no changes to children $ ( '#YourDivId' ) . contents ( ) . filter ( ( _ , el ) => el . nodeType === 3 ) . remove ( ) ; Example 4: jquery if empty remove div //if empty remove parent $ ( '#id:empty' ) . parent ( ) . remove ( ) ; Example 5: remove text element jquery < ! doctype html > < html lang = "en" > < head > < meta charset = "utf-8" > < title > empty demo < / title > < style > p { background : yellow ; } < / style > < script src = "https://code.jquery.com/jquery-3.4.1.js" > < / script > < / head > < ...

Bootstrap 4 Card Examples

Example 1: card bootstrap 4 < div class = "card" style = "width:400px" > < img class = "card-img-top" src = "img_avatar1.png" alt = "Card image" style = "width:100%" > < div class = "card-body" > < h4 class = "card-title" > John Doe < / h4 > < p class = "card-text" > Some example text some example text . John Doe is an architect and engineer < / p > < a href = "#" class = "btn btn-primary" > See Profile < / a > < / div > < / div > Example 2: boostrap card < div class = "card" style = "width: 18rem;" > < div class = "card-body" > < h5 class = "card-title" > Card title < / h5 > < h6 class = "card-subtitle mb-2 text-muted" > Card subtitle < / h6 > < p class =...

Codeigniter Where Count Code Example

Example: count all results codeigniter $ this - > db - > select ( 'id' ) ; $ this - > db - > from ( 'table' ) ; $ this - > db - > where ( $your_conditions ) ; $num_results = $ this - > db - > count_all_results ( ) ;

Ansi Sql Tutorial Code Example

Example: what is SQL SQL full form is a structured query language , and it allows you to interact through commands with the database . Here are some of the SQL Database functions : This allows users to retrieve information from the relational database . It enables the development of tables and databases . It allows data base and tables to be modified , added , removed , and changed . It gives protection , and allows permission to be set . Allows new ways for people to manage the info .

Angular Refresh Page Without Reloading Code Example

Example 1: how to refresh page angular refresh ( ) : void { window . location . reload ( ) ; } Example 2: angular refresh page without reloading this . router . navigate ( [ 'path/to' ] ) . then ( ( ) => { window . location . reload ( ) ; } ) ; Example 3: angular reload component reloadCurrentRoute ( ) { let currentUrl = this . router . url ; this . router . navigateByUrl ( '/' , { skipLocationChange : true } ) . then ( ( ) => { this . router . navigate ( [ currentUrl ] ) ; } ) ; } Example 4: angular 6 reload current page import { DOCUMENT } from '@angular/common' ; import { Component , Inject } from '@angular/core' ; @ Component ( { selector : 'app-refresh-banner-notification' , templateUrl : './refresh-banner-notification.component.html' , styleUrls : [ './refresh-banner-notification.component.scss' ] } ) export class RefreshBanner...

Check Open Ports On Windows 10 Cmd Code Example

Example: how to check for open ports in windows netstat - an

Bootstrap 4 Cards Examples

Example 1: card bootstrap 4 < div class = "card" style = "width:400px" > < img class = "card-img-top" src = "img_avatar1.png" alt = "Card image" style = "width:100%" > < div class = "card-body" > < h4 class = "card-title" > John Doe < / h4 > < p class = "card-text" > Some example text some example text . John Doe is an architect and engineer < / p > < a href = "#" class = "btn btn-primary" > See Profile < / a > < / div > < / div > Example 2: boostrap card < div class = "card" style = "width: 18rem;" > < div class = "card-body" > < h5 class = "card-title" > Card title < / h5 > < h6 class = "card-subtitle mb-2 text-muted" > Card subtitle < / h6 > < p class =...

Angularjs $http Post Response Code Example

Example: angularjs make post request var url = 'posturl' , data = 'parameters' , config = 'contenttype' ; $http . post ( url , data , config ) . then ( function ( response ) { // This function handles success } , function ( response ) { // this function handles error } ) ;

Array Map With Index Js Code Example

Example 1: es6 map usin index const array = [ 1 , 2 , 3 , 4 ] ; const map = array . map ( ( x , index ) => { console . log ( index ) ; return x + index ; } ) ; console . log ( map ) ; Example 2: map javascript index // Arrow function map ( ( element ) => { ... } ) map ( ( element , index ) => { ... } ) map ( ( element , index , array ) => { ... } ) // Callback function map ( callbackFn ) map ( callbackFn , thisArg ) // Inline callback function map ( function callbackFn ( element ) { ... } ) map ( function callbackFn ( element , index ) { ... } ) map ( function callbackFn ( element , index , array ) { ... } ) map ( function callbackFn ( element , index , array ) { ... } , thisArg ) Example 3: map index array . map ( ( currentelement , index ) => { } ) ;

Angularjs $window Force Refresh Code Example

Example 1: angular refresh page without reloading this . router . navigate ( [ 'path/to' ] ) . then ( ( ) => { window . location . reload ( ) ; } ) ; Example 2: angular 6 reload current page import { DOCUMENT } from '@angular/common' ; import { Component , Inject } from '@angular/core' ; @ Component ( { selector : 'app-refresh-banner-notification' , templateUrl : './refresh-banner-notification.component.html' , styleUrls : [ './refresh-banner-notification.component.scss' ] } ) export class RefreshBannerNotificationComponent { constructor ( @ Inject ( DOCUMENT ) private _document : Document ) { } refreshPage ( ) { this . _document . defaultView . location . reload ( ) ; } }