Skip to main content

Posts

Default routing on Angular 8 doesn't work fine

I have built an app on Angular 8 and the below is the routing configuration i have setup, const routes: Routes = [ { path: '', redirectTo: "/pages", pathMatch: 'full', }, { path: 'pages', canActivate: [AuthGuard], loadChildren: () => import('./pages/pages.module') .then(m => m.PagesModule), }, { path: 'auth', loadChildren: './auth/auth.module#NgxAuthModule', }, { path: '**', redirectTo: 'pages' }, ]; For some reason, the default routing doesn't seem to work fine. I tried setting up the configuration to debug the routing and it looks like the router doesn't seem to pick up the redirect at all. Can anyone let me know if i am doing something wrong. I tried all different values for redirectTo like 'pages'. But nothing seems to work. Via Active questions tagged javascript - Stack Overflow https://ift.tt/4KIFwbN

AttributeError: 'NoneType' object has no attribute 'get', and the knn step is right

I have a problem with the get() method its not being recognized. I have not found a solution. I want to take the input from the GUI and apply it to the knn algorithm from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.multiclass import OneVsRestClassifier from sklearn.neighbors import KNeighborsClassifier from tkinter import * top = Tk('300','300') box= Text(top).grid(row=1,column=1) p = TfidfVectorizer(sublinear_tf=True, stop_words='english') p.fit(box.get("1.0",END)) wordOfp = p.transform(p) x_train,x_test,y_train,y_test = train_test_split(wordOfp,y,random_state = 42, test_size = 0.2)# y is target model = OneVsRestClassifier(KNeighborsClassifier(n_neighbors=5, metric= 'euclidean' )) model.fit(x_train,y_train) prediction = model.predict(x_test) this is a error p.fit(box.get("1.0",END)) AttributeError: 'NoneType' object has no attribute 'get' source https://stackoverflow.com/questions

Convert milliseconds to human readable [closed]

I am trying to convert milliseconds from database to human readable format I know that my timestamp in DB is in UTC as of today's date. When I plug it into momentJS, I get: 1969-12-31T19:00:00-05:00 Below is my code: return moment(val).format(); Via Active questions tagged javascript - Stack Overflow https://ift.tt/pqNtFsl

Scraping a udemy course with beautifoulsoup

I am scraping the next web page: https://www.udemy.com/course/the-modern-cpp-20-masterclass/ I got 2 params that I cant access to. The first one is the price and the second is the number of the articles. For example, in the course I sent the link, there are 4 articles. You can find it in the right side under 'this course includes'. Thank you for your help ! My code for the price that doesnt work is: import time import os import bs4 from bs4 import BeautifulSoup import pandas as pd import scipy as sc import numpy as np import requests url = "https://www.udemy.com/course/the-modern-cpp-20-masterclass/" page = requests.get(url) soup = BeautifulSoup(page.content,'html.parser') course_price = soup.find('div', {"class" : 'sidebar-container-position-manager'}) children = course_price.findChildren("div" , recursive=False) For the number of articles, when I tried it, it returned me: 4 articles When I tried to ex

Redraw d3 graph with a new data

i'm pretty new to d3. Could you help me, please, why doesn't my graph redraw after I generate new data on button press? It draws once, but after I push button it only logs new data array to console. Do I remove old data wrong? Just in case I import d3 functions separately this is why it's written select instead of d3.select . Everything works besides updating graph. Thank you in advance. There is a similar question here, and I tried to do it in a similar way, but I don't get what am I doing wrong. const randomValue = randomInt(0, 100); const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sen', 'Oct', 'Nov', 'Dec']; let data = months.map(m => ({ label: m, value: randomValue() })) let values = data.map(m => m.value) const yScale = scaleLinear().domain([0, 100]).range([0, height]); const colorScale = scaleLinear().domain([0, 100]).range([

Recreating PacMan using Pygame [closed]

Here's my code: import pygame pygame.init() pygame.display.set_caption("Pac-Man") # Sets the size of the screen via (WIDTH, HEIGHT) SCREEN_WIDTH = 475 SCREEN_HEIGHT = 608 # Speed of Characters SPEED = 1 # Frames per second, how fast the game runs FPS = 50 # Colors (RED,GREEN,BLUE) BLACK = (0, 0, 0) WHITE = (255, 255, 255) YELLOW = (255, 255, 0) BLUE = (0, 0, 255) HIGH_SCORE = 0 # Sets the WIDTH and HEIGHT of the window WINDOW = (SCREEN_WIDTH, SCREEN_HEIGHT) # Displays the screen SCREEN = pygame.display.set_mode(WINDOW) CLOCK = pygame.time.Clock() PacManStartSurface = pygame.transform.scale(pygame.image.load ("PacManStart.png").convert(), (25, 25)) PacManStartRect = PacManStartSurface.get_rect(topleft = (((SCREEN_WIDTH - 22) // 2), (SCREEN_HEIGHT + 225) // 2)) PacManSurface = pyga

Find sequences where all elements have same sign and then change sign

I have a series of lists with 7 elements (but could be any number). I am trying to find the lists that have all positive elements, all negative elements, and those that change sign at ANY point, for example [3, 6, 7, -2, -5, -1, -1] or [3, 1, -1, -2, -1, -5, -1] . Note that, though I used integers in my example, the lists are actually made of floats . I can easily find all lists that are always positive or negative, but how do I find those that change sign (it could go from positive to negative as in example or from negative to positive). source https://stackoverflow.com/questions/72320439/find-sequences-where-all-elements-have-same-sign-and-then-change-sign