This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Link: https://awk.js.org/ | |
Command Line: | |
-F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | |
STDIN: | |
r/john | james | today | |
r/abc| def | hij |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
import java.math.*; | |
public class RepeatingEvenString { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
String inputString = in.nextLine(); | |
String result = removeEvenRepeatedCharacters(inputString); | |
System.out.println(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="child-container"> | |
<h3> Child component </h3> | |
<pre>{{person | json}}</pre> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ChildComponent { | |
@Input() person: Person; | |
} | |
export interface Person { | |
name: string; | |
age: number; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<h3> Parent component </h3> | |
Name: <input type='text' [(ngModel)]="person.name"> <br /> | |
Age: <button (click)="person.age = person.age+1">+</button> {{ person.age }} <button (click)="person.age = person.age-1">-</button> <br /> | |
<button (click)="reassign()">Re-Assign</button> <br> | |
<pre>{{ person | json}}</pre> | |
<child [person]="person"></child> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent { | |
public person: Person = { | |
name: 'John Doe', | |
age: 20 | |
}; | |
public reassign(): void { | |
this.person = { | |
name: this.person.name, | |
age: this.person.age | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'child', | |
//.. | |
changeDetection: ChangeDetectionStrategy.OnPush // <--- | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public reassign(): void { | |
this.person = { | |
name: this.person.name, | |
age: this.person.age, | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assigning object to x | |
x = { | |
name: 'John', | |
age: 20 | |
}; | |
y = x; | |
x.name = 'John Doe'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original data | |
x = [1, 2, 3, 4] | |
// making a change | |
x.push(5); | |
// reassign array to change reference | |
x = [...x]; |