Posts

Angular 2 NgModelChange Old Value

Answer : This might work (ngModelChange)="onModelChange(oldVal, $event); oldVal = $event;" or (ngModelChange)="onModelChange($event)" oldValue:string; onModelChange(event) { if(this.oldValue != event) { ... } this.oldValue = event; } Just for the future we need to observe that [(ngModel)]="hero.name" is just a short-cut that can be de-sugared to: [ngModel]="hero.name" (ngModelChange)="hero.name = $event". So if we de-sugar code we would end up with: <select (ngModelChange)="onModelChange()" [ngModel]="hero.name" (ngModelChange)="hero.name = $event"> or <[ngModel]="hero.name" (ngModelChange)="hero.name = $event" select (ngModelChange)="onModelChange()"> If you inspect the above code you will notice that we end up with 2 ngModelChange events and those need to be executed in some order. Summing up: If you place ngModelChange befor...

Can I Use An Xbox 360 Controller To Play Xbox One?

Answer : The Xbox One cannot directly accept input from an Xbox 360 controller - however, with Windows 10, there is a work around. Windows 10 allows you to set up your Xbox One to stream to your computer. While streaming to your computer, you are directed to connect the controller into the computer, not the Xbox One. In this form, Xbox 360 controllers will work for playing Xbox One games. You can directly plug in a wired controller, or use an adapter, if you are using the wireless controllers.

Pure CSS Background Animation CodePen Code Example

Example: background image animation css codepen Refer to this link for many options https : //codepen.io/collection/Iolmb?cursor=ZD0xJm89MSZwPTEmdj0z

Crawling Multiple URLs In A Loop Using Puppeteer

Answer : map , forEach , reduce , etc, does not wait for the asynchronous operation within them, before they proceed to the next element of the iterator they are iterating over. There are multiple ways of going through each item of an iterator synchronously while performing an asynchronous operation, but the easiest in this case I think would be to simply use a normal for operator, which does wait for the operation to finish. const urls = [...] for (let i = 0; i < urls.length; i++) { const url = urls[i]; await page.goto(`${url}`); await page.waitForNavigation({ waitUntil: 'networkidle2' }); } This would visit one url after another, as you are expecting. If you are curious about iterating serially using await/async, you can have a peek at this answer: https://stackoverflow.com/a/24586168/791691 The accepted answer shows how to serially visit each page one at a time. However, you may want to visit multiple pages simultaneously when the task is embarrassingly pa...

Queues And Stacks Hackerrank Solution In Java Code Example

Example: queue using two stacks hackerrank solution # include <stack> # include <iostream> using namespace std ; int main ( ) { stack < int > Front , Rear ; int Q ; cin >> Q ; while ( Q -- ) { int type , x ; cin >> type ; if ( type == 1 ) { cin >> x ; Rear . push ( x ) ; } else { if ( Front . empty ( ) ) { // move all the elements from "Rear" stack to "Front" stack while ( ! Rear . empty ( ) ) { Front . push ( Rear . top ( ) ) ; Rear . pop ( ) ; } } if ( ! Front . empty ( ) ) { if ( type == 2 ) Front . pop ( ) ; if ( type == 3 ) cout << Front . top ( ) << endl ; } } ...

Angular Material Customize Tab

Answer : In your component, set ViewEncapsulation to None and add the styles in your component.css file. Changes in Typescript code: import {Component, ViewEncapsulation} from '@angular/core'; @Component({ .... encapsulation: ViewEncapsulation.None }) Component CSS: /* Styles for tab labels */ .mat-tab-label { min-width: 25px !important; padding: 5px; background-color: transparent; color: red; font-weight: 700; } /* Styles for the active tab label */ .mat-tab-label.mat-tab-label-active { min-width: 25px !important; padding: 5px; background-color: transparent; color: red; font-weight: 700; } /* Styles for the ink bar */ .mat-ink-bar { background-color: green; } Demo Update To customize tab background and ink bar, you can define your own theme then use the theme options on the tab group: <div class="my-theme"> <mat-tab-group [backgroundColor]="'primary'" [color]="...

Contenteditable Change Events

Answer : I'd suggest attaching listeners to key events fired by the editable element, though you need to be aware that keydown and keypress events are fired before the content itself is changed. This won't cover every possible means of changing the content: the user can also use cut, copy and paste from the Edit or context browser menus, so you may want to handle the cut copy and paste events too. Also, the user can drop text or other content, so there are more events there ( mouseup , for example). You may want to poll the element's contents as a fallback. UPDATE 29 October 2014 The HTML5 input event is the answer in the long term. At the time of writing, it is supported for contenteditable elements in current Mozilla (from Firefox 14) and WebKit/Blink browsers, but not IE. Demo: document.getElementById("editor").addEventListener("input", function() { console.log("input event fired"); }, false); <div contenteditable="true...

