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
https://js-cqdfne.stackblitz.io/ | |
highlightNode(document.body, 'angular'); | |
function highlightNode(root, word) { | |
const textNodes = textNodesUnder(root); | |
console.log('Found nodes: ' + textNodes.length, textNodes); | |
const matchingNodes = textNodes | |
.filter((node) => new RegExp(word, 'gi').test(node.nodeValue)) |
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
const puppeteer = require('puppeteer'); | |
async function autoScroll(page) { | |
await page.evaluate(async () => { | |
await new Promise((resolve, reject) => { | |
var totalHeight = 0; | |
var distance = 300; | |
var timer = setInterval(() => { | |
const element = document.querySelectorAll('.section-scrollbox')[1]; | |
var scrollHeight = element.scrollHeight; |
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
{ | |
test: cssRegex, | |
exclude: cssModuleRegex, | |
use: [ | |
{ | |
loader: require.resolve('style-loader'), | |
options: { | |
esModule: false, | |
}, | |
}, |
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
// https://www.codewars.com/kata/523f5d21c841566fde000009 | |
// Solution 1 | |
function arrayDiff(a, b) { | |
var result = []; | |
for(var n of a) { | |
if(!b.includes(n)) { | |
result.push(n); | |
} | |
} | |
return 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
// Valid Braces | |
// https://www.codewars.com/kata/5277c8a221e209d3f6000b56 | |
/* Solution 1 */ | |
function validBraces(braces){ | |
var queue = []; | |
for(var brace of braces) { | |
if(brace === '(' || brace === '{' || brace === '[') { | |
queue.push(brace); |
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
// Your order, please | |
// https://www.codewars.com/kata/55c45be3b2079eccff00010f | |
/* Solution 1 */ | |
function order(words){ | |
if(!words) { | |
return words; | |
} | |
var arr = words.split(' '); | |
var obj = {}; |
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 { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { AppRoutingModule } from './app-routing.module'; | |
import { AppComponent } from './app/app.component'; | |
import { HomeComponent } from './home/home.component'; | |
import { ProfileComponent } from './profile/profile.component'; | |
import { NotFoundComponent } from './error/not-found/not-found.component'; | |
import { LoginComponent } from './login/login.component'; | |
import { UserRoleDirective } from './directives/user-role.directive'; | |
import { UserDirective } from './directives/user.directive'; |
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 { NgModule } from '@angular/core'; | |
import { Routes, RouterModule } from '@angular/router'; | |
import { HomeComponent } from './home/home.component'; | |
import { ProfileComponent } from './profile/profile.component'; | |
import { NotFoundComponent } from './error/not-found/not-found.component'; | |
import { AuthGuard } from './app-routing.guard'; | |
import { AuthService } from './services/auth.service'; | |
import { LoginComponent } from './login/login.component'; | |
import { Role } from './models/role'; | |
const routes: Routes = [ |
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 { CanActivate, CanLoad } from '@angular/router'; | |
import { Router, ActivatedRouteSnapshot, Route } from '@angular/router'; | |
import { Observable } from 'rxjs'; | |
import { Injectable } from '@angular/core'; | |
import { AuthService } from './services/auth.service'; | |
import { Role } from './models/role'; | |
@Injectable() | |
export class AuthGuard implements CanActivate, CanLoad { | |
constructor( | |
private router: Router, |
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 { Injectable } from '@angular/core'; | |
import { User } from '../models/user'; | |
import { Role } from '../models/role'; | |
@Injectable() | |
export class AuthService { | |
private user: User; | |
isAuthorized() { | |
return !!this.user; | |
} | |
hasRole(role: Role) { |
NewerOlder