• Breaking News

    Sunday, January 31, 2021

    What's the most important thing you learned about programming that you use daily? learn programming

    What's the most important thing you learned about programming that you use daily? learn programming


    What's the most important thing you learned about programming that you use daily?

    Posted: 30 Jan 2021 07:03 PM PST

    Pretty much, the question in the title :)

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

    4 Ways to Create a Modal Popup Box with Html, CSS and Vanilla JavaScript

    Posted: 30 Jan 2021 07:13 AM PST

    How much faster is C++ than Python?

    Posted: 30 Jan 2021 04:31 AM PST

    I keep hearing that C++ is faster than Python. But I also read (can't quite remember where) that since Python 3 it's actually become similar in speed. Does anyone know what a speed comparison for these languages would be?

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

    To learn Java or not

    Posted: 30 Jan 2021 06:31 PM PST

    I been learning only for about a month now and started the CS50 course. I want to end up making a career switch at some point since my biology degree kind of just sits there. I'm wondering if I want to get a job is web developer a good route or to learn Java and some more app based stuff. I'm still fairly new but like learning on the topic. But basically for job potential wise are there more job potentials working with Java? If so what kind of path could you take with Java?

    submitted by /u/According-Winter-766
    [link] [comments]

    Caesar Cipher: some words of encouragement

    Posted: 30 Jan 2021 04:56 PM PST

    The Caesar cipher is a common programming exercise and for whatever reason I just could. Not. Get. It. I have spent endless hours trying to sort it out, lol. Anyways, I have finally realized the solution and some people are probably thinking "well, it's not that difficult", but it's a good reminder that certain problems are just going to be more challenging for certain people -especially when you are learning independently. So don't be too hard on yourself when you reach a challenge like this.

    (The Caesar cipher solution that eluded me for so long is that the cipher key needs to be understood in terms of the number of letters in the alphabet, and so any key over 26 is simply beginning again after 26 since that's the number of letters in the alphabet. So we take the modulo 26 (remainder) in those cases and just work with that...)

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

    What should I learn (Everything I try to learn, I later find out is deprecated/dead or no longer used)

    Posted: 30 Jan 2021 05:26 PM PST

    This just happened recently, but I was learning Xamarin and C# for Android apps. I just recently found out that Microsoft will discontinue it in November of 2021. This made me lose my motivation to start learning Xamarin in the first place because when I am done, it will already be obsolete. This happens to everything I try and learn. I need some help to see what I can learn and stick to in the long run. I want to learn C/C++, but I have no idea what to do with them. Can anyone tell me what I could look into learning? I would prefer doing something with C/C++/C#, but I would like to see what others think would be the best path to take.

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

    What are some good free JAVA Udemy courses for a lacking CS student?

    Posted: 30 Jan 2021 08:09 PM PST

    It seems like I am lacking a lot in terms of knowledge if I compare myself to others in my class. What are some good free udemy courses? I know the basics but I'm kinda not confident with the collections part and streams.

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

    A few questions about Spring Boot ModelAttribute and RequestMapping annotations

    Posted: 30 Jan 2021 05:55 PM PST

    I'm somewhat familiar with how routing and callbacks work in Node.js, but am very new to it in Java. I've never worked with Spring before, so I'm a bit perplexed about how it works.

    The code examples have been taken from here: https://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation

    Take the code:

     @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) public String submit( @ModelAttribute("employee") Employee employee, BindingResult result, ModelMap model) { if (result.hasErrors()) { return "error"; } model.addAttribute("name", employee.getName()); model.addAttribute("id", employee.getId()); employeeMap.put(employee.getId(), employee); return "employeeView"; } 

    I understand that @RequestMapping is just mapping the endpoint to this method, however what I don't understand is:

    1. Where are the method parameters "coming from" when the method is invoked? I don't know where ModelMap is coming from. In Node.js Express I believe they were just parameters that were sort of pre-set in the framework, but here I'm not sure what these methods ever are or who they're being invoked.

    2. How does it know what @ModelAttribute("employee") is? This is coming from the View (the HTML), right? Does that mean all @ModelAttributes need to be pre-defined in the View?

    3. What is Model really? Is it just type of map of <String, Object>? What's the lifespan of the Model?

    4. How does @ModelAttribute("employee") know what fields we want to bind to our Employee object?

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

    Python book/course/resource to teach programming essentials?

    Posted: 30 Jan 2021 08:59 PM PST

    Hey,

    I'm looking for a Python resource that doesn't necessarily focus on Python, but moreso the important fundamentals associated with programming for a beginner. By this I mean things like object oriented programming, flows, data types, classes, and other things of that nature. I looked through the resources in FAQ but wasn't sure what would be good for teaching the important fundamentals to make sure that work flows are smooth, organized, and make sense to others if they were to look at it.

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

    Discord Bots -> Data storing, how to do it right and what is the most optimal way? And bot testing.Q

    Posted: 31 Jan 2021 12:08 AM PST

    Hi,

    Question 1: Storing data from multiple severs

    Lately I've been developing a discord bot for me and my friends (it's an exam reminder bot). But I would like to upload it to more users. And my point is what it the best way to store data? Right now I'm using sqlLite and Heroku for deployment, but before going "official" with my bot I'm thinking of changing sql lite to Postgres, but when my bot will be "official" how should I store data for every sever it's on? Add some additional sever id table with would be a foreign key for my main table. Or maybe there is some other better option?

    Question 2: Unit testing the bot

    My second question would be how to unit test the discord bot? Just like the regular code or maybe it need some functional tests? I'm writing it in JS and I'm a Swift developer so I'm used to tests but haven't yet wrote those in JS so if have any good materials I'm all for it :)

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

    How to read bytes from a file into a single string using readAllBytes?

    Posted: 30 Jan 2021 03:52 PM PST

    I'm taking an algorithms class where we have to implement LZW compression in Java. I decided to use a Trie data structure for this, and I've already implemented the Trie and got it working with strings.

    Now, I would like to read the bytes from a file, convert them to padded binary (00000001 instead of 01) and then store them in my Trie. I don't need help for the Trie, but rather for reading the contents of the file.

    I've tried using readAllBytes to read the contents, and appending each converted byte to a StringBuilder, but when I do this, I get a StringBuilder full of 48's and 49's. I think my binary data is being converted to ASCII, which I don't want. I simply want a string with 1's and 0's.

    Here is a method I've used, but it doesn't use readAllBytes, and it's very slow:

     File file = new File(path); ArrayList<String> codes = new ArrayList<String>(); try (FileInputStream fileInputStream = new FileInputStream(file)) { int singleCharInt; while ((singleCharInt = fileInputStream.read()) != -1) { codes.add(Integer.toBinaryString((singleCharInt & 0xFF) + 0x100).substring(1)); } } return codes; 

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

    Beginner in need of help with C++

    Posted: 30 Jan 2021 06:55 PM PST

    I have written the easiest part but I need help with the equation. I would appreciate any help.

    Assignment

    Write a program that will prompt the user for length, width, and height and calculate the surface area of a pyramid using the formula given.

    x=Lw+L\sqrt(((w)/(2))^(2)+h^(2))+w\sqrt(((L)/(2))^(2)+h^(2))

    length = 5

    width = 6

    height = 3

    My code so far:

    #include <iostream>

    using namespace std;

    int main()

    {

    double length, width, height;

    cout << "SURFACE AREA OF A PYRAMID" << endl;

    cout << "Enter length: ";

    cin >> length;

    cout << "Enter width: ";

    cin >> width;

    cout << "Enter height: ";

    cin >> height;

    cout << "Surface area: " << endl;

    return 0;

    }

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

    I can’t do it.

    Posted: 30 Jan 2021 05:39 PM PST

    I really want to do it. I promised myself that I will master one of the programming languages in 2021. And I'm practicing. I don't want to give up. I have already given up on my profession and I don't want to give up on this. I can't even do the FreeCodeCamp's Random Quote Machine. It seems a lot to me. And i know that's one of the easiest task. Any advice? I don't want to be trapped in YT tutorials. I want to do it myself but i cant.

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

    Web vs mobile for beginner ?

    Posted: 30 Jan 2021 06:19 PM PST

    What makes web development easier for beginners when compared to mobile development ? I find web too have alot of tools and require wide range of knowledge, while mobile is more condensed any help on the matter would be appreciated.

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

    What is the rule of thumb of what to put in a Http Request headers, body?

    Posted: 30 Jan 2021 11:04 PM PST

    What kind of data should I put in the header and body when I make a post request? Can't you just put the header data in the query parameters, why do you have to put it in the headers?

    For example if I have a shopping cart app, would I place the user logged in authentication token in the query parameters, and the shopping cart items in a Json for the request body?

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

    Hello i have been learning programming with python for a week and decided to make a calculator based on what i've learned. can anyone tell me that is this good for beginner learner?

    Posted: 31 Jan 2021 02:43 AM PST

    # A=int(input("Enter you're first number:"))
    # B=int(input("Enter you're second number:"))
    # c=int(input("Enter what u want to do with them: 1.+ 2.- 3.// 4.*"))
    # def plus():
    # return A+B
    #
    # def minus():
    # return A-B
    #
    # def multiply():
    # return A*B
    #
    # def divide():
    # return A//B
    #
    # if c==1:
    # print(plus())
    # elif c==2:
    # print(minus())
    # elif c==3:
    # print(divide())
    # elif c==4:
    # print(multiply())

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

    Need help counting sequences of “-“ in strings

    Posted: 31 Jan 2021 02:37 AM PST

    I'm coding in Python (3.8) and I can't seem to figure out how to do this: Let's say I have two strings of equal length: a = "-C—-CC-" b = "A-GCT—T" I want to compare these two strings and see how many continuous sequence of characters are aligned with how many continuous sequence of dashes.

    Note: two dashes will never be aligned

    So if I compare a and b, I get [1, 1, 3, 2, 1] where 1) 1 : from "-" in a and "A" in b 2) 1 : from "C" in a and "-" in b 3) 3 : from "—-" in a and "GCT" in b 4) 2 : from "CC" in a and "—" in b 5) 1 : from "-" in a and "T" in b

    Any help will be greatly appreciated! :)

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

    Skipping else statement. Super basic problem that is getting me pretty hard.

    Posted: 30 Jan 2021 10:50 PM PST

    Im doing input validation and the if statement to check the number parameter is getting me pretty good. I thought i had these down lol. I have the input as a string, checks for if its numeric, then i convert the string to an int and check to see if its in the number parameter. My logic is right for the if statement(or im just being a dumbass and missing something easy) and its skipping the else statement. Im 90% sure its something with converting the string to an int because i got it to work before checking for if its numeric and also the input was an input before added the other stuff. I tried debugging and the numsize is coming up as an int for the number parameter. Never would of thought converting to an int would kick my ass so much lol. Heres the code.

    Edit: Actually just typeid(numsize).name() in the output and it said its an int so its not the converting, its most likely me just being dumb with the logic.

    #include <iostream> #include <cctype> #include <string> #include <cstdlib> #include <sstream> using namespace std; int main() { string size{}; int numsize{}; bool inbounds = false; do { cout << "Pick a number between 2 and 20: "; getline(cin, size); // checks to see if bounds for (int i = 0; i < size.length(); i++) { if (isdigit(size[i]) == false) { cout << "\nThats out of range. Please pick a numeric value.\n\n"; size[i] = '0'; } } numsize = stoi(size); if ((numsize < 3) || (numsize > 20)) { cout << "\nThats out of range. Please pick a number between 2 and 20.\n\n"; } else { inbounds == true; } cout << "You picked: " << numsize << endl; } while (inbounds == false); 
    submitted by /u/HousePappas
    [link] [comments]

    [Java] How do you use a hashmap to store (a,b) : Integer ?

    Posted: 31 Jan 2021 02:29 AM PST

    In CTCI, trying to solve "Find all integer solutions <= 1000 of a3 + b3 = c3 + d3 "

    The pseudocode solution (the first half) is:

    n = 1000 for c from 1 to n for d from 1 to n result = c^3 + d^3 append (c,d) to list at value map[result] //how to declare?? for a from 1 to n for b from 1 to n result = a^3 + b^3 list = map.get(result) for each pair in list: print pair1, pair2 

    How do you declare a hashmap in Java that can store a pair of coordinates (c, d) to a value?

    Would it be something like...

    Map<ArrayList??, Integer> map = new HashMap<>(); 

    Edit: Added in the second half. Looks like the 'map' actually contains a LIST of coordinate pairs mapped to a value...not just a coordinate pair.

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

    Where do you use algorithms and problem solving?

    Posted: 30 Jan 2021 03:07 PM PST

    So I'm learning web development, I'm currently learning react. I know little bit of JavaScript.

    People keep saying " it's all about algorithms/problem solving", what's that supposed to mean ? I've never used it nor do I know what they mean.

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

    Hello How can I improve and solve the error in the code, can someone help me please? thank you

    Posted: 31 Jan 2021 02:22 AM PST

    costSmall=10.25 costMedium=12.88 costLarge=15.25 total=0.0 number=0 size="" number=float(input("number of t-shirts: ")) size.upper() size=float(input("size of t-shirt (S, M, L): ")) print(size.upper()) if (size=="S"): print(total=number*costSmall) elif (size=="M"): print(total=number*costMedium) else : print(total=number*costLarge) 

    number of t-shirts: 1

    size of t-shirt (S, M, L): s

    Traceback (most recent call last):

    File "<string>", line 10, in <module>

    ValueError: could not convert string to float: 's'

    >

    submitted by /u/Glass-Blackberry6474
    [link] [comments]

    Learning from books in 2021: How much the information available online compares to traditional learning?

    Posted: 30 Jan 2021 01:29 AM PST

    Sometimes I see people talking about which books about some language are good and things like that.

    In the last 15~20 years the Internet really changed and shaped a lot of things in a new way so I was wondering how much it changed the learning side of programming and related jobs.

    Softwares and frameworks are being updated all the time and books have this problem that after being printed they won't change.

    So right now in 2021 are books the better option even if the internet itself was made by programmers? Someone who focused only in "online learning" will lack knowledge when compared to someone who went after some books?

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

    Having trouble with creating a static library in visual studio with c++

    Posted: 30 Jan 2021 06:20 PM PST

    I am trying to make a static library to link to a c++ project I made so that I can build it all into a standalone .exe file.

    The problem (I think) I am running into is creating a .lib file from the static library project that I am trying to make.

    For a basic sense of the Solution, I have:

    Main Project (console app)

    Static Library (static lib)

    The main project uses rapidjson, which I have the include .h files for already. It also uses a .json file with data to read from. The main project works fine if I include them in the source files, but then I can't run the .exe since they don't get packaged, so that's why I need to make a static library.

    Finally, my question is, what can I do to have the rapidjson .h files and my .json file in the Static Library link in my Main Project .cpp file?

    I've added the Static Library as a dependency to the Main Project, and included it's directory in the Main Project's properties. It doesn't even create a .lib file when I try to build both the Main and Static projects.

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

    No comments:

    Post a Comment