• Breaking News

    Sunday, October 6, 2019

    What have you been working on recently? [October 05, 2019] learn programming

    What have you been working on recently? [October 05, 2019] learn programming


    What have you been working on recently? [October 05, 2019]

    Posted: 05 Oct 2019 09:04 AM PDT

    What have you been working on recently? Feel free to share updates on projects you're working on, brag about any major milestones you've hit, grouse about a challenge you've ran into recently... Any sort of "progress report" is fair game!

    A few requests:

    1. If possible, include a link to your source code when sharing a project update. That way, others can learn from your work!

    2. If you've shared something, try commenting on at least one other update -- ask a question, give feedback, compliment something cool... We encourage discussion!

    3. If you don't consider yourself to be a beginner, include about how many years of experience you have.

    This thread will remained stickied over the weekend. Link to past threads here.

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

    How do you learn what "good" code is?

    Posted: 05 Oct 2019 11:49 AM PDT

    Code can run and still look like trash, be overly complicated (this is the hardest one for me: how do I make this working program simpler?), hard to read, etc. How does someone who's learning to program learn to write good code instead of just "making it do what it's supposed to"?

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

    Useful Bookmarks

    Posted: 05 Oct 2019 07:52 PM PDT

    Hi Everyone, Today I created a list of my browser bookmarks. I bookmarked these links when I was learning programming or when I discovered something new. I thought It would be helpful to share it with you guys so you can find it helpful too

    Furthermore there's a lot of work to be done since it's a simple markdown file but I will be working on hosting it as a static site so I can implement search that will make easier to search through bookmarks.

    What are you thoughts on this ??

    useful-bookmarks
    submitted by /u/dev_o47
    [link] [comments]

    I am new to programming and would very much appreciate it if someone could point me in the direction of some helpful resources for a small project I'm working on

    Posted: 05 Oct 2019 07:25 PM PDT

    I am familiar with web development, but I would like to try my hand at creating a very simple application for windows 10 and I just have no clue where to start. So any advice or links to tutorials or anything helpful would be much appreciated

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

    How can I automate changes in my MySQL database?

    Posted: 05 Oct 2019 09:36 PM PDT

    So here is what I am trying to figure out.

    I have a database where I store memberships to a club. On January first of every year I need to update the status of these members based on whether or not they have paid a membership fee. Then on February First I need to change their state again, if they still have not payed the fee to reflect that they are no longer members. As it stands right now, I would be relying on someone to log into my online database, and check on the members page for anything to interact with the database. Is there a way I can trigger an event through MySQL to automatically change the state of these member fields at Midnight on January 1st, because if no one, hypothetically, were to log in during the entire month of January and check this page, it would effectively break the database because then no fields would ever be changed.

    TL;DR: How can I get my database to make changes to itself at a certain date or time without having to rely on people logging in and interacting with the database through PHP?

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

    Unable to compile on Mac using gcc/g++

    Posted: 06 Oct 2019 12:02 AM PDT

    I am using the command "g++ -std=c++11 -o file file.ext" to compile some c++ text that references a header file in my working directory. I get a lot of errors when trying to do this, but not when writing other simple c++ code that does not reference the file.

    When I am working over an ssh connection to my school's server (running linux) I have no issues compiling my code using the same command in the terminal. Its not ideal for me to be working on everything over the ssh connection, I don't even have internet at home. So I need to find a way to be able to compile code on my own machine that has these issues with different versions of c++ in it (i assume is what is happening).

    Hopefully Ive given enough information so far, but if anyone has any advice I would really appreciate it. I need to finish my homework! thanks

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

    Learning javascript

    Posted: 05 Oct 2019 11:55 PM PDT

    What are some good youtubers that code in javascript?

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

    python help

    Posted: 05 Oct 2019 11:41 PM PDT

    hi i was wondering with this -os.system("start cmd /D /C python3 file.py")- is there anyway to start it in a minimized form?

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

    What should I know before going to a cyber security hackathon?

    Posted: 05 Oct 2019 11:39 PM PDT

    I've registered for a cyber security hackathon, mostly on a whim. I dont have any formal knowledge in the field so I was wondering - what should I definitely know/learn before taking part in such an event?

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

    How not to comment (and how to).

    Posted: 05 Oct 2019 11:37 PM PDT

    I came across a comment today in a large pile of ugly (very ugly) legacy code I've been unlucky enough to inherit and it annoyed the hell out of me. I then came online hoping to find a place to share it so as to purge said annoyance (I searched for "Stupid code comment of the day", among other things). I couldn't find a dedicated place, but I did find this learning to program Reddit, so I thought I'd leave it here with a little "moral to the story" so those learning to program can, well, learn something that will help them not get a change request in the ol' code review.

    // For now, only TCP sockets can be created // added UDP 

    That there is the comment. I don't know if they were written by two people (bad) or the same person (even worse), but the lesson here is: do not be afraid to delete a comment. Once someone came along and added UDP support, the first line should have been deleted. But someone thought it needed to be preserved for posterity instead (this code has always been under a VCS, but maybe the author of the second comment thinks that is best done with comments; speaking of VCS, I could go back and find who put that second comment there, but I'm afraid it will be someone I still work with so I really don't want to know).

    Now, comments are important. There are other things that are more important, but as long as you're not writing things like "// Add 1 to i." right above "i += 1;", then they're important (and unless you're in a tight loop with an index named i, don't give a variable a meaningless name like 'i').

    • Don't comment too much. Let your well-written/named code, spread across small functions and/or classes, speak for itself where possible, though it definitely won't always be possible; sometimes, even well thought out, elegant code gets gnarly, and gnarly code may need a comment.
    • But don't comment too little, either. Comment especially at the head of your functions and classes. But if you've got coherent functions and classes that do one or a few (closely related) things each, then inline comments will mostly be left to the whys (but usually not the whats or hows), especially at system boundaries (e.g. you'll probably want to explain what some other system is saying to your system, or why you're handling a message from another application in a counterintuitive way, or what the format of that application's message header is).
    • And old comments should be adjusted - or deleted - as you adjust - or delete - code. In fact, my favorite way to write code is to delete code when possible/appropriate. Less code, all else being equal, means fewer bugs (and you're using source control - you are, right? - to get it back if needed). And when the code goes, any related comments goes as well.
    • And use proper grammar and punctuation in your comments.

    Good comments, like good code, take practice. I'm still adjusting what and how and where I write comments after 15+ years of programming professionally. The key is to always take a minute to evaluate what you're doing to see if you can do better - and don't be afraid to change.

    And one final note: while all seasoned programmers will agree with some of what I said above, I guarantee that some won't agree with all of it, which shows that, like many, if not most, things in programming, there aren't always hard and fast rules. Keep an open mind and experiment!

    /rant off; thanks for listening.

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

    How can I fix this? It is giving me a probability of 0.0 for every number!

    Posted: 05 Oct 2019 11:27 PM PDT

    I'm making a program that will muffin' take the dang for to be playing n number of songs on your SHUFFLE MODE (of zune or iPods, etcetera) input from our user. I am making a program to determine the probability of hearing 3 sequential songs. here is the exact problem (dot)...

    You set your music player to shuffle mode. It plays each of the n songs before repeating any. Write a program to estimate the likelihood that you will not hear any sequential pair of songs (that is, song 3 does not follow song 2, song 10 does not follow song 9, and so on).

    every number I put in gives a 0.0 probability

    import java.util.Scanner; import java.util.Random; public class ShuffleMode{ public static void main(String[] args){ Scanner input = new Scanner(System.in); Random random = new Random(); System.out.println("how many songs being shuffled?"); int n = input.nextInt(); int playedInSequence = 0; int s1, s2, s3; for(int i=1; i<=n; i++) System.out.println("Playing song: " + i); s1 = 98; s2 = 99; for(int i=1; i<=1000; i++){ s3 = random.nextInt(n); if(s2==s1+1 && s3==s2+1) { playedInSequence++; System.out.println("Sequnce: " + s1 + ", " + s2 + ", " + s3); } } System.out.println("probability: " + (playedInSequence / 1000.0 * 100) + "%%" ); } } 
    submitted by /u/RoadManUnderwater
    [link] [comments]

    [JAVA / Spring] Beyond basic CRUD apps.

    Posted: 05 Oct 2019 10:36 PM PDT

    Most of the stuff I find online are just simple management systems. Library Management, Movie Ticketing, Student Managment, etc etc. I'm so tired of them and have lost any feeling of progression. Can somebody please point to any resource that contains case studies of complex systems with a little explanation and code.

    I feel like my progress has halted and can't seem to know how to level up from here.

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

    Is it possible to write your own 2FA app?

    Posted: 05 Oct 2019 07:41 AM PDT

    I wanted to do this as a final year project and implement new technologies on top of 2fa to make it more secure

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

    What can I do more than just follow online courses?

    Posted: 05 Oct 2019 06:30 PM PDT

    Currently learning C# and Unity for the past 5-6 months.

    Online courses are great but I feel like I could be doing more. I try to make some side projects but I always quickly end up stuck on something, cave in, google the solution & follow a tutorial, which is basically the same as following an online course.

    Is there more I can do? Read a book during my commute to work maybe? Is that even useful? Listen to podcasts at work? Is that a even a thing? Or just keep going with online courses, one after the other until I'm good enough to be employable?

    Thanks,

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

    Finding the seed root of a number

    Posted: 05 Oct 2019 10:14 PM PDT

    I am pretty new to coding and I have only been using c++ for about 2 months. I am having problems understanding an assignment of mine and I was hoping to get some clarification if possible.

    The instructions to my assignment are:

    Write a program in a file named SeedFinder.cpp that finds and displays all the seeds of a integer given by the user. Let's define a seed of an integer, n, to be a value that equals n when multiplied by its individual digits. For example, 23 is a seed of 138 because 23 × 2 × 3 = 138. 111 is an example of a seed of itself because 111 × 1 × 1 × 1 = 111. Many numbers have no seeds (e.g., 2) and some numbers have multiple seeds (e.g., 24 and 32 are seeds of 192).

    Implement the following functions as parts of your overall solutions:

    1. getPositiveWholeNumber
      : This function asks the user for a positive whole number (integer) repeatedly until the input is correct. You can assume that the user will only input whole numbers, but you need to check if they are positive.
    2. checkIfSeed
      : This function takes two parameters: (1) the number with possible seeds and (2) a possible seed to check. The function returns a bool. The function returns true
      if the possible seed is in face a seed of the first parameter; otherwise, the function returns false
      . The function should first check if the number is divisible by the possible seed, otherwise it cannot be a seed and no further checks are necessary. If the number is dividable by the possible seed, multiple the seed by each of its digits using a loop. Finally, compare that product with number. Hint: use the modulus operator to extract the last digit of a number and divide by 10 to remove the last digit of a number.
      This function should not get any input from the user or display any information (i.e., do not use cin
      or cout in this function).
    3. findAndDisplaySeeds
      : This is a void function that accepts a single integer as a parameter. The function should output "The seed(s) of N are:"
      (but replacing N with the parameter's value). After that, find and display each seed by looping through each possible seed value for the parameter and using checkIfSeed
      to see which values should be displayed. Output the word "none" if no seed values were found.
    4. The main function should simply display the header "--- Seed Finder ---
      ", call getPositiveWholeNumber()
      , and then displayNumberInfo()
      . Also, it may define any variables that are necessary.

    I don't really understand step 2 and 3. In step 2 how do I determine the divisor? what is this second parameter "possible check to check" and how do i use it to determine the seed. We just started working with functions and this has been a little overwhelming. Any help would be greatly appreciated.

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

    Help with C# UNITY movement coding

    Posted: 05 Oct 2019 10:08 PM PDT

    Hello guys,

    First of all, i would like to introduce me and my friend, who are NEWin programming a game. What game are we working on? We are working in a 2D PVP UNIQUE playability but that goal is really far since we are stuck in the basics

    Our problem? The reason of our shout of help? Movement. We want a 4 Direction, grid based movement yet what we have achieved is a not so smooth movement( if you press two arrow keys at the same time the character doesnt respond) but still, grid based. The main problem is that if you intercact with an object (fountain, enemies) the character gets stuck and tilting and uhg, you gotta restar the whole thing.

    Down below i'll copy you our code and would really appreciate some help, and improvements to make it 4 directions grid based and your computer not exploding.

    To top it off, we created an enemy ai to test our results but when they collide, they kinda "push" each other, sigh

    Thanks in advance from G&G

    Movement code:

    using System.Collections;

    using System.Collections.Generic;

    using UnityEngine;

    public class PlayerController2 : MonoBehaviour

    {

    public Rigidbody2D rb;

    private Animator animator;

    public int speed = 5;

    private DIRECTION dir = DIRECTION.DOWN;

    private bool attacking;

    private bool canAttack;

    private float timerAttack;

    private float delayAttack;

    void Start()

    {

    rb = this.GetComponent<Rigidbody2D>();

    animator = GetComponent<Animator>();

    attacking = false;

    canAttack = true;

    timerAttack = 0.0f;

    delayAttack = 0.25f;

    }

    void Update()

    {

    move();

    //ATAQUE

    if (Input.GetKey("q")) { attacking = true; } else { attacking = false; }

    timerAttack += Time.deltaTime;

    canAttack = timerAttack > delayAttack;

    if (attacking && canAttack)

    {

    timerAttack = 0f;

    animator.SetBool("Attacking", true);

    if (dir == DIRECTION.UP)

    {

    animator.SetFloat("MoveX", 0);

    animator.SetFloat("MoveY", 1);

    } else if (dir == DIRECTION.DOWN)

    {

    animator.SetFloat("MoveX", 0);

    animator.SetFloat("MoveY", -1);

    } else if(dir == DIRECTION.LEFT)

    {

    animator.SetFloat("MoveX", -1);

    animator.SetFloat("MoveY", 0);

    } else if (dir == DIRECTION.RIGHT)

    {

    animator.SetFloat("MoveX", 1);

    animator.SetFloat("MoveY", 0);

    }

    }

    else

    {

    animator.SetBool("Attacking", false);

    }

    }

    private void move()

    {

    if (Input.GetKey(KeyCode.UpArrow))

    {

    if (dir != DIRECTION.UP)

    {

    dir = DIRECTION.UP;

    }

    else

    {

    animator.SetFloat("MoveX", 0);

    animator.SetFloat("MoveY", 1);

    animator.SetBool("Moving", true);

    }

    }

    else if (Input.GetKey(KeyCode.DownArrow))

    {

    if (dir != DIRECTION.DOWN)

    {

    dir = DIRECTION.DOWN;

    }

    else

    {

    animator.SetFloat("MoveX", 0);

    animator.SetFloat("MoveY", -1);

    animator.SetBool("Moving", true);

    }

    }

    else if (Input.GetKey(KeyCode.LeftArrow))

    {

    if (dir != DIRECTION.LEFT)

    {

    dir = DIRECTION.LEFT;

    }

    else

    {

    animator.SetFloat("MoveX", -1);

    animator.SetFloat("MoveY", 0);

    animator.SetBool("Moving", true);

    }

    }

    else if (Input.GetKey(KeyCode.RightArrow))

    {

    if (dir != DIRECTION.RIGHT)

    {

    dir = DIRECTION.RIGHT;

    }

    else

    {

    animator.SetFloat("MoveX", 1);

    animator.SetFloat("MoveY", 0);

    animator.SetBool("Moving", true);

    }

    } else

    {

    animator.SetBool("Moving", false);

    }

    }

    }

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

    Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) 1

    Posted: 05 Oct 2019 10:05 PM PDT

    my code:

    int main()

    {

    `return 0;` 

    }

    I keep getting this damn error whenever I create a new Visual Studio project, does anyone know what it means?

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

    Is it possible to run a python script in html code?

    Posted: 05 Oct 2019 09:57 PM PDT

    I want to run a python script on my webpage

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

    How can my website edit a Google Sheet when a user votes on a poll on my website?

    Posted: 05 Oct 2019 09:33 PM PDT

    I want to treat this google sheet as a backend for my website, but how can I edit the sheet in my frontend html code? Do I use POST or PUT?

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

    Grade converter wont log Bs or Cs

    Posted: 05 Oct 2019 09:29 PM PDT

    let convertToLetterGrade = function(score) {

    `if ( score = 100 && score >= 90 ) {` `console.log(' A ')` 

    }

    `else if ( score <= 89 && score >= 80 ) {` `console.log(' B ')` 

    }

    `else if ( score <= 79 && score >= 70 ) {` `console.log(' C ')` 

    }

    `else if (score <= 70 ) {` `console.log(' F ')` 

    }

    }

    i cant get the converter to spit out a b or c..

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

    Program Design Class Help

    Posted: 05 Oct 2019 09:19 PM PDT

    For my program design class i have to make a function that uses pointers to encrypt a number in C. The function takes in two arrays as pointers and the size of the arrays as an int. Each array has each digit of the number as an element. it encrypts the number by taking each digit them from an array A adding six to each one then doing modulus by 10 and storing the new number in array B. it then would swap the first and the last digit. this is my code so far:

    void encrypt(int *a, int *b, int n) {

    int *i, *j;

    int k = 0;

    int temp;

    for(i = a; i < a + n; i++) {

    j = b + k;

    *j = (*i + 6) % 10;

    k++;

    }

    i = b;

    j = b + n;

    temp = *i;

    *i = *j;

    *j = temp;

    }

    it works fine up until the point at the end where it has to swap the numbers, im not sure whats going on here, any help is appreciated.

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

    [Laravel] Homestead installed but not recognized as command

    Posted: 05 Oct 2019 12:26 PM PDT

    Hello

    A friend of mine suggested I started learning Laravel. In order to do that, I'm trying to follow this tutorial series:

    https://laracasts.com/series/laravel-5-fundamentals/episodes/2

    The problem is that, before actually going into Laravel proper, it seems necessary to install a few other programs, including the last one, Homestead, which was properly installed (or at least appeared to be so, based on the texto from the command window). Unfortunately, when I try to use it it isn't recognized as an internal or external command.

    Googling the problem encounters suggestions of "setting the PATH", which I have no clue what it means. I have already tried rebooting my PC, to no avail.

    Any help with configuring homestead would be appreciated. Failing that, if you could point me to a tutorial that doesn't require as many other programs to be installed in order to go through with them, it'd also be most appreciated.

    Thank you very much for taking your time to read this :)

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

    When asked to write a program that involves "n" number of things, does that mean we are supposed to get that number from the user?

    Posted: 05 Oct 2019 03:08 PM PDT

    Like for this problem-

    Rumors. Alice is throwing a party with n other guests, including Bob. Bob starts a rumor about Alice by telling it to one of the other guests. A person hearing this rumor for the first time will immediately tell it to one other guest, chosen uniformly at random from all the people at the party except Alice and the person from whom they heard it. If a person (including Bob) hears the rumor for a second time, he or she will not propagate it further.

    Write a program to estimate the probability that everyone at the party (except Alice) will hear the rumor before it stops propagating. Also calculate an estimate of the expected number of people to hear the rumor.

    It doesn't tell us how many people are there, nor does it tell us how long the party is or how long it takes to spread the rumor from one person to the next. So does it want us to get these numbers from the user? Is this what is meant by 'n'?

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

    What was so hard about learning "programming"??

    Posted: 05 Oct 2019 08:56 PM PDT

    Hello to anyone who is learning programming. I have a question about learning the subject. Since this is a reddit for people who are working hard in learning, I thought it would be great to ask this.

    Regardless of the language or concept, what was so hard about learning it? How did you overcome the obstacles in learning them?

    Waiting for great comments :)

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

    getting an unexpected token error in the console

    Posted: 05 Oct 2019 08:42 PM PDT

    let convertToLetterGrade = function(score) {

    if ( score = 100 && >=90 ) { console.log('A') 

    }

    if ( score = 89 && >= 80 ) { console.log( 'B' ) 

    }

    if ( score = 79 && >= 70 ) { console.log(' C ') 

    }

    if (score = <70 ) { console.log(' F ') 

    }

    ​}

    convertToLetterGrade=(78)

    the error appears on line 2 but i dont have anything on that line

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

    No comments:

    Post a Comment