re-configure VMware after upgrading Kernel on Linux
sudo vmware-modconfig --console --install-all
References
https://askubuntu.com/questions/707281/vmware-workstation-12-vmmon-not-found-or-not-loaded
sudo vmware-modconfig --console --install-all
References
https://askubuntu.com/questions/707281/vmware-workstation-12-vmmon-not-found-or-not-loaded
uname -r
sudo pacman -S linux-headers
References
https://superuser.com/questions/951055/unable-to-install-linux-header-for-current-kernel-with-pacman
01 10 100
In Python 2 you can do:
print "%02d" % (1,)
Basically % is like printf or sprintf.
For Python 3.+ the same behavior can be achieved with:
print("{:02d}".format(1))
For Python 3.6+ the same behavior can be achieved with f-strings:
print(f"{1:02d}")
References
https://stackoverflow.com/questions/134934/display-number-with-leading-zeros
interface myCallbackType { (myArgument: string): void }
and use it like this:
public myCallback : myCallbackType;
Or
export type ScreenSizeChangeCallback = (prop: ScreenProperties) => void;
References
https://stackoverflow.com/questions/13137350/defining-typescript-callback-type
refresh(): void { window.location.reload(); }
References
https://stackoverflow.com/questions/43985752/how-to-reload-page-the-whole-page-in-angular-2
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Sofia"));
References
https://stackoverflow.com/questions/2493749/how-to-set-a-jvm-timezone-properly
This is working but not dynamically, so we need to change this to work
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { LayoutModule } from '@progress/kendo-angular-layout'; import { RTL } from '@progress/kendo-angular-l10n'; import { AppComponent } from './app.component'; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, LayoutModule ], // Enable Right-to-Left mode for Kendo UI components providers: [{ provide: RTL, useValue: true }], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule { }
Use a factory provider to dynamically resolve values
export function enableRTL(): boolean { const x = document.cookie; const dir = getCookie('dir'); if (dir === 'rtl') { return true; } return false; }
{provide: RTL, useFactory: enableRTL}
References
https://www.telerik.com/kendo-angular-ui-develop/components/globalization/localization/
https://plnkr.co/edit/EOFoxuwc6ooUm5Ctho2q?p=preview
https://github.com/telerik/kendo-angular/issues/984
import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { CustomerComponent } from './customer.component'; import { NewItemDirective } from './new-item.directive'; import { OrdersPipe } from './orders.pipe'; @NgModule({ imports: [ CommonModule ], declarations: [ CustomerComponent, NewItemDirective, OrdersPipe ], exports: [ CustomerComponent, NewItemDirective, OrdersPipe, CommonModule, FormsModule ] }) export class SharedModule { }
References
https://angular.io/guide/sharing-ngmodules
ng generate module customers --route customer-list --module app.module
tsconfig.app.json & tsconfig.json
"module": "esnext"
import { Component, forwardRef, HostBinding, Input } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; @Component({ selector: 'rating-input', template: ` <span *ngFor="let starred of stars; let i = index" (click)="onTouched(); rate(i + (starred ? (value > i + 1 ? 1 : 0) : 1))"> <ng-container *ngIf="starred; else noStar">⭐</ng-container> <ng-template #noStar>·</ng-template> </span> `, styles: [` span { display: inline-block; width: 25px; line-height: 25px; text-align: center; cursor: pointer; } `], providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => RatingInputComponent), multi: true } ] }) export class RatingInputComponent implements ControlValueAccessor { stars: boolean[] = Array(5).fill(false); // Allow the input to be disabled, and when it is make it somewhat transparent. @Input() disabled = false; @HostBinding('style.opacity') get opacity() { return this.disabled ? 0.25 : 1; } // Function to call when the rating changes. onChange = (rating: number) => {}; // Function to call when the input is touched (when a star is clicked). onTouched = () => {}; get value(): number { return this.stars.reduce((total, starred) => { return total + (starred ? 1 : 0); }, 0); } rate(rating: number) { if (!this.disabled) { this.writeValue(rating); } } // Allows Angular to update the model (rating). // Update the model and changes needed for the view here. writeValue(rating: number): void { this.stars = this.stars.map((_, i) => rating > i); this.onChange(this.value) } // Allows Angular to register a function to call when the model (rating) changes. // Save the function as a property to call later here. registerOnChange(fn: (rating: number) => void): void { this.onChange = fn; } // Allows Angular to register a function to call when the input has been touched. // Save the function as a property to call later here. registerOnTouched(fn: () => void): void { this.onTouched = fn; } // Allows Angular to disable the input. setDisabledState(isDisabled: boolean): void { this.disabled = isDisabled; } }
References
https://alligator.io/angular/custom-form-control/
https://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html