• Breaking News

    Tuesday, September 7, 2021

    Is Having Several Files Named the Same Bad? Ask Programming

    Is Having Several Files Named the Same Bad? Ask Programming


    Is Having Several Files Named the Same Bad?

    Posted: 07 Sep 2021 03:56 PM PDT

    I'm currently making my first website and noticed that I have several files similarly named. It's going to possibly be my portfolio so I have access to the programs I want to share all being routed (using express.js) through a file called routes/programs.js These programs have information stored in a MongoDB, so the model schema is called models/program.js There's a file to verify the fields entered when adding a new program called public/javascript/program.js And there's a file that contains functions relating to the programs, such as finding one by name, changing parameters, etc, called tools/program.js

    I personally don't have any trouble when working with this and it's intuitive enough for me, but I'm not sure about a team environment, I'm still in school so I haven't really had that experience yet. I'm wondering if this is perfectly fine or if I should be naming them all different things.

    Note: This is ignoring naming conventions that workplaces set. I'm aware that every workplace has their own naming conventions, but I'm just curious on in general what the convention is, or if there's none a all.

    submitted by /u/WatsonDo
    [link] [comments]

    Is the Harvard CS50 course worth it for someone who has no programming knowledge, or should I look into another course for introduction?

    Posted: 07 Sep 2021 06:59 PM PDT

    I was looking at the harvard cs50 extension course as a great introduction to programming concepts. I want to teach myself c++/Java, but I have not seen anything that introduces the basic concepts? What would you suggest?

    submitted by /u/Spectrum-Code
    [link] [comments]

    Distributing n items as evenly as possible into k boxes, where each item has a range of boxes it could go into

    Posted: 07 Sep 2021 10:43 PM PDT

    For example, suppose I have 10 boxes and 20 items. If each item can go into any box 1-10, then obviously each box gets 2 items. However, my situation is much more irregular. Each item has a specific range, there is no pattern. For example, the first item might have the range 3-10, the second might have the range 1-5, etc. Some boxes may be left empty, I'm just trying to distribute the items as evenly as possible. I've just started thinking about this problem, but would like to hear from anyone who has solved a similar problem in the past, or is willing to solve mine. Please also let me know if anything I've written is unclear.

    submitted by /u/mike_the_tutor
    [link] [comments]

    Why modern programming is hard to start with?

    Posted: 07 Sep 2021 06:42 AM PDT

    Hi! This is a vent post.
    I'm recently investing my time into open source projects, and pre-internship projects, trying to find my way in IT job market. But there is a one big hurdle to me which i can't jump over. I can't even start projects. The main reason why i can't do it is, setting up environment. I get requests to set up things like LAMP, and I'm sitting there for weeks doing nothing but trying to solve why it works on other machines but on mine doesn't. Its all entangled in this dependency hell, that even people who already work in this project can't seem to help me out. Is there any way to not lose sanity, or its just not for me? I can see code , but if i can't run it, i can't even participate in it, except for spotting out typos.
    Maybe there is something like pre-made environments, like Docker, which would already set this up, so i can at least start working.

    submitted by /u/AguliRojo
    [link] [comments]

    Automatically editing a text file based on display?

    Posted: 07 Sep 2021 10:21 PM PDT

    Sort of a hard question to even ask so I'm sure the answer is even harder. But really I just need someone to tell me where to start and I can figure out the specifics. So basically what I'm wanting to do is update a text file that contains my MMR(Match Making Rating) for my Twitch Overlay. Basically if I gain MMR e.g. +25 at the end of a game; I want to automatically update the text file and add 25 to the number that is currently there. Here's an image where the +75 is what I would want added to the number in the current text file. What is the best way to go about this, or, is there even any way to go about this? Thanks for taking the time to read

    submitted by /u/reynadsaltynuts
    [link] [comments]

    Been trying for 2 hours to use a .lib file (c++, sdl, how to make it work; my code, file structure, and error message below)

    Posted: 07 Sep 2021 08:54 PM PDT

    My Code (test.cpp):

    #include <iostream> #include <sdl\SDL2.lib> // using namespace std; int main() { std::cout << "hi"; return 0; } 

    My files (the ----- is my name):

    PS C:\Users\-----\Desktop\coding\A-Spacemans-Journey> ls -R Directory: C:\Users\-----\Desktop\coding\A-Spacemans-Journey Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 9/6/2021 8:58 PM sdl -a---- 9/6/2021 8:45 PM 55 README.md -a---- 9/7/2021 8:42 PM 135 test.cpp -a---- 9/6/2021 8:48 PM 56882 test.exe Directory: C:\Users\-----\Desktop\coding\A-Spacemans-Journey\sdl Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 8/10/2021 5:55 PM include d----- 8/10/2021 5:55 PM lib -a---- 8/10/2021 5:55 PM 165498 SDL2.lib Directory: C:\Users\-----\Desktop\coding\A-Spacemans-Journey\sdl\lib Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 8/10/2021 5:55 PM 1249280 SDL2.dll -a---- 8/10/2021 5:55 PM 165498 SDL2.lib -a---- 8/10/2021 5:53 PM 40484 SDL2main.lib 

    I don't know why it doesn't work.

    Error:

    .\test.cpp:2:10: fatal error: sdl\SDL2.lib: No such file or directory #include <sdl\SDL2.lib> ^~~~~~~~~~~~~~ compilation terminated. 

    Computer info:

    • Windows 10
    • Editor vscode
    • g++
    • terminal alacritty (and the vscode terminal)

    I don't understand. I have used c++ for a couple months, finally needed a .lib so I found sdl for what I want (2 d graphic stuffs). Been googling and typing things in for ~2+ hrs now, I don't get it. (Already tried yesterday, so fresh mind didn't help, new pair of eyes didn't help either.

    submitted by /u/LelsersLasers
    [link] [comments]

    Time complexity of printing a list? The entire list object itself, not its individual elements (Python)

    Posted: 07 Sep 2021 07:35 AM PDT

    I've been trying to Google this for hours, but only found one that answers it. However the explanation was short, and because there was only one, I couldn't make sure if it was correct at all.

    Let's say a function asks for an input n, and then it creates a list x with n elements. What would then be the time complexity of print(x) with respect to n? Would its run time scale with whatever the size n of the list x is and therefore it would be O(n)? Or is its runtime going to be constant regardless of the size n?

    The reason I'm having a hard time finding an answer to this in Google is because the results I get is always talking about iterating through the list and printing each element individually, instead of printing the list object itself.

    According to the one result I found, it is also O(n), because the print function in this case apparently also iterates over the list visiting each element once. It would be nice if anyone else could confirm if this is correct.

    submitted by /u/Xil_Jam333
    [link] [comments]

    Comparing data

    Posted: 07 Sep 2021 05:32 PM PDT

    This is going to be a complicated question I think.

    So what is the best way to go about doing this type of comparison.

    So say I have three basketball players and they all have stats of: Points, assists, and steals.

    I want to compare their stats and see who wins the most categories, so say player 1 has more points and assists but less steals than player 2, it still wins.

    I then want this to continue on the list so say player 1 beats player 2, I want to compare players 1 and 3. But I want the program to print the best player of the list.

    This is all in Python btw.

    submitted by /u/21sthoma
    [link] [comments]

    How would you go about parsing out data from a web page using XPath?

    Posted: 07 Sep 2021 01:35 PM PDT

    There's some price data I want to scrape on a regular basis from a web page. I can pull down the HTML with wget or curl, but I have no idea how to parse out a particular item with XPath once I have the file on my PC.

    What's the best way to provide a file name and an XPath to parse, and receive just the information from inside that block?

    EDIT: This appears solved! Thanks to /u/knoam! Thanks!

    submitted by /u/PsychYYZ
    [link] [comments]

    Looking for coding language where you can see other teammates' cursor?

    Posted: 07 Sep 2021 04:34 PM PDT

    Similar to Roll20 from DnDBeyond (which is HTML5 based I believe) -- looking for a coding language where there's a websocket connection and you can bring folks into a lobby where each players mouse has a colour, and you can see their mouse moving around and clicking. Any ideas? Thank you!!

    submitted by /u/joshtriestocode
    [link] [comments]

    How to check whether item exists, in Bash and using a samba path?

    Posted: 07 Sep 2021 12:09 PM PDT

    Dear all

         I need to be able to check, using a Samba path (smb://<ip>/<shareName>), and using Bash (and where shareName is mounted), whether an item (a file or directory) exists.

         Things I've tried to no avail. stat and [[ -e ]] (and similar) and not working, because the path is a Samba one. gio seems not to have a relevant command. smbclient has smblient stat but I cannot get it to work.

         Thanks.

         EDIT: The reason I wish to test for an item's existence is to to get the user to choose whether to overwrite it via gio copy or gio move. Now one can pass those commands an --interactive parameter. Yet, sometimes I run my script graphically and gio proves to prompt for overwriting only on the command line (and indeed on the command line ctrl-C hangs that prompt!).

    PS: If this is not the best subreddit for the question, I'd appreciate being pointed to a more appropriate sub.

    submitted by /u/AnythingAnthingAnthi
    [link] [comments]

    Should i switch from php to c#?

    Posted: 07 Sep 2021 03:39 PM PDT

    Hello everyone I was thinking about switching from php to c#, my question is how hard would it be? If anyone done that or something similar please share your experience, i want to hear it.

    Almost 2 years of experience with php, mostly laravel and some codeigniter. Tbh i like better the non-object oriented way but i see nobody does that anymore, maybe you can recommend another language suitable?

    Thanks

    submitted by /u/BrainDamage_
    [link] [comments]

    I need suggestions for building a web application which show data in real time it also includes TCP socket programming. Please read and Help

    Posted: 07 Sep 2021 08:05 AM PDT

    I want to build a Web Application in which data (JSON) is sent from multiple/single TCP Client Socket to the TCP Server Socket and then stored in Database by Tcp Server. The Web Application server then accesses the same database to show data on client/browser. If possible, I want to show the data on browser as soon as it is successfully stored on the database by tcp server (you can say in Real-Time) although suggestions for achieving same without real time visualization on client side is also good.

    For example: Just like stock or share market apps or websites where we see the stock or share rate going up and down in real time.

    Full Discerption starts from here

    Let's divide this in 2 parts and elaborate:

    1) TCP Client-Server and Database:

    Multiple/single TCP Client send JSON data to TCP Server using sockets. TCP Server make connection to the Database and store the received data in Database.

    2) Web Application:

    Now as soon as the data is stored successfully, I like to show the same data on client side/browser. For this I guess I need to send a command or trigger an event (sorry I don't know the technical terms) on client side. This command should be sent from Web Application server to the client/browser or web application.

    Now there are 2 options to do this.

    a) Either I send the new data (received from the TCP Clint) from Database as JSON with command and command calls a function on client side/browser to show received data.

    b) I send the command and it trigger an event on client side or call a function on client side (maybe use JavaScript). The function on client side then asks for data from same database (just as it ask when the page is loaded for the first time) and then update the page if there is any new data added in database. (I guess this can be achieved using Ajax calls, but to show data in real time making a lot of ajax call to fetch data from server is not good option as far as I think)

    The Problem:

    Let's come my problem. I am fresher/newbie and as far as I know, the Part 1 of this project (sending the data using tcp sockets and storing it in database) is a completely different thing than Part 2 (web application). I want to know how I can connect these two so that as soon as TCP Client sends JSON data to TCP server and it successfully store the data in database. The web application server will get to know that new data has been received and stored in database and then web application server will immediately send new data to the client/browser and client shows it on the user interface.

    I think as soon as the data is successfully stored in database TCP Server have to call a function that will tell web application server that new data has been received and web application server then do the rest of the part like retrieving the new data and sending the data to the client.

    Here is the image of data flow according to "me" - https://i.imgur.com/ujDd9Dk.png

    What I want to know:

    I want to know how I can achieve this?

    What are the different ways? or what is the best way?

    Plus, I want to know what I should study to achieve this? I mean what topics or technology (?).

    Suggestions for achieving the same without real-time data visualization on client site is also acceptable.

    I know many of you may ask – why am I using sockets for storing data in database? This is the only option I have for now. Please suggest other option if in case I need to remove sockets later

    I have to make the same project using python and C Sharp technologies, like I can use flask, Django when I build this using python and Asp.net mvc when building the same using c sharp. So it would be good if you can suggest things from these two technologies.

    I have knowledge about: Basic of all the following - HTML, CSS, JavaScript, Asp.net MVC, Flask, Django, Python, C Sharp.

    Request: Please use easy language, I don't know a lot of jargon.

    TL;DR : I want to build a Web Application in which data (JSON) is sent from multiple/single TCP Client Socket to the TCP Server Socket and then stored in Database by Tcp Server. The Web Application server then accesses the same database to show data on client/browser. If possible, I want to show the data on browser as soon as it is successfully stored on the database by tcp server (you can say in Real-Time) although suggestions for achieving same without real time visualization on client side is also good.

    For example: Just like stock or share market apps or websites where we see the stock or share rate going up and down in real time.

    submitted by /u/TryingToBe_Honest
    [link] [comments]

    Controlling a browser from an external script? (No, not with Selenium)

    Posted: 07 Sep 2021 07:58 AM PDT

    Use-case

    1. A native desktop app has a list of websites to block (set by user).
    2. When a "blocked" website tab is opened in browser, the external app should close it.
    3. For simplicity, let's assume the native app runs the script every 5 seconds, and has code something like -

    tabs = browser.tabs() for tab in tabs: if tab.url in BLOCKED_APPS: tab.close() # As a result, "blocked" tabs can stay open for max 5 seconds before being closed. 

    Problem

    How do I close the browser tab when a blocked website is visited?

    Is there a Chrome API/SDK I can use to connect the external script? I haven't been able to find one. Explored remote-debugging, but no user launches their browser via the CLI, and that too with the debug flag set.

    Extras

    • Why not Selenium? Because you only control the browser instance you opened with Selenium, not an existing one.
    • Which language? Basically any one works (Python & JavaScript are preferred), since the end result is gonna be a binary that the desktop app can call to close tabs.
    • It's preferred to not use an extension, but I appreciate ideas about that as well.

    Thank you!

    submitted by /u/roshnet
    [link] [comments]

    Would you make this line a helper function or not?

    Posted: 07 Sep 2021 03:40 AM PDT

    I use this line in a couple of places around the codebase:

    const sizeOfObjectInBytes = (obj: any) => Buffer.byteLength(JSON.stringify(obj));

    Would you keep it as is or make it a helper function?

    The reason I ask this is primarily readability as I could see how it wouldn't necessarily be immediately obvious what the code does (especially if you haven't used it before).

    submitted by /u/edvin123212
    [link] [comments]

    Help me set up something that my (Java) students can query for a simulation?

    Posted: 07 Sep 2021 06:27 AM PDT

    Hi! I'm a secondary school computer science / (Java) programming teacher who's comfortable with data structures and algorithms but I have NO networking experience. I have an idea for a fun project that I don't know how to do, but I feel like it's possible, and I'd like to try to figure it out if I can get an idea of what I'd need to learn.

    I want students to be able to write an agent in a stock market simulation. I want them to interact with something I make that feeds them stock data, and I want their program to read that data, process it with conditionals and basic line-fitting, and have them manage an amount of fake money with a few fake stocks to choose from.

    How do I make something central that feeds consistent, but unpredictable (to them) data when their programs are ready for a test run? I could do a rudimentary version by just giving them a .csv and file-reading code, but I think doing this as a networked interaction would be more exciting and could raise a lot of interesting questions.

    So what I'd love help with from someone who can do this:

    - How much time do you think this would take me to set up? Assume I'm a generally good problem-solver and decent data/algorithms programmer with no networking experience.

    - Could you phrase what I'm trying to do with precise technical language (e.g. "You want to set up a zigzog server (that can be hosted for free on Heroku as long as you limit the requests) that uses TFLC protocols to return data whenever another computer makes a flimflam request.") This will help me to search for tutorials!

    - Maybe a sub-question of the above: What services and/or libraries will I need to use and fit together?

    - If you have or know of any examples of similar projects or tutorials, that'd be much appreciated!

    Thank you!

    submitted by /u/Questions4576
    [link] [comments]

    Extension that sorts out followers of a somewhat big Instagram page?

    Posted: 07 Sep 2021 06:10 AM PDT

    I have been trying to find a person on instagram whose name i dont know, but i know for sure that they follow this one page which has like 17k followers, and although ive been scrolling through them its a bit tough to search them all and not be scared of missing anyone that could be said person. So i was wondering if there's an extension out there that sorts out instagram followers to different characteristics, such as the time when they've followed the page, like from latest to oldest, or their gender and wether they have an actual profile picture or not. Any help would be greatly appreciated! Thanks in advance :)

    submitted by /u/sindiziu
    [link] [comments]

    How to Understand Large Projects

    Posted: 06 Sep 2021 11:59 PM PDT

    Right now I am looking at the react github page there are so many files and there is so much code, I find it to be extremely overwhelming. Even though I am familiar with vanilla javascript, I still have no idea how to begin fixing even a 'good first issue'. Any help or tips will be appreciated.

    submitted by /u/Ok_Coffee_6913
    [link] [comments]

    How to estimate minimum hardware requirements for a particular program?

    Posted: 07 Sep 2021 05:55 AM PDT

    So, basically, I was given a project in ML/SE to extract text from a set of 46 scanned PDFs, and then compare them with original .docx files. Though I have a mediocre laptop for work, the program runs quite OK on it, but I don't know what is the minimum requirement for the hardware the client can possibly use. How do you estimate it?

    submitted by /u/__DW__
    [link] [comments]

    doubt in PROLOG exercise (exam tomorrow pls help ;_;)

    Posted: 07 Sep 2021 05:49 AM PDT

    I was doing this prolog exercise with constraints where each of the subfunctions that i did seems to work correctly but when i run the whole program it doesn't accept any solution for some reason.

    We are given a predicate sequence(+Number, -Sequence, -Cost) where Sequence is a list with numbers from 0 to 3, where each of them appear Number times (for example, (2, [2,0,2,0,1,3,1,3], Cost) would be valid, since each digit from 0 to 3 appears exactly 2 times.

    The Cost is represented in this table, costTable(X,Y,Price), where X,Y are two consecutive numbers in the Sequence, and the Price is how much it costs to go from X to Y. There are only the possibilities in this table, so where [..,2,0,...] would be valid, [...,2,3,...] is not, since there isn't any line in the table with the values (2,3,_). The final Cost is the sum of all the Prices (for example: (2, [2,0,2,0,1,3,1,3], 15)).

    costTable(0,1,3). costTable(0,2,3). costTable(0,3,2). costTable(1,3,1). costTable(2,0,1). costTable(2,1,4). costTable(3,1,5). costTable(3,3,2). 

    I did the following code:

    sequence(Number, Sequence, Cost):- Length is 4*Number, length(Sequence,Length), domain(Sequence,0,3), checkNumber(Number,Sequence), cost(Sequence,Cost), labeling([minimize(Cost)],Sequence). checkNumber(Number,Sequence):- count(0,Number,Sequence), count(1,Number,Sequence), count(2,Number,Sequence), count(3,Number,Sequence). count(N,XTimes,List):- delete(List,N,NewList), length(NewList,NewLength), length(List,Length), NewLength #= Length-XTimes. cost([_|[]],0). cost([X,Y|Sequence],TotalCost):- costTable(X,Y,Cost), cost([Y|Sequence],NewCost), NewCost #= TotalCost-Cost. 

    Where checkNumber (that calls count) makes sure that the Sequence has each number from 0 to 3 appearing Number of times and cost calculates the total cost of the sequence.

    I tested each of the functions sepparately and they all worked correctly, but when i run the program with the predicate (2,Sequence,Cost) it simply returns no. I tracked it and it stops on the first iteration of count, on the last line (NewLength #= Length-XTimes), but I don't see why.

    I would really appreciate if anyone could help me here, ty in advance :)

    submitted by /u/koreesa
    [link] [comments]

    How to access a cloud database from a windows forms application?

    Posted: 07 Sep 2021 12:27 AM PDT

    Hi everyone!

    I'm developing a preventive maintenance tool for my internship. Basically, I need to collect machine data, store this data in a DB and then visualize this data. Based on this data the program must send a notification when maintenance is necessary.

    I would like to host my own cloud server on OwnCloud on a Raspberry Pi on which the database can run. A desktop application (windows form) must then have access to this database, and use this data to create plots, graphs and predictions.

    Does any one of you have experience in this? Or any advice/ideas?

    I want to keep costs low, so that's why I want to try hosting my own cloud server first before going to AWS or something similar.

    Any advice is much appreciated!

    submitted by /u/Disasterhawk
    [link] [comments]

    what skills do I have to develop in order to easily get hired as a entry level programmer( in python)?

    Posted: 07 Sep 2021 12:09 AM PDT

    I've recently started to learn python by taking udemy courses. I'm currently in my third year of college (not a CS degree) and would like to get a job that pays decently. so, I'm wondering what skills should I focus on getting better( job focused) at and are there any certificates that you would recommend I take to get easily hired.

    submitted by /u/Positive-Mood-3738
    [link] [comments]

    .XSL to .JSX conversion help

    Posted: 06 Sep 2021 11:30 PM PDT

    I have a software that accept only .jsx file but i have .xsl file to give input. Is there some way I can convert xsl to jsx file, or can i call xsl file from jsx file, or can i embed the xsl file in jsx file, I don't know both of these language so this thing is really getting in between my work . Help is really appreciated.

    submitted by /u/Material-Economics13
    [link] [comments]

    No comments:

    Post a Comment