Monday, 31 January 2022

Duolingo invitation link

Learn a language with me for free! Duolingo is fun, and proven to work. Here’s my invite link:



Monday, 27 December 2021

List of Breakpoints in Angular Material

https://material.angular.io/cdk/layout/api

These are Breakpoints constant actual values.

Thursday, 23 December 2021

When you align Justice League covers, you get amazing picture

Thursday, 9 December 2021

Problem przy tworzeniu Azure Active Directory B2C

Potrzebuję katalogu Azure B2C dla mojego projektu.

Przy próbie utworzenia nowego katalogu dostaję taki błąd:

The subscription is not registered to use namespace 'Microsoft.AzureActiveDirectory'.
See https://aka.ms/rps-not-found for how to register subscriptions.


 

Rozwiązanie:

 

  1. Zaloguj się do Azure
  2. Otwórz konsolę
     

  1. Konsola może wymagać stworzenia katalogów.
  2. W konsoli wpisz:

az provider register --namespace Microsoft.AzureActiveDirectory

 

Po kilku minutach powinno zadziałać. Możesz spróbować stworzyć katalog jeszcze raz.

 

Tuesday, 20 October 2020

Implementing ControlValueAccessor


import { Component, forwardRef, Input, OnInit } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';

@Component({
  selector: 'app-password-input',
  templateUrl: './password-input.component.html',
  providers: [
    {
      provide: NG_VALUE_ACCESSOR,
      useExisting: forwardRef(() => PasswordInputComponent),
      multi: true
    }
  ]
})
export class PasswordInputComponent implements OnInit, ControlValueAccessor {
  constructor() {}
  writeValue(obj: any): void {
    this.Value = obj;
  }
  registerOnChange(fn: any): void {
    this.onChange = fn;
  }
  registerOnTouched(fn: any): void {
    this.onTouch = fn;
  }
  setDisabledState?(isDisabled: boolean): void {
    this.disabled = isDisabled;
  }
  onChange: any = () => {};
  onTouch: any = () => {};
  disabled?: boolean;
  ngOnInit(): void {}

  /** Password value */
  public value: string;
  set Value(val) {
    // this value is updated by programmatic changes
    if (val !== undefined && this.value !== val) {
      this.value = val;
      this.onChange(val);
      this.onTouch(val);
    }
  }
  get Value(): string {
    return this.value;
  }
 }

Thursday, 1 October 2020

Custom Events with Angular Elements

Created component in Angular, it has Output called selectedStep, that emits a number.
@Output() public selectedStep: EventEmitter<number> = new EventEmitter<number>();
How to write CustomEvent in plain HTML + JS page, so that it would eg. display step number to console?
<script>
// trigger this function, when event is emitted from inside custom-element
function stepChanged(e) {
  console.log('Current step: ' + e);
}

document.addEventListener("DOMContentLoaded", function() {
  // Handler when the DOM is fully loaded
  let element = document.querySelector("custom-element");
  element.addEventListener("selectedStep", event => {
    stepChanged(event.detail);
  });
});

</script>
<custom-element></custom-element>
Important to remember: 
  1. addEventListener first parameter is the name of Output 
  2. Emitted value is in detail property of second paramenter

Wednesday, 23 September 2020

TypeScript - generate random word

This method will generate random string of n-letter length with lowercase letters:
  /**
   * Generate random lowercase word
   * @param {number} length Word length
   * @returns Random n-letter word
   */
  randomWord(length: number): string {
    let result = '';
    for (let index = 0; index < length; index++) {
      // one of 26 en letters, 'a' = 97
      const ascii = Math.floor(Math.random() * 26 + 97);
      result += String.fromCharCode(ascii);
    }
    return result;
  }

Tuesday, 1 September 2020

Hide Addons panel for some stories in Storybook

I'm using Code Preview globally in Storybook with storybook-addon-preview. However, I there is one story that has no code preview and it displays "No Preview found" message.
To hide the panel for single story, set following parameters in Story:
export default {
  title: 'Some title',
  parameters: { options: { showPanel: false } }
};

Friday, 17 July 2020

Bootstrap in Storybook

To use Bootstrap modules in Storybook, you have to import NgbModule inside the story and then in the story say:
export default {
    title: 'Tooltip',
    decorators: [
        moduleMetadata({
            // imports both components to allow component composition with storybook
            declarations: [TooltipComponent],
            imports: [NgbModule]
        }),
    ],
};

Friday, 29 May 2020

Sideload install custom ROM

I have TWRP on my bacon (OnePlus One).

I decided to install new custom ROM and try Carbon. I pushed the zip file to device, then rebooted to TWRP

adb reboot recovery

and decided to completely wipe the phone. I had a lot of files "orphaned" from some old apps and wanted to get rid of all of them.

Then I realized, that the zip image was also deleted. And in bootloader, adb push does not work. So, what did I do?

1. In TWRP I went to: Advanced > ADB Sideload > Swipe to Start Sideload
Now, if I type

adb devices

I get my device in sideload mode.

2. Typed:

adb sideload .\CARBON-CR-7.0-OPAL-RELEASE-bacon-20200526-1945.zip

and the ROM was installed. Then I installed GApps the same way.