const groupBy = key => array =>
array.reduce((objectsByKeyValue, obj) => {
const value = obj[key];
objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
return objectsByKeyValue;
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
This is way is very simple and nice way to display images in Angular. | |
<img [src]="imageUrl" class="img-responsive" onError="this.src='assets/images/no-image.png';"> |
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
// angular component init lifecycle | |
ngOnInit() { | |
// setup vidyo client | |
this.vidyoService.loadVidyoClientLibrary(); | |
// as a seperate process, calling browser API to get media | |
navigator.getUserMedia({audio: true}, | |
(stream) => { |
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
/*** | |
Fake backend router looks like this. | |
static router(url: string): DBConnection { | |
if (url === environment.apiUrl + 'users') { | |
return {db: annotators, searchField: '', type: RequestType.Pagination}; | |
} else if (url.includes(environment.apiUrl + 'corpora')) { | |
if (url === environment.apiUrl + 'corpora') { | |
return {db: corpora, searchField: 'name', type: RequestType.Pagination}; | |
} else { |
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
this.signUpForm.get('email').valueChanges | |
.pipe( | |
tap(() => this.isInvalidEmail = false), | |
debounceTime(500), | |
filter(value => CommonService.validateEmail(value)), | |
tap((x) => { | |
this.isCheckingEmail = true; | |
this.isInvalidEmail = false; | |
}), | |
switchMap(x => this.authService.checkEmail(x)), |
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 { Pipe, PipeTransform } from '@angular/core'; | |
/* | |
* Convert bytes into largest possible unit. | |
* Takes an precision argument that defaults to 2. | |
* Usage: | |
* bytes | fileSize:precision | |
* Example: | |
* {{ 1024 | fileSize}} | |
* formats to: 1 KB |
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
wget -O /tmp/YaHei.Consolas.1.12.zip https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/uigroupcode/YaHei.Consolas.1.12.zip | |
unzip /tmp/YaHei.Consolas.1.12.zip | |
sudo mkdir -p /usr/share/fonts/consolas | |
sudo mv YaHei.Consolas.1.12.ttf /usr/share/fonts/consolas/ | |
sudo chmod 644 /usr/share/fonts/consolas/YaHei.Consolas.1.12.ttf | |
cd /usr/share/fonts/consolas | |
sudo mkfontscale && sudo mkfontdir && sudo fc-cache -fv |
To remove a submodule you need to:
- Delete the relevant section from the .gitmodules file.
- Stage the .gitmodules changes git add .gitmodules
- Delete the relevant section from .git/config.
- Run git rm --cached path_to_submodule (no trailing slash).
- Run rm -rf .git/modules/path_to_submodule (no trailing slash).
- Commit git commit -m "Removed submodule "
- Delete the now untracked submodule files rm -rf path_to_submodule