StackOverflow.com

VN:F [1.9.22_1171]
Rating: 9.4/10 (10 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

How to find specific value of html element (such as h1) with node.js

3 December 2022 @ 8:09 am

I'm trying to find the numbers of users on this website, using node.js, but I'm not sure of what process I can do to get it. The value is subclassed under multiple divs with different class names. Right now I will just be console.logging it but I'm going to do more with the data later on. I was suggested to use the package "puppeteer", but I'm not sure how this would fetch it or what to do with it to fetch it. Thank you in advance

How to prevent adding .editorconfig to one solution leading to StyleCop rules getting applied to every solution?

3 December 2022 @ 8:08 am

I'm using C#. Say I have the following folder structure: Root -> dir A -> dir B -> sln B -> dir C -> sln C -> sln A There's stylecop.json present for all the solutions. { "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "settings": { "documentationRules": { "companyName": "Microsoft", "copyrightText": " Copyright (c) Microsoft Corporation. All rights reserved." } } } But there's no .editorconfig file and the SA rules are not applied to the solutions (not sure if it's expected). Now, the moment I create a .editorconfig file for sln C, the SA rules start getting applied to A, B, C all solutions. How do we configure it to apply for a single solution only?

Print time update it by 1 sec in the same time with getting user input under the time line

3 December 2022 @ 8:08 am

I want to make a digital clock in C with the time is update real time by 1 second. And i want to put input under the digital clock line. I'm using windows. And here is what i've tried before #include <stdio.h> #include <string.h> #include <time.h> void display_time(){ time_t s, val = 1; struct tm* current_time; while(1){ s = time(NULL); current_time = localtime(&s); printf("%02d:%02d:%02d", current_time->tm_hour, current_time->tm_min, current_time->tm_sec); if(current_time->tm_sec == 0){ break; } } } int main(){ int i; display_time(); printf("\nEnter number for i: "); scanf("%d", &i); printf("%d", i); return 0; } I want the output like this, but the digital clock still updated by 1 second HH:MM:SS Enter number for i: //example 10 1

Renderflex Overflow on the bottom

3 December 2022 @ 8:07 am

I want to create a two column card layout and I'm using reusable widget I created. But I'm having renderflow issues. Below are the errors. i already tried to make it smaller, it worked but not as what i want it to look like. ════════ Exception caught by rendering library ═════════════════════════════════ A RenderFlex overflowed by 99853 pixels on the right. The relevant error-causing widget was Row lib\…\student\subjects.dart:158 ════════════════════════════════════════════════════════════════════════════════ enter image description here subjects.dart SingleChildScrollView(

split the file based on header and footer lines

3 December 2022 @ 7:59 am

I have a text file structured like this: header data1 data2 data3 .. footer junk header data4 data5 ... footer junk header data6 data7 data8 .. footer I need to find each part between header and footer and save it in another file. For example the file1 should contain: data1 data2 data3 .. and the next pack should be saved as file2 and so on. This seems like a routine process, but I haven't find a solution yet. I have this sed command that finds the first packet. sed -n "/header/,/footer/{p;/footer/q}" file But I don't know how to iterate that over the next matches. Maybe I should delete the first match after copying it to another file and repeat the same command

Eror occurs when install nuxt and create app

3 December 2022 @ 7:54 am

Cannot instal nuxt and create app. I used https://nuxtjs.org/docs/get-started/installation and https://github.com/nuxt/create-nuxt-app for creating app but this error occurs: "create-nuxt-app" is not internal or external command executed by a program or batch file. npm ERR! path C:\Users\Acer\Desktop\nuxt npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-nuxt-app "hacker-news" npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Acer\AppData\Local\npm-cache\_logs\2022-12-03T06_03_59_129Z-debug-0.log``` Please help! PS: node js and npm are installed

pandas/regex: Remove the string after the hyphen or parenthesis character (including) carry string after the comma in pandas dataframe

3 December 2022 @ 7:46 am

I have a dataframe contains one column which has multiple strings separated by the comma, but in this string, I want to remove all matter after hyphen (including hyphen), main point is after in some cases hyphen is not there but directed parenthesis is there so I also want to remove that as well and carry all the after the comma how can I do it? You can see this case in last row. dd = pd.DataFrame() dd['sin'] = ['U147(BCM), U35(BCM)','P01-00(ECM), P02-00(ECM)', 'P3-00(ECM), P032-00(ECM)','P034-00(ECM)', 'P23F5(PCM), P04-00(ECM)'] Expected output dd['sin'] # output U147 U35 P01 P02 P3 P032 P034 P23F5 P04 Want to carry only string before the hyphen or parenthesis or any special character.

Is parsing state from child component up in react a good practice

3 December 2022 @ 7:45 am

I am trying to change the state in the App components from a child components and I fell i would result to an issue later in my app i tried passing the setFunction down to the child components then having it change the value in the app components

python get dictionary key from value is list

3 December 2022 @ 7:40 am

I have two dictionaries: first_dict = {'a': ['1', '2', '3'], 'b': ['4', '5'], 'c': ['6'], } second_dict = {'1': 'wqeewe', '2': 'efsafa', '4': 'fsasaf', '6': 'kgoeew', '7': 'fkowew' } I want to have a third dict that will contain the key of second_dict and its corresponding value from first_dict's key. This way, I will have : third_dict = {'1' : 'a', '2' : 'a', '4' : 'b', '6' : 'c', '7' : None, } here is my way: def key_return(name): for key, value in first_dict.items(): if name == value: return key if isinstance(value, list) and name in value: return key return None reference:

c: extern variable is not retaining value

3 December 2022 @ 7:19 am

I am using an extern bool variable. I have initialized it (to true) and want to use this value somewhere else in program. But the problem is, when went into another module, this true value is becoming false and when returned from that module (where the value was last seen true), then it turns to true. I am not understanding why extern variable is behaving like this. Does someone know about this? I want extern variable to retain its value like it should be.