Disable Chrome Extension Js Code Example

Example: disable javascript chrome 1 . Ctrl+Shift+I 2 . Ctrl+Shift+P 3 . Type 'javascript' 4 . Select '[Debugger] Disable Javascript'

Using Map Arduino Code Example

Example 1: map arduino Syntax map ( value , fromLow , fromHigh , toLow , toHigh ) Parameters value : the number to map . fromLow : the lower bound of the value’s current range . fromHigh : the upper bound of the value’s current range . toLow : the lower bound of the value’s target range . toHigh : the upper bound of the value’s target range . Example : map ( val , 0 , 255 , 0 , 1023 ) ; Example 2: arduino map function long map ( long x , long in_min , long in_max , long out_min , long out_max ) { return ( x - in_min ) * ( out_max - out_min ) / ( in_max - in_min ) + out_min ; }

Cron Guru Every 30 Minutes Code Example

Example: crontab every 30 minutes in specific minute // every 30 minutes */30 * * * * // it depends on the crontab version you are using // example: every 30 minutes at number '5' // mode 1 5,35 * * * * // mode 2 5/30 * * * *

Media Query In W3school Code Example

Example 1: css media queries @media only screen and ( max-width : 1200 px ) { /*Tablets [601px -> 1200px]*/ } @media only screen and ( max-width : 600 px ) { /*Big smartphones [426px -> 600px]*/ } @media only screen and ( max-width : 425 px ) { /*Small smartphones [325px -> 425px]*/ } Example 2: media query @media only screen and ( max-width : 600 px ) { body { background-color : lightblue ; } } Example 3: media query in css @media screen and ( min-width : 374 px ) { section #rent_sectionn { padding : 0 20 px !important ; } }

Bootstrap Scrollbar Code Example

Example 1: custom scrollbar body ::-webkit-scrollbar { width : 12 px ; /* width of the entire scrollbar */ } body ::-webkit-scrollbar-track { background : orange ; /* color of the tracking area */ } body ::-webkit-scrollbar-thumb { background-color : blue ; /* color of the scroll thumb */ border-radius : 20 px ; /* roundness of the scroll thumb */ border : 3 px solid orange ; /* creates padding around scroll thumb */ } Example 2: bootstrap overflow hidden <div class= "overflow-auto" >...</div> <div class= "overflow-hidden" >...</div> Example 3: make a container scrollable bootstrap .anyClass { height : 150 px ; overflow-y : scroll ; } Example 4: custom scrollbar ::-webkit-scrollbar { /* 1 */ } ::-webkit-scrollbar-button { /* 2 */ } ::-webkit-scrollbar-track { /* 3 */ } ::-webkit-scrollbar-track-piece { /* 4 */ } ::-we...

How To Use Filter Blur In Css Code Example

Example 1: image blur css filter : blur ( 8 px ) ; -webkit-filter : blur ( 8 px ) ; Example 2: blur css .mydiv { filter : grayscale ( 50 % ) } /* Graut alle Bilder um 50% aus und macht sie um 10px unscharf */ img { filter : grayscale ( 0.5 ) blur ( 10 px ) ; }

Materialize Css Form Template Code Example

Example 1: materialize css form file input <form action= "#" > <div class= "file-field input-field" > <div class= "btn" > <span>File</span> <input type= "file" > </div> <div class= "file-path-wrapper" > <input class= "file-path validate" type= "text" > </div> </div> </form> Example 2: fix materialize form label not working input :-webkit-autofill + label { font-size : 0.8 rem ; transform : translateY ( -140 % ) ; }

Montserrat Font Free Download Code Example

Example: montserrat font <link rel= "preconnect" href= "https://fonts.gstatic.com" > <link href= "https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel= "stylesheet" >

Android:fitsSystemWindows Not Working

Answer : Use CoordinatorLayout as root for your view, it worked for me. <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> My problem was most likely related to multiple/nested fitsSystemWindows attributes which does not work as I found out later. I solved my problem by applying the attribute to one view, and then copy the paddings to other views that need them via an ViewTreeObserver.OnGlobalLayoutListener . That is an ugly hack, but does its job for now. I meet the same problem in Android 4.4 My problem is <item name="android:windowTranslucentStatus">true</item> conflict with <item name="android:fitsSystemWindows">true</item> My way is remove ...