• Breaking News

    Sunday, October 28, 2018

    [JavaScript] Minesweeper game in 100 lines of code - easy tutorial learn programming

    [JavaScript] Minesweeper game in 100 lines of code - easy tutorial learn programming


    [JavaScript] Minesweeper game in 100 lines of code - easy tutorial

    Posted: 27 Oct 2018 07:48 AM PDT

    How do scripting languages run fast?

    Posted: 27 Oct 2018 11:15 PM PDT

    I'm well aware that scripting languages are slow. From what I understand they can be really fast. For example when most of it is using a 'c module' it can run in comparison of a native app. However I'm sure there's lots of techniques. Is there any books or articles I can read? What are ways of implementing a scripting language and having it run fast? I only know of using C code/modules and JIT

    submitted by /u/UniqueQuality-1
    [link] [comments]

    My Python calculator isn't working? I feel like the logic is correct...

    Posted: 27 Oct 2018 11:58 PM PDT

    I am new to constructing things in Python, so I thought I'd start by making a simple calculator; it can perform an operation on two numbers (so only two can be added together, one can be divided from another, etc.) and it contains operations for addition, subtraction, multiplication, division, and the modulus operator. It has an input where you first have to enter the kind of operation you're performing, then if and elif statements to calculate those two numbers based on the kind of operation you want, then finishing by printing the answer. For some reason, even though the logic looks completely sound, my code does NOT work. When I type anything into the first input, it'll add the two numbers I enter together no matter what, and will not perform other operations. What's wrong with my code?

     start = input("What kind of operation would you like to perform?") if start == "Add" or "add": additionEntry1 = float(input("First number:")) additionEntry2 = float(input("Second number:")) addAnswer = additionEntry1 + additionEntry2 print(addAnswer) elif start == "Subtract" or "subtract": subtractionEntry1 = float(input("First number:")) subtractionEntry2 = float(input("Second number:")) subtractAnswer = subtractionEntry1 - subtractionEntry2 print(subtractAnswer) elif start == "Multiply" or "multiply": multiplyEntry1 = float(input("First number:")) multiplyEntry2 = float(input("Second number:")) multiplyAnswer = multiplyEntry1 * multiplyEntry2 print(multiplyAnswer) elif start == "Divide" or "divide": divideEntry1 = float(input("First number:")) divideEntry2 = float(input("Second number:")) divideAnswer = divideEntry1 / divideEntry2 print(divideAnswer) elif start == "Modulo" or "modulo": moduloEntry1 = float(input("First number:")) moduloEntry2 = float(input("Second number:")) moduloAnswer = moduloEntry1 % moduloEntry2 print(moduloAnswer) else: print("Invalid command.") 

    print("Type START to run the program again.")

    Thanks in advance!

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

    (C) If I declare a string array without using malloc(), do I need to still free() it? Example below.

    Posted: 27 Oct 2018 07:36 PM PDT

    I need to read from a text file that contains a list of words from the dictionary and store them into a data structure.

    I'm choosing a string array. Since I know how may words there are, can I just do this?:

    char *dictionary[100000]; 

    And do I need to free() this at the end of the program?

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

    Can someone explain Big ‘O’ notation and why it helps to learn it?

    Posted: 27 Oct 2018 05:50 PM PDT

    So I've been teaching myself to program and have started looking into algorithms, right now I'm learning about sorting algorithms and some of the things I have read talk about the Big 'O' notation. I don't understand how it works or how it relates to Programming in general, thank you.

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

    Cannot Understand loops

    Posted: 27 Oct 2018 02:08 PM PDT

    So I am in my python class right now and I am falling behind so much because of these stupid loops. I keep re-reading the chapter and doing the example but when I get a problem using loops, I cannot do it myself and honestly its frustrating to the point where I actually think I am incapable of coding. Anyone have any tips or advice you can shed for me, the textbook I am using currently Learning Python 4th edition

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

    [Java] Please explain constructors and methods better

    Posted: 27 Oct 2018 05:41 AM PDT

    Hello, I am a first year student at a university and we're writing a test on Monday that includes basic knowledge of Java - multiple classes, references to objects, methods, constructors, method overloading etc.

    I am trying to get a better understanding on how methods and constructors work, but I've got a problem understanding exactly how the variables work with methods and constructors.

    For example I want to make a simple program that calculates the area of circle. I have class Main and class Circle in which I want to make a method that uses two attributes - radius and pi.

    public class Circle { private double pi; private double r; } 

    So far so good, now let's add a method with two arguments - double r and double pi:

    public class Circle { private double pi; private double r; public Double getArea(double r, double pi){ r = r; pi = 3.1415; return(r * r * pi); } } 

    Is my code okay at this point?

    Shouldn't there be another method called setArea as well, in which I want to set the value of radius?

    How do the variables work with multiple methods in one class?

    How do I print out an object with set attribute for radius in my Main class?

    How would the code that creates an object in which the getArea method is used look like?

    If I wanted to get the square root of the calculated area in the first method, how will the method that calculates the square root look like?

    If you can, please, point me toward these answers using examples. Thank you in advance.

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

    What's the difference between wrapping a library, and binding a library?

    Posted: 27 Oct 2018 11:51 PM PDT

    They both use glue code, so what's the difference?

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

    6 year old book worth studying?

    Posted: 27 Oct 2018 08:02 PM PDT

    I was recently given a C++ book from 2012 (C++11). I noticed online that it's currently up to C++17. Is is worth going through to learn? Or should I stick to online resources that are more up to date?

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

    Started #100DaysOfCode yesterday, and made a simple webpage for others to checkout what I've done!

    Posted: 27 Oct 2018 09:21 AM PDT

    https://wislos.github.io/100-days-of-code/

    Currently, I've just started on my Java project (to make a Todo-app), but I will make more! Anyone else doing 100 days of code?

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

    C++, Cannot figure out why my program will not/cannot read from the same file twice.

    Posted: 27 Oct 2018 11:24 PM PDT

    I am working on an assignment that required me to read from a file. Part of the assignment first requires me to count the amount of lines in the file. The next part of the assignment then requires me to read every line from the file in order to allow users to input a response according to each line. After googling I have found several iterations of potential solutions with this one describing perfectly what I am attempting to do. Other potential solutions are here, and here. I have also tried what seems like the simplest solution, file.close(), file.open(), with search results mentioning that file.clear(), must also be used. To the best of my knowledge, I have tried every iteration of possible solutions, to no avail. Any help in solving this issue/ and or steering me in the right direction would be greatly appreciated. Thanks in advance.

    My code can be viewed here.

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

    Trying to get GitHub to work with XAMPP. Sync htdocs AND database

    Posted: 27 Oct 2018 11:03 PM PDT

    I'm a bit familiar with github and totally new to xampp.

    I'm working on a project with a few friends and would like to be able to use github so that everyone can contribute and see changes etc

    Usually I would create a github repo and put my project folder in there (for instance my Unity3D project or and Android Studio project).

    However, as far as I know, XAMPP stores my php/html/css etc files in \htdocs\myproject\ and my database in \mysql\my_db\

    I dont know how to get both of the things (my actual website files, php/html/css, and my database files) to be in one repository.

    Right now the only solution I can think of is to only sync the htdocs\myproject\ folder and just have separate database on each computer (which is going to be a pain since we're supposed to work on the database too).

    Any help is appreciated. Thanks!

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

    Building a Line Sentiment Detection Chatbot

    Posted: 27 Oct 2018 10:27 PM PDT

    Yes, it's another bot tutorial! However, this one has some interesting elements, and is quite extensible. Here is part 1 of the ongoing series: Building a Sentiment Detection Bot with Line and Ruby.

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

    Can't help making lots of classes?

    Posted: 27 Oct 2018 10:13 PM PDT

    This isn't really a specific example, but whenever I start a project in an OOP language, I always end up making tons of classes before I get anywhere.

    Usually, I have one central focus, but end up making tons of support classes that play a sort of minimal role. How much is too much?

    EDIT: I'm not sure if this is the right place to post this. If it isn't, I'm really sorry.

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

    Routing in Express/Node

    Posted: 27 Oct 2018 09:57 PM PDT

    If you have two routes such as:

    app.get("/", function(_,res){

    res.render("home");

    });

    app.get("/:id", function(_,res){

    res.render("home");

    });

    As you can see, both routes render the same page. Is there a way to combine this into just one line?

    I know you can use app.get("*"), but I do not want to allow urls that have more than one "/".

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

    How do I save user data on a website?

    Posted: 27 Oct 2018 09:51 PM PDT

    I'm really new to html, like I just started yesterday new. I think I understand a lot of the basics, like how the tags work, how to format with CSS, embed code with JavaScript, etc. that's where my knowledge ends. I think for the next step, I need to figure out how to actually store data. This could be something like account information, or for instance, I was trying to recreate a poll like the ones on straw poll.com, (I thought that would be a good beginner exercise), and while I think I have the formatting figured out, I've hit my wall. How do I save the answers?

    Looking into it, if I'm understanding correctly (part of the problem is I don't understand the terminology to look up what I want) I think I need to set up a database with SQL, but looking into that, I had no idea where to start. I'm not even asking for like a direct tutorial, it just seems really overwhelming and I don't know where to start learning how to make a website of my own. Thanks for the help, and I appreciate any pointers.

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

    How long does it take to complete the Odin Project for a college student?

    Posted: 27 Oct 2018 03:53 PM PDT

    I'm a CS major in college trying to integrate the Odin project (among other things) into and independent study course on web development. I'm trying to figure out about how much time it should take to complete the course because I only have about 3 months and 3 hours per day. Not to mention I also want to integrate a few other subjects (sql, boot strap, etc.)

    Any recommendations of complementary programs would be appreciated.

    Edit: I plan on skipping the jQuery section. I'm trying to get an internship this summer and all the ones on my list do not require knowledge of java.

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

    Assembly Language, simple code made more efficient

    Posted: 27 Oct 2018 09:27 PM PDT

    What could I change to give this code a performance boost? This program is supposed to multiply each half word from multiplicands array by the same numbered half word in MULTIPLIERS array and put the result in the same numbered element in PRODUCTS array.

    text

    .global

    _start

    _start:

    .equ

    NUM, 4

    LDR R1,=MULTIPLICANDS

    @ Load pointer to MULTIPLICANDS array

    LDR R2, =MULTIPLIERS

    @ Load pointer to MULTIPLIERS array

    LDR R3, =PRODUCTS

    @ Load pointer to PRODUCTS array

    MOV R4, #NUM

    @ Initialize loop counter

    NEXT:

    LDRH R6,[R1]

    @ Load a MULTIPLICAND Half word in R6

    LDRH R7, [R2]

    @ Load a MULTIPLIER half Word in R7

    MUL R8, R6, R7

    @ Multiply

    STR R8, [R3]

    @ Store result in PRODUCTS array

    ADD R1,R1,#2

    @ Increment MULTIPLICANT pointer to next

    ADD R2,R2,#2

    @ Increment MULTIPLIER pointer to next

    ADD R3,R3,#4

    @ Increment PRODUCTS pointer to next

    SUBS R4,#1

    @ Decrement loop counter by 1

    BNE NEXT

    @ Go to NEXT if all elements not multiplied

    NOP

    @ Instruction for breakpoint. Does nothing.

    .data

    MULTIPLICANDS:

    .HWORD 0x1111, 0x2222, 0x3333, 0x4444

    MULTIPLIERS:

    .HWORD 0x1111, 0x2222, 0X3333, 0x4444

    PRODUCTS:

    .WORD 0x0, 0x0, 0x0, 0x

    .END

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

    Making Game With JavaScript and P5JS

    Posted: 27 Oct 2018 05:14 PM PDT

    So I've always been told that even though you think you may have an understanding of something, you truly don't understand it until you can teach it to others. Even Albert Einstein said, "If you can't explain it simply, you don't understand it well enough."

    I've just started live streaming my process of making a set of JavaScript games using the library p5js. I try and explain while I program and hopefully my videos can help others. I live stream them to both Twitch and YouTube. Feel free to leave comments of you have questions about anything.

    Twitch: https://www.twitch.tv/collections/K9h4akCKXhWtrg

    YouTube: https://www.youtube.com/playlist?list=PLCGtQjAB1Winev5ytBIsnoW5Bj6TnsZqk

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

    Is it possible to click HTML button from within the code?

    Posted: 27 Oct 2018 08:55 PM PDT

    Hi, I am using Apple's new app Shortcuts, it lets you program relatively basic scripts from within your iPhone/iPad. As of right now I am experimenting with websites and automating things using them. The thing is I got into this page http://www.myrapname.com/ and I want to be able to generate a rap name using the html, that is filling the text box that asks you for your first name and then clicking the "Suggest male rap name" or "Suggest female rap name" button.

    From within shortcuts I can use GET, POST, PUT, PATCH and DELETE methods, but I don't know how to use them to fill the text box and click the button. In the past I've used GET to get information from certain websites, but I've never done something like what I am trying to do right now so I would like to know if it's possible and how would you do it?

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

    Learning by reading source code?

    Posted: 27 Oct 2018 04:57 PM PDT

    After Watch and Code, I went ahead and completed the premium content as well. The main focus is learning by reading source code, the parallel being if you were an aspiring writer, you'd first read a bunch of books. Most programmers will probably admit they also spend more time reading code than writing.

    The last few videos briefly went over Underscore.js, so I've been continuing with that. While I've learned a lot, the process has been very slow and painful. The comments often aren't that helpful in really understanding how things are working. The code feels very intertwined when every function ends up calling ten other functions. I'm assuming Underscore is considered well designed, but you have to keep so many things in mind when looking at one function. I don't know if I'll ever be capable of writing anything with the same complexity.

    I've gotten past all the setup, which is probably the most difficult part, so I'll probably continue reading bits and pieces. But I'm curious what you guys think. Is this really a good way to learn? Should I read smaller libraries in the future? Should I still spend most of my time actually coding?

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

    Job opportunity as a junior programmer, need guidness for interview

    Posted: 27 Oct 2018 08:08 PM PDT

    Hello reddit!

    I need help. I got great chance to get a junior software engineering position in the company that I am working at currently. I am a beginner still, only familiar with basic principles of programming, doing python and JavaScript for a while. I am studying software and data engineering on college (started almost a month ago in first year).

    So the job that I will be applying in 2months from now at most, will be a job where I will be writing some scripts(I don't know more info at the moment but nothing too complicated as my colleague told me), batch scripts, job starts from zero and they require only the basic knowledge nothing else.

    On the interview they are asking to solve minor algorithms, actually to solve minor problems with algorithms in pseudo code. Not even a couple of code lines, just to test your ability to think.

    I doubt that I can get that job since I have no CV but I will have good recommendation (hopefully), I've proven that I am hard working in that company, one of the best in team of 100+. But I have no idea how to prepare myself for this interview. I want this job so bad!!!

    Would you please, anyone, please help me prepare myself for those questions, tasks, give me advice...? anything and I would appreciate it a lot!!

    Sorry for the long post, I really hope I can grab this job opportunity.

    Thank you in advance!

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

    [Java] Luhn Algorithm Help

    Posted: 27 Oct 2018 07:34 PM PDT

    I am trying to code something using the luhn algorithm that takes the sum of the computation and adds it back to the original user entered string. For example 7992739871 should give me 79927398713 but is instead giving me 7992739871144. Please help:

    import java.util.Scanner;

    public class luhn

    {

    static void main(String[] args){ Scanner kb = new Scanner(System.in); String entry = kb.next(); int entryLength = entry.length(); int sum = 0; for(int num = entryLength - 1; num >= 0; num--){ int d = entry.charAt(num) - 2; d = d * 2; sum += d / 10; sum += d % 10; } System.out.println(entry+""+sum); } 

    }

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

    Frontend vs Backend

    Posted: 27 Oct 2018 08:14 AM PDT

    Hi all!

    I apologize if this is against the rules but I am having a really hard time deciding what I want to do. I am currently working as a radio producer who would like to get into programming and eventually make a career change. I have been doing a ton of reading and research and trying to decide what language to start with and I have seemed to narrow it down to JavaScript if I want to do frontend development and Python if I want to do backend. My issue now is deciding between frontend and backend.

    I am not asking you to decide for me I am asking how you decided and what ultimately made you choose which way you wanted to sway for work. Also if I want to go full-stack is it better to learn both JS and Python or is one of them better than the other for full-stack.

    Thanks!

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

    No comments:

    Post a Comment