Skip to content

Instantly share code, notes, and snippets.

View ippatev's full-sized avatar
🎯
Focusing

Aleksandr Ippatev ippatev

🎯
Focusing
View GitHub Profile
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,

Random shape generator

Hit highlighted region to generate an object of square or circular shape randomly. The object is randomly coloured, randomly positioned within svg object bounds, 20px<=(square side)<=150px, 30px<=(circle diameter)<=200px. Hit randomly generated object to dismiss it.

A Pen by V on CodePen.

License.

@ippatev
ippatev / index.ts
Created August 9, 2021 04:06
Angular Inputs with getters & setters
@Input() set mimeType(v: string) {
// eslint-disable-next-line no-underscore-dangle
this._mimeType = v.split('/')[1];
}
get mimeType(): string {
// eslint-disable-next-line no-underscore-dangle
return this._mimeType;
}
@ippatev
ippatev / index.ts
Created August 12, 2021 06:50
Typical Oberver object
const observer = {
next: x => console.log('Observer got a next value: ' + x),
error: err => console.error('Observer got an error: ' + err),
complete: () => console.log('Observer got a complete notification'),
};
@ippatev
ippatev / Prerequisites.md
Created August 16, 2021 08:18 — forked from MagicJohnJang/Prerequisites.md
D3-Sankey on Angular component + Typescript

(It's not a file, do this before using)

  1. Have D3.js v4 implement in your project first.
  2. npm install --save d3-sankey

npm install --save @types/d3-sankey

@ippatev
ippatev / jwt-parser.js
Created August 20, 2021 03:51
JWT parser
function parseJwt (token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonPayload);
};
@ippatev
ippatev / README.md
Created September 13, 2021 06:50
Git revert helper

Если вы хотите вернуть изменения, внесенные в рабочую копию, сделайте следующее:

git checkout .

Если вы хотите отменить изменения, внесенные в индекс (т.е. добавленные вами), сделайте это. Предупреждение: это приведет к сбросу всех ваших неотправленных коммитов на master!

git reset
@ippatev
ippatev / application-form.ts
Last active November 15, 2021 07:04
add service
public apiSearchAddressFromData(
searchAddress: string
): Observable<unknown[]> {
return this.http.get<unknown[]>(
`${environment.laccUrl}/searchAddress?searchReq=${searchAddress}`
);
}
@ippatev
ippatev / index.md
Last active December 23, 2021 12:43
Dynamic validation in angular forms

To add onto what @Delosdos has posted.

Set a validator for a control in the FormGroup:

this.myForm.controls['controlName'].setValidators([Validators.required])

Remove the validator from the control in the FormGroup:

this.myForm.controls['controlName'].clearValidators()
@ippatev
ippatev / index.json
Created December 29, 2021 08:52
server errors
{
"message":"Form is not valid. Check inputs and try again",
"modelState":{
"id":{
"errors":{
}
},
"customFields[32].valueContainer.value":{
"errors":[
{