• Breaking News

    Friday, May 14, 2021

    Starting Programming Full-time learn programming

    Starting Programming Full-time learn programming


    Starting Programming Full-time

    Posted: 13 May 2021 08:22 AM PDT

    I just really need to get this off my chest, and get it out there.

    After a year and a half of learning programming on the side, about an hour a day, becoming more and more interested in it, and wanting to do a career transition, I left my job today, a job I had no passion for and have been mentally checked out of for the last 6 months anyway, to study programming full time.

    My goal is to have a job in web development by the end of the year, or early next year. I hope I'm making the right decision for myself here, but I am determined to do this. Wish me luck!

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

    Is using a while(true) loop bad coding practice?

    Posted: 13 May 2021 03:01 AM PDT

    I was talking to someone on Reddit not long ago, and he was giving me some advice for coding interviews. He noticed that I had used a while (true) loop to print a menu from which the user could choose various options, with a break statement to end the loop (and the program) when the user was finished. He made the statement that if he were interviewing me, he would ask about the while (true) statement and that if I didn't see that as problematic, that would be a red flag for him.

    So I googled it, and there are several questions on Stack Overflow about it, and some people don't seem to mind, and others say that's it's bad practice because you could end up with an infinite loop. That doesn't make any sense to me, because you could end up with an infinite loop anytime you use a while loop, right? So what's the difference?

    To further compound my confusion, I've finished the first of The University of Helsinki's Java MOOC and am nearly halfway through the second part and they make use of this format in practically every time you're asked to get input from a user.

    So to the actual engineers of Reddit, in the professional world, is this considered bad practice or no? If so, what differentiates a while(true) loop from any other while loop?

    edit: Here is the actual code in question, if anyone is interested:

    while True: print("\nWhat would you like to do?") print("\n\n1. Export Test Results\n" "2. Increase Chlorine\n" "3. Neutralize Chlorine\n" "4. Increase Total Alkalinity\n" "5. Decrease Total Alkalinity\n" "6. Increase Calcium Hardness\n" "7. Increase Stabilizer\n" "8. Calculate Saturation Index\n" "9. Print Water Chemistry Guidelines\n" "10.Exit") user_input = input("Please make a selection from the menu. ") try: int(user_input) # checks user input and calls the correct function if user_input == "1": export_test_results(daily_tests) elif user_input == "2": increase_chlorine(pool_factor) elif user_input == "3": neutralize_chlorine(pool_factor) elif user_input == "4": increase_TA(pool_factor) elif user_input == "5": decrease_TA(pool_factor) elif user_input == "6": increase_CH(pool_factor) elif user_input == "7": increase_stabilizer(pool_factor) elif user_input == "8": calculate_SI(daily_tests) elif user_input == "9": print_table() elif user_input == "10": print("\n\n****Thank you for using the Pool Maintenance Program!****") break else: print( "\n\nI'm sorry. Your selection was not valid. Please enter a number from the menu below.") except: print("\n\n****Input must be a number. Please try again****") 

    You can see the whole program here: https://github.com/Joshua-Byrd/PMP. It's just a simple chemical calculator for pool operators. Also, if anyone is confused as to why I'm talking about Java and this is clearly in Python, it's because I started in Python last year, but I have an upcoming class in Java, so I've been working on that lately. Thanks to all who have replied so far!

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

    Feeling lost

    Posted: 13 May 2021 09:50 PM PDT

    I'm 33 and decided to try pursuing programming as a career after diving into Excel formulas at work. Late last year I finished the Java Programming Masterclass by Tim Buchalka on Udemy after about a year on and off working through it, and I feel like I have an okay grasp of Java and am beginning to think like a programmer, but I don't have a great idea of where to go from here. My end goal is to land a full-time job as a programmer/software developer, but I've just been feeling a little lost lately.

    I've made a few applications that are of use to me, like a JavaFX application that keeps track of Pokemon GO data using SQLite and some 3rd party libraries, a savings goal application that adds and updates different savings goals, and one that unzips and renames video files for use with Plex Server.

    Do I just have to keep making new programs while improving my existing ones, adding new features and searching for ways of implementing ideas I have? When I have a new idea for something to implement in one of my current apps or a new app, I can spend hours coding but afterwards I feel the same lack of direction. I know about all of the suggestions for projects, but is that really all I need to do? Just keep making new things and eventually I'll be at a point where I can apply for a job? Is it normal to feel this way?

    I'm sorry if any of this isn't appropriate for this sub. I don't know anybody else who's gone through this and don't know anywhere else I can ask. Thank you to anyone who responds.

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

    Java program will not compile is command line?

    Posted: 13 May 2021 11:27 PM PDT

    I have written this code in notepad -

    public class Main{

    public static void main(String[] args){

     System.out.println("Hello"); 

    }

    }

    class AnotherClass{

    System.out.println("Hello from another class");

    }

    But when I try to compile it using javac Main.java , it shows the following error -

    Main.java:8: error: <identifier> expected

    System.out.println("Hello from another class");

    ^

    Main.java:8: error: illegal start of type

    System.out.println("Hello from another class");

    Can someone tell me what I'm doing wrong? Thanks for helping out :)

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

    Here's how to get CPU usage percentage of current process from inside of your program. (C, C++)

    Posted: 13 May 2021 06:51 PM PDT

    Note; This is Windows specific

    It took me lots of searching and I couldn't find a single straightforward way of displaying the percentage usage of a process the same way you see it in Task Manager. So after the time I spent to finally figure it out, I decided to share my result in case someone is having the same issue when working on their own engine. so here it goes:

    The problem with CPU usage measuring is that the CPU processors are either on or off, you can't really measure how much of a processor is working. you can measure how ever how many are working from overall at one instance of time, but that still doesn't show you the average over time, which is what Task Manager does. Now I found this code from this URL, so credits to them for it. It measures CPU resources by current process, but there's a catch (more below) I will paste the initial code here as it is part of this solution:

    #include "windows.h" static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU; static int numProcessors; static HANDLE self; void init(){ SYSTEM_INFO sysInfo; FILETIME ftime, fsys, fuser; GetSystemInfo(&sysInfo); numProcessors = sysInfo.dwNumberOfProcessors; GetSystemTimeAsFileTime(&ftime); memcpy(&lastCPU, &ftime, sizeof(FILETIME)); self = GetCurrentProcess(); GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser); memcpy(&lastSysCPU, &fsys, sizeof(FILETIME)); memcpy(&lastUserCPU, &fuser, sizeof(FILETIME)); } double getCurrentValue(){ FILETIME ftime, fsys, fuser; ULARGE_INTEGER now, sys, user; double percent; GetSystemTimeAsFileTime(&ftime); memcpy(&now, &ftime, sizeof(FILETIME)); GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser); memcpy(&sys, &fsys, sizeof(FILETIME)); memcpy(&user, &fuser, sizeof(FILETIME)); percent = (sys.QuadPart - lastSysCPU.QuadPart) + (user.QuadPart - lastUserCPU.QuadPart); percent /= (now.QuadPart - lastCPU.QuadPart); percent /= numProcessors; lastCPU = now; lastUserCPU = user; lastSysCPU = sys; return percent * 100; } 

    The problem with this code is that while it works at getting the CPU percentage of the current process, the results are way too accurate to be useful. if you printf() the result of getCurrentValue() you will get a bunch of zeros and occasionally a nonzero value that is high like 50% or more, which isn't really that useful as it doesn't show you an overall view of what's happening.

    This is -I assume and am not sure of- the dedicated core or nodes of your CPU that are working on your process. Since the CPU multitasks, it won't be doing your process constantly but rather occasionally, especially if your process is FPS-capped.

    So what's the solution of this? simple, lets just measure the average of these recordings.

    double CPU_Recordings[100]; // an array where we store CPU recordings double count = 0; // a counter to keep track float ActualUsage = 0; // where we store the end result while (1) // this is the game loop { CPU_Recordings[count] = getCurrentValue(); // save one recording count++; // increment counter if (count == 100) // every 100 counts (when full) { count = 0; // reset counter float CPU_sum = 0; for (int i = 0; i < 100; i++) CPU_sum += G->Debug.CPU[i]; // calculate the sum of the array ActualUsage = CPU_sum / 100; // devide by 100 to get an average } printf("%.1f %% \n",ActualUsage); // spit out the result } 

    (of course you can adjust array sizes and increment frequency to change how often this updates)And voila, we have a result that is really close to what the Task Manager shows, something that could be of use to display how much CPU resources you are using.I hope this helps, and if there is any mistake or comment on this or how to improve it, I would gladly hear them.

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

    I want the to know if I should start to learn programming again. Is it worth it? Do you feel like your changing the world or just another person working behind a desk in a cubicle?

    Posted: 14 May 2021 12:33 AM PDT

    I used to program before, I used to program in middle school and have stopped in high school. Any input would be appreciated.

    submitted by /u/No-Clock9273
    [link] [comments]

    How to measure engagement in a video chat application?

    Posted: 13 May 2021 11:04 PM PDT

    I have developed a website in Django where users can randomly pop into rooms to have a conversation. Imagine something like a video reddit

    This is more of an architecture question than a code question. How do I measure usage? I want to track how long users spend in each room, which rooms are popular, get a history of every room that a user has visited to understand their user profile

    The most naive thing that I can think of is to create a new table in the database called usage where I log every event such as user entering a room with timestamp, user leaving a room with timestamp that would look something like this for eg -

    user room event timestamp
    1 bitcoin join_room 1620632092
    2 comedy join_room 1620632094
    1 bitcoin leave_room 1620632292
    3 politics join_room 1620632295
    3 politics leave_room 1620632296
    4 dogs join_room 1620632296
    5 python join_room 1620632296
    4 dogs leave_room 1620632296
    5 python leave_room 1620632296

    With this database architecture, I would have to run really complex SQL queries to understand how much time users spend in each room.

    Is there a better way to do this?

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

    Building a Youtube channel for solo devs. Got questions for a solo dev that I can address in a video?

    Posted: 13 May 2021 07:52 PM PDT

    Hi Reddit,

    I am building a Youtube channel to provide knowledge, skills, and insights to build beautiful mobile and web apps and give a behind-the-scenes look as I build out my own solo dev business. I'm a software engineer and data researcher who's just made the leap into her own business. I am currently under contract to develop an app that I can hopefully showcase soon. I'd like to solicit community questions from aspiring solo app developers so I can create videos addressing these questions as a resource. So, if you have any questions you'd like addressed in the channel, please let me know!

    Best,

    Alia (YT channel: Alia Akram Apps)

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

    I froze up during a technical interview.

    Posted: 13 May 2021 12:46 PM PDT

    TLDR: Technical interview went awry, I embarrassed myself and froze up on simple questions, and now I feel like an idiot and like I shouldn't be here. Am I being too hard on myself?

    This is long-winded, but I could use some advice.

    Probably one of the most embarrassing things I've ever had to write. I'm fresh out of a one-year long 'coding bootcamp', and have been applying to a variety of jobs in hopes of at least getting a response. My first actual technical interview (two previous interviews were mainly screens, one of which I have a follow-up technical interview with on Monday) for an entry-level Python position went... not so great. It started out good, we introduced ourselves (four people interviewing me), and the main interviewer went through basic HR questions and introduced the company and whatnot. The next interviewer started asking me questions, and I don't know why but my nerves just went awry.

    After a few basic questions, I got asked, "What is object-oriented programming? Can you describe it to me?" I froze. I didn't know how to explain it. I knew what it was, conceptually, but I just completely froze up. All I could say is that it was the ideal that everything is an object. I felt so stupid, because I couldn't answer a simple question. The follow-up question was, "how does a class relate to the ideal of object-oriented programming?" (or something along those lines), and again I just didn't know how to answer that; I tried to explain it the best I could by saying that classes are essentially 'markups' or 'blueprints' for objects, but I couldn't go much further than that. I was so shook. I had just spent the last year grinding my hardest to get as ready as I can and I completely dropped the ball. I felt so embarrassed, and I got that feeling over my entire body where you feel excruciatingly hot and your stomach has that weird feeling. It was terrible.

    I am not sure what I am hoping to achieve with this post. I guess I just need some advice. How can I pick myself up and move on? They didn't say that they weren't moving forward with me, just that they would let me know by Friday. It didn't sound very promising with the way they worded things though.

    Edit: thank you all, genuinely, everything I've read is stuff I need to hear and I appreciate it. I definitely feel like I can come out of this on top and carry this experience into my next interview on Monday.

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

    Ideal way to dump data

    Posted: 14 May 2021 12:40 AM PDT

    Do you guys dump data so that it's awk-able or dump it in format that make sense for the given data and then extract pieces using perl or just dump it in sqlite and query that way? Needs: Reporting and analysis.

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

    Many are against Codecademy because it’s too basic, but isn’t that a good thing for those starting out?

    Posted: 13 May 2021 12:11 AM PDT

    I'm starting from knowing near nothing about coding, and I've gone through a lot of lessons on Codecademy. I've learned a lot about variables, Datatypes, strings and the like. I understand this stuff is ultra-basic, but it's like trying to teach a 5 year old 1+1, then calling 1+1 too basic, when the 5 year old is just being introduced to mathematics. It's really teaching me a lot and I'm just inhaling the info because of how super simple and detailed it is. Should I really just abandon Codecademy? I'm definitely going to get into more complex lessons and actually start building things, though I feel Codecademy is a good starting point... right?

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

    Faster way to solve this problem?

    Posted: 13 May 2021 08:02 PM PDT

    I'm writing a small python script that uses the spotify api to iterate through every song in two users' public playlists and return the songs that are in common between the two users. However, the runtime of this script is pretty bad as i simply iterate through the playlist and add all the songs to a set and use the intersection built-in function to get the songs that are in common. Is there a more efficient approach to solve this problem or is this it?

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

    Why is recursion emphasized so heavily in school?

    Posted: 13 May 2021 03:26 PM PDT

    I'm gradually working my way through OSSU and two of the fundamental courses exclusively use recursion instead of iteration, making the bold claim that recursion is more powerful than loops.

    Yet when I ask my friends, who are already professional software developers, about how frequently they use recursion, they say they never use it.

    This makes me wonder: am I wasting my time by putting this much emphasis on recursion in my studies when I could be studying more practical tools and concepts? Or are my friends just coding sub-optimally? Perhaps a little bit of both?

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

    My 8 year old daughter loves Roblox so I’m convincing her it’s cool to develop games on their platform!

    Posted: 13 May 2021 01:13 PM PDT

    I already bought a new computer so I'm going to set up my old computer in her room and slowly have her learn that shit over time.

    She thinks learning is overrated so I gotta disguise it.

    I'm sneaky. I know.

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

    Web scrapping/automation in python

    Posted: 13 May 2021 08:29 AM PDT

    Hello,

    I am trying to automate the purchase of shares on the website Predictit. My code is currently finding optimal markets to invest in but I'm struggling to automate the purchase of shares because the URL is different every time. The website doesn't have an API so is there any way to automate or scrape the website.

    Thank you in advance

    here is a link to the website: https://www.predictit.org/markets

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

    Learning to code, what web-based compilers and courses would you recommend?

    Posted: 13 May 2021 02:20 PM PDT

    I know a local instance is still the preferred option when coding but I'm trying to learn off a Chrome book so...

    Any websites (preferably free) that you would recommend? I tried Codecademy since it's all web-based, so I liked it, but unfortunately, I need a pro account to progress further so I'm asking here if there are any similar style websites that you would recommend?

    I'm thinking of learning Python or Java.

    Thank you!

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

    need help with abstraction functions and rep invariants

    Posted: 14 May 2021 12:02 AM PDT

    I'm reading the Reading of MIT 6.031: Software Construction.

    In Reading 11: Abstraction Functions & Rep Invariants.

    They say:

    A common confusion about abstraction functions and rep invariants is that they are determined by the choice of rep and abstract value spaces, or even by the abstract value space alone. If this were the case, they would be of little use, since they would be saying something redundant that's already available elsewhere.

    I get abstraction function and rep invariants are not determined by the choice of rep and abstract values because there are more and one abstraction function and rep invariants for one rep and abstract value space. But I don't get why they say:

    If this were the case, they would be of little use, since they would be saying something redundant that's already available elsewhere.

    can someone please explain this to me.

    Many thanks

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

    How to convert multi-character character constant to int?

    Posted: 14 May 2021 12:00 AM PDT

    I am trying to create a switch statement using the parameters that can be passed into my File classes constructor in the modeparameter. However, as mode can be up to 2 chars ('r', 'r+', 'w', or 'w+'), I do not know how to create a switch statement that will get this done for me.

    Does anyone have any suggestions on how to implement this? Currently with what I have below, I am getting errors for the 'r+' and 'w+' cases, as those are not chars. Is there a way I can convert these values to ints so that I can more easily compare them?

    File::File(const char *name, const char *mode) { int fileMode = 0; //Initializing mode to 0 fileName = name; //Setting the file name of this File object to the name we pass in. switch(*mode){ case 'r': fileMode = O_RDONLY | O_CREAT; canWeRead = true; canWeWrite = false; break; // Open a text file for update (that is, for both reading and writing) case 'r+': fileMode = O_RDWR | O_CREAT; canWeRead = true; canWeWrite = true; break; case 'w': fileMode = O_WRONLY | O_CREAT; canWeRead = false; canWeWrite = true; break; // Open a text file for update (reading and writing), // first truncating the file to zero length if it exists // or creating the file if it does not exist. case 'w+': fileMode = O_RDWR | O_CREAT | O_TRUNC; canWeRead = true; canWeWrite = true; break; default: //We should never reach the default case, so I assert(0) assert(0); } fileBuffer = (char*)malloc(bufsiz); //Create buffer with malloc //Free is called in the File class destructor. assert(fileBuffer != NULL); //If fileBuffer == NULL, we did not allocate a buffer. fileDescriptor = open(name, fileMode); /*On success, open() returns the new file descriptor (a nonnegative integer). On error, -1 is returned and errno is set to indicate the error.*/ assert(fileDescriptor >= 0); //If we dont get a positive nonnegative int, we have a problem. } File::~File() { free(fileBuffer); //Free the memory we have for the buffer int rc = close(this->fileDescriptor); //We want to close the FileDescriptor of the current File object. assert(rc == 0); //close returns 0 on success. So if we dont get 0, we have a problem. } 
    submitted by /u/Evening_Bet
    [link] [comments]

    Can someone please help me with my C# program ? I'm trying to modify this modified streamreader which allows you to peek through lines. How would I reset the Peekline everytime I want to use it from a specific line ? Instead of having it continuing from where it previously left when used.

    Posted: 13 May 2021 11:32 PM PDT

    class StreamReaderPeek { private readonly StreamReader Peeking; private readonly Queue<string> PeekQueue; public StreamReaderPeek(StreamReader peeking) { Peeking = peeking; PeekQueue = new Queue<string>(); } // The method assists the method - Peekline() to peek through the next line public string ReadLine() { // We first check that there are elements in the Queue before Dequeuing it. if (PeekQueue.Count > 0) { // Removing and returning the line at the beginning of the Queue. return PeekQueue.Dequeue(); } return Peeking.ReadLine(); } // The method is used to peek through x number of lines in the given file. public string PeekLine() { // Create a line to store the value of the next line in. string peekLine = Peeking.ReadLine(); // If the line does not contain anything return null. if (peekLine == null) { return null; } // Adding the line to the end of the Queue PeekQueue.Enqueue(peekLine); return peekLine; } } 
    submitted by /u/TheArray
    [link] [comments]

    is it okay to upload malware files to google drive?

    Posted: 13 May 2021 11:30 PM PDT

    the malware files are from Microsoft Malware Classification Challenge from Kaggle and It's well known dataset

    The reason I upload them to Drive is that I'm planning to load it from Google Colab

    submitted by /u/Snoo-62877
    [link] [comments]

    Learning more coding languages.

    Posted: 13 May 2021 07:25 PM PDT

    So I have been getting into Python and Arduino coding for about a year now, and while learning both I have noticed that a lot of professional programmers use multiple languages for an assortment of things. I started learning Python for robotics purposes and interacting with online sources but I would still like to know other languages. Are there any suggestions on what languages I should learn to communicate with websites, control real objects (such as motors or other devices like phones or tablets), and build virtual environments?

    I don't know if a flair would fit this sort of question and I am not completely sure if this is a suitable subreddit for this question but it was the closest I could find.

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

    Best course for learning Java (help needed)

    Posted: 13 May 2021 11:08 PM PDT

    Hi guys, I am a CS student. I have used C++ extensively for competitive coding and Python for data science and web development. I want to learn Java Spring Boot. I have never used Java before. I prefer well organised resources for learning something as they help me to map and understand topics/concepts in a tree like structure.

    There are many java courses on Coursera and Udacity and I can't decide which one to go for. These are my preferred sites but other sites are welcome too.

    Thanks for your inputs.

    submitted by /u/8EF922136FD98
    [link] [comments]

    How to ask check for condition based on user input?- Java

    Posted: 13 May 2021 10:56 PM PDT

    Hey Guys,

    I was working on a practice question. This is basically a virtual bank that is supposed to perform different tasks based on the value that the user inputs.

    This is my code:

    import java.util.Scanner;
    public class HW {
    public static void main(String[] args)
    {
    Scanner scan= new Scanner(System.in);
    System.out.println("Enter the balance in your Account");
    int amount= scan.nextInt();
    String response=null;
    do
    {
    System.out.println("What would you like to do today? d for Deposit, w for Withdraw and b Balance");
    String answer= scan.nextLine();
    if (answer.equals("d"))
    {
    System.out.println("How much would you like to Deposit: ");
    int deposit= scan.nextInt();
    amount=deposit+amount;
    System.out.println("Your new Balance is: "+amount);
    }
    else if(answer.equals("w"))
    {
    System.out.println("How much would you like to withdraw: ");
    int withdraw= scan.nextInt();
    if(withdraw>amount)
    {
    System.out.println("Error. Insufficient Funds!!");
    }
    else if (withdraw>5000)
    {
    System.out.println("Withdrawal Attempt Failed");
    }
    else
    {
    amount=amount-withdraw;
    System.out.println("Thank you. Your new Balance is: "+amount);
    continue;
    }
    }
    else if(answer.equals("b"))
    {
    System.out.println("Your Balance is: "+amount);
    }
    else
    {
    System.out.println("Error!");
    }
    System.out.println("Would you like to continue? y/n");
    response=scan.next();
    } while(response.equals("y"));
    System.out.println("Thank you and have a pleasant day!!");
    }
    }

    However, the programming keeps printing error before I can even entire either d or w or b. However it works when I input y or n for the while loop. Im rly confused. Any help is gr8!!

    Thanks

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

    I'm 13 and i don't know what to learn.

    Posted: 13 May 2021 10:39 PM PDT

    So as the title says I'm 13 and I know the beginner level python and tkinter, recently I stopped programming for a while because I don't know what I should learn or do. So any help with what I should learn in python will be appreciated :D Thanks!

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

    No comments:

    Post a Comment