Skip to content

Instantly share code, notes, and snippets.

View FSou1's full-sized avatar
:octocat:

Maxim Zhukov FSou1

:octocat:
View GitHub Profile
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))
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;
{
test: cssRegex,
exclude: cssModuleRegex,
use: [
{
loader: require.resolve('style-loader'),
options: {
esModule: false,
},
},
// 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;
@FSou1
FSou1 / valid-braces.js
Last active September 24, 2020 23:14
// 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);
// Your order, please
// https://www.codewars.com/kata/55c45be3b2079eccff00010f
/* Solution 1 */
function order(words){
if(!words) {
return words;
}
var arr = words.split(' ');
var obj = {};
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';
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 = [
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,
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) {