• Breaking News

    Sunday, February 9, 2020

    Am I the only one who manages to forget simple syntax? (Case statements.. where array brackets go..) Ask Programming

    Am I the only one who manages to forget simple syntax? (Case statements.. where array brackets go..) Ask Programming


    Am I the only one who manages to forget simple syntax? (Case statements.. where array brackets go..)

    Posted: 09 Feb 2020 11:09 AM PST

    Title.

    I write mostly in multiple languages but predominately C#..

    Man, I have googled 'C# Case statement syntax' at least 40 times :) Anyone else do this? I mean I'm a competent programmer I feel, but find it hilarious to search for something fairly commonly used every so often..

    Like an array of strings.. I legitimately couldn't tell you/my boss where to put the brackets in this next line.

    string[?here?] arrOfStrings[?here?] = new string[]; 

    I find that both humorous and horrifying..

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

    Do you go on github to just read code? If so how do you do it?

    Posted: 09 Feb 2020 12:11 PM PST

    So ive seen a lot of people that go on places like github to just read some good code. But I tried to do this myself because I want to improve my own coding practices but I don't know where to start. Just to clarify I know how to look at the source code, I just don't know what code to look at.

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

    Help on Nature of Code?

    Posted: 09 Feb 2020 07:00 PM PST

    I am attempting to learn autonomous agent steering behavior and Nature of Code has been a god send. This site has made movement so much simpler and easier. I am actually starting to understand vector math - albeit little by little.

    The bad part is he post "Exercises", but doesn't gave an answer. Usually, I am able to piece things together, but now I am stumped.

    In his exercise 6.13 he asks us to implement the separation force to the path following. While my agents still get to the target they do not avoid each other. They go up on the y-axis and get crazy rotations, and then normally just land on top of each other.

    I guess, I am asking where is the source code? I obviously fail at trying to figure this out on my own.

    I appreciate any guidance on this.

    https://natureofcode.com/book/chapter-6-autonomous-agents/

    edit: his is 2D but I am working with 3d. I have never had a problem with the y-axis before now.

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

    Computer Networks Question

    Posted: 09 Feb 2020 10:10 PM PST

    Can someone help me solve this? I need to for work but not too familiar with TCP New Reno.

    —————————————-

    There is a TCP connection using TCP New Reno. The sender has 44 MSS to transmit. If a TCP connection is already established, the initial congestion window size is 2, the slow start threshold is 8 MSS, and RTT is 100ms. Assume there is no timeout or packet loss in the network.

    How long would it take to transmit all 44 MSS without considering the FIN messaging time? Answer in milliseconds.

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

    Novice java question

    Posted: 09 Feb 2020 08:14 PM PST

    I know this is a really basic question but I'm learning java right now and for our homework assignment we have to build a homework class and it has me lost. any help would be appreciated

    "Specifications for class Assignment:

    This class will contain one method called homework. This method will display your name and the homework assignment name. The homework method takes one argument which is a string with homework assignment name. Example: homework("Homework 2a"); The method homework will display your first and last name and the homework assignment name. Here is a sample output of the homework method:"

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

    How to send mail to multiple recipients on SMTP form

    Posted: 09 Feb 2020 07:09 AM PST

    I have made a form and the user can input multiple email addresses and my program will then send a mail to the email addresses. My program does collect the input but the SMTP is only sending it to one email address.

    Here's my code:

    def results(): userdata = request.form quantity = userdata['quantity'] name = userdata['name'] email = userdata['email'] print(email) msg = Message(subject="Hello", sender='janedoe@gmail.com',recipients=[email], body="Hi!" + name + "This is a test email I sent with Gmail and Python!") # calling mail and the send method and passing the message mail.send(msg) return render_template('results.html', quantity=quantity, email=email, name=name) 

    I was recommended to split it.

    Here's what I did:

    email = email.split(",") print(email) for x in email: msg = Message(subject="Hello", sender='janedoe@gmail.com', recipients= [x], body="Hi!"+name+"This is a test email I sent with Gmail and Python!" ) mail.send(msg 

    Problem: Now the email only gets sent to the second recipient and not the first one. What should I do and why is it only sending it to the second recipient?

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

    How to divide without a DIV instruction or floating-point?

    Posted: 09 Feb 2020 08:03 PM PST

    In the olden days of assembly magic when there was no floating point coprocessors and RISC architecture ruled, how did people divide two numbers without the DIV instruction? I'm specifically thinking of the 6502 processor.

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

    I need some help figuring out what to do with my programming knowledge.

    Posted: 09 Feb 2020 06:21 PM PST

    I need some help figuring out what to do with my programming knowledge.

    I've been coding for a very long time. I'm a 16 year old kid that loves programming and spends all of his free time coding, and would like to become a software developer one day. I haven't had much time to code recently because of school, though. I know many languages very well. I am pretty much all self taught. I would say I am actually pretty good at coding, too, and I also know a lot about compilers, operating systems, networks/networking (switching, routing, servers, …), hardware, and computers in general (not trying to be a dick, just being honest). I also know a lot about Docker, Kubernetes, DevOps, different "full stack" architectures, etc. I also have official teaching experience within computer science and programming. I love learning and experimenting so much... and that's what a lot of my code is... experimental code written just so that I can learn some new technology or software or library.

    I enjoy systems programming and especially network programming. However, I also do a lot of full stack, which is my favorite type of coding in general. My favorite language for the backend is Golang, and I use JavaScript with React for the frontend (just recently learned React). I've written databases from scratch, a crap ton of different REST & HTTP APIs for various different projects, random network programs that utilize raw TCP sockets, and a crap ton of other completely random stuff. I've worked on developing a simple cryptocurrency with my friend and a "portal" full stack web app for a summer camp (which required many thousands of lines of code and had many many features). My GitHub is https://github.com/xoreo.

    Okay, enough about me. Now let's get into my problem. A lot of the programs I've made were made simply because I just wanted to code... something... ANYTHINGGG. If I did not make a program for that reason, I probably made the program to learn a new technology. For example, I didn't write a robust "TCP chat" program in C because I wanted a robust TCP chat program written in C, I made it because I wanted to learn about TCP sockets on a lower level. Another example: my "mystery" repository on my GitHub builds a nifty password exchange/secret sharing protocol on top of TCP and implements a client and server for that protocol. My life didn't have a need for this protocol, but I implemented it as an exercise for myself. I would say that the majority of my code was written for this purpose. In writing even this "exercise" code, I try to follow the best programming practice, making sure not to use any anti-patterns, writing clean, readable code, and writing overall good code. Therefore, a lot of effort goes into my code, even if the end program is not that valuable. This is where we get into where I ask for help:

    WTF do I do with my programming knowledge? I know that I am capable of building cool software… but I really don't know what to make. I really can't think of any problems in my life that need solving digitally, and I really just don't have project ideas. I need something that I can just make that will actually serve a purpose in someone's life. And I know that this is literally the entire point of programming - building software. But most of the programing I've done has been for the sake of programming, not for building some cool end product that other people will find cool. I have put a lot of tools in my toolbox, but they're all useless if I don't use them to actually make something cool. So, what should I do?

    PS: I am approaching the college process, and I don't want to tell them that I used my knowledge of full stack programming to make a "Minecraft Server Hosting Platform" even though my platform works well, was written and documented well, has a somewhat complicated architecture and many layers in the stack, and is somewhat robust.

    TLDR; What do I do with my programming knowledge? I'm at a loss.

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

    Is it normal to have such a difficult time installing anything for programming purposes?

    Posted: 09 Feb 2020 10:54 AM PST

    I recently started using ruby. I decided to learn more I'll try out an open source project.

    Downloaded it, tried following the instructions, each one had its own horror and difficulty.

    Didn't even finish with the set up. I just got so many errors, after fixing it I get to a brick wall. I research for solutions online, and the only solution I can find is not the solution for me. So I try to ask online in two different places, but so far no answer.

    Since I'm waiting, I know people like to say doing any programming on windows is always a horrible experience, so I thought maybe it would be easier if I tried set up on my VM, and use Linux.

    Linux brought me down it's own rabbit hole and I just ended up going back to an old state because I fucked something up trying to get it to work on Linux.

    The problem is this happens ALL THE TIME. I don't know... Why do I bother with programming. I get really eager and motivated to learn, but I always get killed at the stupid setup because nothing ever works. I can't ever get the basic set up to work so I can run it. It's never easy. It's always painful, I'm always left really angry and depressed because I never learn in the end. I feel like an incompetent programmer and every time I try to learn and improve this happens.

    The documentation makes it seem easy! Just five steps! Yeah except it's not, they want you to run one command and it doesn't work. Too many errors, always failing, and barely finished step 2.

    I just don't know what to do any more. I never learn anything because nothing works in the end. I'm tired of all this.

    Is this normal or am I just a major idiot and maybe I should try a new hobby?

    It seems like it should be easy, and people always recommend open source to learn. So if this doesn't work I'm lost, I can't get any ideas for my own projects, and coding challenges only gets me so far. I don't ever get to learn third party tools.

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

    Need some on Thinking Like A Programmer.

    Posted: 09 Feb 2020 10:27 AM PST

    First of I want to start by saying, I'm not a great programmer in any sense of the word, that being said, I'm not new to this field. Coming to my question.

    I was sitting on leetcode for an hour or so unable to think of a solution to a problem, and after an hour of trying multiple ways, I finally gave up and looked up the solution. Turns out it could be solved in a line or so. Feeling pretty ashamed and frustrated that I didn't think of something so simple.

    I really need some advice on how to think like a programmer, and how to approach problems from different perspectives.

    Any book recommendations or some routines that you do I would really appreciate it.

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

    First ever program and I can't seem to get my math syntax correct!

    Posted: 09 Feb 2020 02:47 PM PST

    So this is my first day programming and I wanted to try to create a simple physics problem program where you enter some variables to find the time in the air of a projectile.

    Here's the code -

    import math

    y = int(input("What is your y-value?"))

    y_vel = int(input("What is your initial velocity?"))

    angle = int(input("What is the angle of trajectory from the initial point?"))

    y_vel = y_vel*math.sin(int(angle))

    if y >= 0:

    y = -y

    if y <= 0:

    y = abs(y)

    the_x = int(-y_vel)

    the_sqrt = the_x**2

    rest_sqrt = -4*4.9*int(y)

    top = int(the_sqrt) + int(rest_sqrt)

    top_2 = int(the_sqrt) - int(rest_sqrt)

    bottom = int(2*4.9)

    ans_1 = float(top/bottom)

    ans_2 = float(top_2/bottom)

    if ans_1>ans_2:

    print(ans_1)

    if ans_2>ans_1:

    print(ans_2)

    When I calculate it, I get a way bigger number than if i plugged in the values to my calculator using the quadratic formula. Where is the code going wrong?

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

    How do you all manage working on different computers?

    Posted: 09 Feb 2020 02:30 PM PST

    I'm just a student right now so I'm mostly just talking about like fairly simple programs. Like I've got my laptop and my desktop computer, and I was wondering what would be the best way to easily be able to modify my programs on both my desktop computer and my laptop. I've used github before for kind of bigger projects but I feel like that's kind of overkill for just a few java files, so I was wondering if anyone had better suggestions for how to manage doing work on multiple devices.

    submitted by /u/404WillToLive
    [link] [comments]

    I'm pulling my hair out trying to find a node editor framework

    Posted: 09 Feb 2020 12:42 PM PST

    Hi everyone, I hope you can help me. Quick run-down of what I want to achieve:

    • A UI that allows non-tech users to build code using nodes. This will also help visualize program flow for experienced people as it can get easy to lose track.

    • In the end I want each node to have a translation to code, or in other words I want a string representation that is filled with variables.

    My main problem is that I can't seem to find a node editor framework (any language is fine, really but I would prefer C#, JS or Python). I tried my hands at this awesome python tutorial and got pretty far with another Python implementation but I could not wrangle it into submission on the code generation part. I have all the logic drawn out but fail to find a good implementation. Am I just stupid, it feels like a framework like this has to exist somewhere but node.js's existence doesn't make googling any easier.

    By now I would really appreciate a pointer in the right direction, this thing could be quite useful if only I figured out the starting point. Thanks in advance for any help you can give!

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

    Remote Workstation within home LAN

    Posted: 09 Feb 2020 03:49 AM PST

    Hi,

    Has any of you ever used Desktop machine as a remote workstation daily?

    I have an idea: build powerful desktop machine, Ryzen 5, 32GB ram ect. plug it into home LAN network and "connect" to it whenever there is work to be done. Of course this requires more than just SSH connection, and I wonder if someone has experience with similar solution. Could I use VNC? would it lag terribly? Am I better off with just buying powerful laptop for 2x price of Desktop build? Thoughts?

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

    Am I committing the sin I've always been a snob against?

    Posted: 09 Feb 2020 11:19 AM PST

    Quick context: I'm a C# full stack (so shit at everything) developer.

    I have always disliked the idea of large frameworks on the front-end being a 'catch-all' and 'include-all' or 'hand-holder' since I feel it aids the proliferation of inexperienced software engineers. If I'm writing JS for example, I'm using this cool framework called Vanilla JS. Nothing against FrontEnd devs! You'll make something 10x faster and better looking than me.

    Anyways, I've been working on getting a huge older WinForms (desktop app) into the browser.. I'm using Blazor and it's f**king awesome tbh. Blazor is a awesome framework that allows you to literally write C# code directly affecting the browser. No more JavaScript needed.. yay! Am I committing the sin I've always been against though? It uses WASM... WASM must be the future, it's only growing.

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

    im making a proposal for time table development using android studio, but confuse in methadology, how to make a methadology?

    Posted: 09 Feb 2020 10:06 AM PST

    Making youtube video compiler - help needed

    Posted: 09 Feb 2020 09:27 AM PST

    I want to build a youtube video compiler that can download the top videos of a given category (like dogs, birds, etc) and compile the downloaded videos.

    What i believe is needed: -Beautiful soup for scraping -Requests for scraping -Ffmpeg for video editing

    What else would i need

    Thanks :)

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

    error 'cout' was not declared in this scope. But I am using namespace std, so I don't know how to solve the issue.

    Posted: 09 Feb 2020 09:19 AM PST

    #include <stdio.h>

    using namespace std;

    struct car{

    char name[15];

    int speed;

    };

    void display(struct car example){

    cout<<"Name: "<<example.name<<" Top Speed: "<<example.speed<<endl;

    };

    int main(){

    struct car supercar = {"Lamborghini",230};

    display(supercar);

    return 0;

    }

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

    Running scheduled daemons in each of the user profiles

    Posted: 09 Feb 2020 08:56 AM PST

    Sorry for the vague title - guess, I dont know the techinical term.

    So I have a large set of user profiles with their own set of preferences (when to fire an email reminder for example). So I want to a have scheduler for each profile running in its own space. Just like any of the online services - calendar/tasks.

    I dont want a huge global monolith scheduler which goes through every user profile reads their preferences and executes them accordingly.

    I am sure this is possible as lot of services are doing it already, just dont know where to start about it.

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

    recursion problem

    Posted: 09 Feb 2020 07:46 AM PST

    yash is a part of club. He has an interesting ₹10 note having serial number 1000000. He liked that note but, he accidentally gave that note to someone in the team. Surprisingly, after some days, he got back that note. He wants to know the total possible sequence of transactions that might have happened after which he got back the note. But, as he knows nothing he is unable to count the total possible sequences. So, he asked for your help.

    Your task is to count the total possible sequences of transactions(repetition is allowed), given that exactly m transactions happened. As the number can be quite large, you should print it modulo
    1000000007(10^9 + 7).
    Let n = 3, m = 4
    Answer will be .
    Explanation:
    Let people in society be : Sparsh(A), B,C.
    Then possible transactions are 6:
    • A-B-A-B-A
    • A-B-A-C-A
    • A-B-C-B-A
    • A-C-B-C-A
    • A-C-A-B-A
    • A-C-A-C-A
    Using Recursive method: Write a Program that outputs T(n,m) for a given pair of n,m. For 1≤𝑛≤107 , 0≤𝑚≤12.

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

    Programming in R Studio

    Posted: 09 Feb 2020 12:09 AM PST

    Essentially I want to find statistical characteristics from downloaded S&P 500 data, FRED time series, bond yields ect and create graphs and plots. Using R studio

    Does anyone have any advice or resources on beginning learning to do computations in R like YouTube channels, books, lectures?

    Thanks!

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

    UPnP decoding / Sending commands with NodeJS

    Posted: 09 Feb 2020 04:54 AM PST

    I have Sonos speaker, which uses UPnP, and I want to decode the UPnP to understand what commands I should send over the network to control it.

    I don't know much about UPnP and not sure where to start. I eventually want to be able to send these commands through a NodeJS server running locally on my computer.

    Would appreciate any guidance on that

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

    Simple question for Java ( fast answer please i have my exam in 3 hours lol )

    Posted: 09 Feb 2020 04:23 AM PST

    Hello , i have a general question about Java classes ( parent and child ) . I will give an example :

    Class Video{

    Video() { sole= 10; }

    Video(int v0) { sole= v0; }

    int x() { return 7;}

    int c () { return 100; }

    }

    class Dvd extends Video{

    static int count = 9;

    Dvd() { count += 2; }

    int x() { return 13;}

    }

    Main program java here , i skipped , abc doesnt appear anywhere else .

    int abc=90;

    Video z = new Dvd();

    abc = z.x();

    My question is : abc takes the value of 7 or 13 ( with explanation please ) .

    Thank you in advance !!

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

    Can you get 4k-aliasing effects in branch predictors?

    Posted: 09 Feb 2020 04:16 AM PST

    I found this link that was posted on the C++ subreddit. It discusses branch prediction and 4k-aliasing, unrelated performance considerations that I am bringing together in this question.

    Branch prediction data must be stored somewhere, so my punt is that the lower few bits of the address of the assembly instruction are stored somewhere and fetched from a 4096 entry array for the prediction.

    If I have two assembly 'compare' instructions that are 4096 instructions (well, bytes) apart, they will share the same 12 bit address. The branch predictor will then assume the two compare instructions are the same instruction, and use each others predictions.

    You could have a loop where one branch comparison always evaluates true, and then the other comparison always evaluates false, and both would be predicted wrong every time.

    Does this problem exist? Can it be demonstrated?

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

    Help me please

    Posted: 09 Feb 2020 10:11 AM PST

    I honestly don't know if this is the right place to ask this, but I mistakenly turned all my programs in my computer into Notebooks and they open as ones. I'm not so great with computers, softwares and whatnot, can anyone tell me how can I fix this? Thank you.

    submitted by /u/Unknown-chan
    [link] [comments]

    No comments:

    Post a Comment